Skip to content

Instantly share code, notes, and snippets.

@omkar0001
Created October 6, 2019 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omkar0001/9ba841b207be95137dbbae568c14f7b2 to your computer and use it in GitHub Desktop.
Save omkar0001/9ba841b207be95137dbbae568c14f7b2 to your computer and use it in GitHub Desktop.
FZF utils
#!/usr/bin/env zsh
# fd - cd to selected directory
fd() {
local dir
dir=$(find ${1:-.} -path '*/\.*' -prune \
-o -type d -print 2> /dev/null | fzf +m) &&
cd "$dir"
}
# fe [FUZZY PATTERN] - Open the selected file with the default editor
# - Bypass fuzzy finder if there's only one match (--select-1)
# - Exit if there's no match (--exit-0)
fe() {
local files
IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment