Skip to content

Commit

Permalink
scripts: add fzf history
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Sep 16, 2021
1 parent 389ecd0 commit 806d4fe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- [ ] !!! use file path for git parsing instead of cwd
- [x] !!! use file path for git parsing instead of cwd

- [x] add version flag
- [x] don't pass `0` line/col to kak
Expand Down
5 changes: 4 additions & 1 deletion scripts/kks-buffers
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
# - highlight (faster than bat, change to your liking) (https://gitlab.com/saalen/highlight)

preview_cmd="highlight --line-range=1-100 -t 4 --force -O ansi -"
history_file="$HOME/.cache/kks-buffers-history"
[ -f "$history_file" ] || touch "$history_file"

kks get %val[buflist] |
grep -F "$*" |
fzf --height 100% --prompt 'buf> ' --preview "kks cat -b {} | $preview_cmd" \
--header="[c-x] delete, [c-t] new scratch" \
--bind="ctrl-x:execute-silent(kks send -b {} delete-buffer)+reload(kks get %val[buflist])" \
--bind="ctrl-t:execute-silent(kks send edit -scratch {q})+reload(kks get %val[buflist])" |
--bind="ctrl-t:execute-silent(kks send edit -scratch {q})+reload(kks get %val[buflist])" \
--history="$history_file" |
while read -r name; do
kks send buffer "$name"
done
5 changes: 4 additions & 1 deletion scripts/kks-files
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
# - highlight (faster than bat, change to your liking) (https://gitlab.com/saalen/highlight)

preview_cmd="highlight --line-range=1-100 -t 4 --force -O ansi"
history_file="$HOME/.cache/kks-files-history"
[ -f "$history_file" ] || touch "$history_file"

fd --type file . "$@" |
fzf --multi --height 100% --prompt 'files> ' --preview "$preview_cmd {}" |
fzf --multi --height 100% --prompt 'files> ' \
--preview "$preview_cmd {}" --history="$history_file" |
while read -r file; do
kks edit "$file"
done
5 changes: 4 additions & 1 deletion scripts/kks-grep
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
# - ripgrep (https://github.com/BurntSushi/ripgrep)
# - fzf (https://github.com/junegunn/fzf)

history_file="$HOME/.cache/kks-grep-history"
[ -f "$history_file" ] || touch "$history_file"

rg --vimgrep '.+' "$@" |
fzf --height 100% --prompt 'grep> ' |
fzf --height 100% --prompt 'grep> ' --history="$history_file" |
awk -F':' '{print $1 " " "+" $2 ":" $3 }' |
xargs -r kks edit

0 comments on commit 806d4fe

Please sign in to comment.