Skip to content

Instantly share code, notes, and snippets.

@kenoss
Created April 3, 2016 09:52
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 kenoss/85ed24b3d168234a16d5f4f7a1e0b29a to your computer and use it in GitHub Desktop.
Save kenoss/85ed24b3d168234a16d5f4f7a1e0b29a to your computer and use it in GitHub Desktop.
function peco-find-file() {
local source_files
if git rev-parse 2> /dev/null; then
source_files=$(git ls-files)
else
source_files=$(find . -type f)
fi
local selected_files=$(echo $source_files | peco --prompt "[find file]")
LBUFFER="${LBUFFER% } $(echo ${selected_files} | tr '\n' ' ')"
zle redisplay
}
zle -N peco-find-file
bindkey '^u^f' peco-find-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment