or include any other directories you don't want like .DS_Store etc. Then run sudo updatedb to update the mlocate database. After that you can just pipe the output to fzf.
# look for any path in you $HOME directorylocate-ei"$HOME"|fzf--height40%--reverse
If you followed the previous tip then using this is a no brainer
# faster but limitedcd"$(locate "$HOME" |fzf--height40%--reverse)"# bit slower but bettercd"$(find~-maxdepth5-not-path '*/\.git/*' -typed|fzf--height40%--reverse)"
fzf can be used as a nice prompt for showing git branches:
#!/usr/bin/env shchoice=$(gitfor-each-ref--format='%(refname:short)'refs/heads/*|fzf \--prompt="Switch branch: " \--header="Select a branch to switch to" \--height40%--reverse)gitswitch $choice
Interactively stage files in Git
#!/usr/bin/env bashreadarray-tchoices<<(gitls-files--other--modified--exclude-standard|fzf \--prompt="Stage Files: " \--height40%--reverse--multi \--header="Choose files to stage (TAB to select multiple files)")gitadd"${choices[@]}"
Deleting unused branches interactively
#!/usr/bin/env shheader="Select branches to delete"choices=$(gitfor-each-ref--format='%(refname:short)'refs/heads/*|fzf \--prompt="Delete Branches: "--pointer='🡆'\--header="Press TAB to select choices" \--multi--height30%--reverse)gitbranch-d $choices
Diff(ing) files across branches
Useful in cases when your working with multiple people and want to compare files that are changed while building a feature.
#!/usr/bin/env bash# FZF Wrapper over git to interactively diff files across branchesreadarray-tgit_files<<(gitls-files|fzf \--prompt="Choose File(s): " \--height40%--reverse--multi \--header="Choose files to diff (TAB to select multiple files)")target_branch=$(gitfor-each-ref--format='%(refname:short)'refs/heads/*|fzf \--prompt="Select target branch: " \--header="Select branch to compare the files against" \--height40%--reverse)# get current branchcurrent_branch=$(gitbranch|grep \\*|cut-d' '-f2)printf"%s\n""Viewing diff for following files against $(tputbold)$target_branch$(tputsgr0)"printf"$(tputbold)$(tputsetaf208)%s$(tputsgr0)\n""${git_files[@]}"echogitdiff"$current_branch".."$target_branch"--"${git_files[@]}"
I like the idea of using emojis in commit messages but I am not ready to install node/npm and 10 other dependencies for a CLI.
We can use fzf to create a nice gitmoji like prompt. Here is a simple bash script that does the job. First download the gimojis.csv file and change the path to the csv file in the script.
Previewing directories may include listing its contents
# Notice the [[ -d ... ]] means only run when the path is a directorylocate-ei"$HOME"|fzf--preview"[[ -d {} ]] && tree -C {} | head -200"--height40%--reverse
Beautifying fzf?
fzf offers very minimal but satisfying enough features to tweak around
Changing pointers (default '>'). Below are some valid pointer styles
A full list of color rules can be found here or on man fzf. Below are some nice colorscheme combinations you might like
# Inspired from ayu colorscheme Vim--color'fg:#E6E1CF,fg+:#ddeeff,bg:#0F1419,pointer:#FF8400,header:#70B650,query:#FCD363'# Inspired from afterglow theme Vim--color'fg:#E6E1CF,fg+:#ddeeff,bg:#1A1A1A,bg+:#393939,pointer:#FF8400,header:#717879'# Inspired from sonokai theme Vim--color'fg:#E6E1CF,fg+:#ddeeff,bg:#2C2E34,bg+:#3C3E48,pointer:#EB4B48,header:#7F8490'# Inspired from Monokai Pro--color'fg:#E6E1CF,fg+:#ddeeff,bg:#2B292E,bg+:#3D3B40,prompt:#A9DC76,pointer:#FF6188,header:#AB9DF2,query:#FFD866'