Skip to content

Instantly share code, notes, and snippets.

@Vaisakhkm2625
Last active January 20, 2023 14:56
Show Gist options
  • Save Vaisakhkm2625/88d247d97c49ced09b23885c6b1c0505 to your computer and use it in GitHub Desktop.
Save Vaisakhkm2625/88d247d97c49ced09b23885c6b1c0505 to your computer and use it in GitHub Desktop.
fuzzyCD - fuzzyfind a file and cd into that dir containing that file
#add his to your bashrc file
#then type fcd to search for file and cd into that dir.
#fzf needs to be installed
fzfa(){
fzf --color 'fg:#839496,fg+:#93a1a1,bg:#002b36,bg+:#073642' --height 50% --reverse
}
fcd() {
local target;
target="$(find . -name '.git' -type d -prune -o -name 'undodir' -type d -prune -o -type f -print | fzfa)" || return;
cd "${target%/*}";
}
---------------------------------------
This is the new way to do
export FZF_DEFAULT_COMMAND='fd --color=always --type file --follow --hidden --exclude .git'
export FZF_DEFAULT_OPTS="--ansi"
fcd() {
local target;
target="$(fzf)" || return;
cd "${target%/*}";
}
------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment