commit 4d8151a1ef582941eaba32be6416f2ba2f458fbd parent b5d6d035d02cd5c6b0450eb33ec194a5d0cccbf6 Author: Alex Balgavy <a.balgavy@gmail.com> Date: Mon, 11 Nov 2019 01:39:28 -0500 shell: more fzf functions Former-commit-id: 4c9ba686e7fce5a89bf5e9cbf10e416e6e9c4f1f Diffstat:
M | shell/functions | | | 25 | ++++++++++++++++--------- |
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/shell/functions b/shell/functions @@ -53,6 +53,7 @@ if command -v osascript &> /dev/null; then echo 'No Finder window found' >&2 fi } + # echo current Finder directory gdf() { osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)' @@ -60,10 +61,9 @@ if command -v osascript &> /dev/null; then # echo selected Finder file fsel() { osascript -e 'tell application "Finder" to return POSIX path of (first item of (get selection as alias list) as alias)' | rev | sed 's/^\///' | rev; - }; + } fi -# fzf functions {{{ if [ -f ~/.fzf.zsh ] || [ -f ~/.fzf.bash ]; then export FZF_DEFAULT_OPTS="--preview-window right:100:hidden:wrap --bind '?:toggle-preview' --preview='(bat --style=numbers --color=always {} || cat {}) 2>/dev/null | head -500'" export FZF_DEFAULT_COMMAND="ag -l -g \"\"" @@ -79,16 +79,23 @@ if [ -f ~/.fzf.zsh ] || [ -f ~/.fzf.bash ]; then vim $DOTFILES/scripts/"$1" && chmod +x $DOTFILES/scripts/"$1" } - # config edit - ce() { - local files - IFS=$'\n' files=($(command find ~/.dotfiles -type f -not -ipath "*/.git/*" | fzf -m --inline-info --prompt="edit> " --height=40 --reverse)) - [[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}" - } + # script find + sf() { + local f + IFS=$'\n' f=($(command find "$(readlink ~/.scripts)" -type f -not -ipath "*/.git/*" | fzf +m --prompt="find> " --height=40 --reverse --cycle)) + [[ -n "$f" ]] && printf "$f" + } + + # config edit + ce() { + local files + IFS=$'\n' files=($(command find ~/.dotfiles -type f -not -ipath "*/.git/*" | fzf -m --inline-info --prompt="edit> " --height=40 --reverse)) + [[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}" + } # vim setting edit ve() { local files - IFS=$'\n' files=($(command find ~/.dotfiles/vim -type f -not -ipath "*/.git/*" | fzf -m --inline-info --prompt="edit> " --height=40 --reverse)) + IFS=$'\n' files=($(command find ~/.dotfiles/vim -type f -not -ipath "*/.git/*" | fzf -m --inline-info --prompt="edit (vim)> " --height=40 --reverse)) [[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}" } # run python