(zshrc) update fdc to quickly select from query string
This commit is contained in:
parent
086369252f
commit
6caf4b1178
1 changed files with 20 additions and 8 deletions
16
zsh/.zshrc
16
zsh/.zshrc
|
|
@ -60,20 +60,32 @@ sf() {
|
||||||
|
|
||||||
# fuzzy cd into specific folders
|
# fuzzy cd into specific folders
|
||||||
fcd() {
|
fcd() {
|
||||||
local selected_dir=$({
|
local selected_dir=""
|
||||||
|
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
selected_dir=$({
|
||||||
|
find "$HOME/.config" -type d -maxdepth 1
|
||||||
|
echo "$HOME/Documents/Obsidian Vault"
|
||||||
|
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
|
||||||
|
ls -d -1 "$HOME/"/*/ | grep -v \.git
|
||||||
|
ls -d -1 */ | perl -pe "s#^#$PWD/#" | grep -v \.git
|
||||||
|
} | fzf --filter="$1" --select-1 --exit-0 | head -1)
|
||||||
|
else
|
||||||
|
selected_dir=$({
|
||||||
find "$HOME/.config" -type d -maxdepth 1
|
find "$HOME/.config" -type d -maxdepth 1
|
||||||
echo "$HOME/Documents/Obsidian Vault"
|
echo "$HOME/Documents/Obsidian Vault"
|
||||||
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
|
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
|
||||||
ls -d -1 "$HOME/"/*/ | grep -v \.git
|
ls -d -1 "$HOME/"/*/ | grep -v \.git
|
||||||
ls -d -1 */ | perl -pe "s#^#$PWD/#" | grep -v \.git
|
ls -d -1 */ | perl -pe "s#^#$PWD/#" | grep -v \.git
|
||||||
} | fzf)
|
} | fzf)
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$selected_dir" ]; then
|
if [ -n "$selected_dir" ]; then
|
||||||
cd "$selected_dir"
|
cd "$selected_dir"
|
||||||
if [[ -f .nvmrc ]]; then
|
if [[ -f .nvmrc ]]; then
|
||||||
NVMRC_VERSION=$(cat .nvmrc)
|
NVMRC_VERSION=$(cat .nvmrc)
|
||||||
CURRENT_VERSION=$(nvm current)
|
CURRENT_VERSION=$(nvm current)
|
||||||
if [ "$NVMRC_VERSIOn" != "$CURRENT_VERSION" ]; then
|
if [ "$NVMRC_VERSION" != "$CURRENT_VERSION" ]; then
|
||||||
nvm use
|
nvm use
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue