Skip to content

Commit

Permalink
cd to the right directory in the jumper
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Aug 4, 2021
1 parent 9b65ed6 commit ecfca54
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkgs/kak-open/rc/kak-open.kak
Expand Up @@ -3,20 +3,24 @@ declare-option str similar_sort_path "similar-sort"
define-command -docstring 'open files named similarly to the current buffer' open-similar %{
tmux-terminal-impl 'display-popup -E' sh -c %{
set -euo pipefail
cd $5

FILE="$(git ls-files --others --cached --exclude-standard | $1 $2 | grep -Ev "^$2\$" | fzf --tiebreak index --preview "bat --color=always -p {}")"
printf "evaluate-commands -client %s edit %s\n" "$3" "$FILE" | indiekak -p $4
} -- %opt{similar_sort_path} %val{bufname} %val{client} %val{session}
} -- %opt{similar_sort_path} %val{bufname} %val{client} %val{session} %sh{ echo $PWD }
}

define-command -docstring 'open buffers named similarly to the current buffer' open-similar-buffer %{
tmux-terminal-impl 'display-popup -E' sh -c %{
set -euo pipefail
cd $5

OPTIONS=""
for OPTION in "${@:5}"; do
OPTIONS="$(printf "%s\n%s" "$OPTIONS" "$OPTION")"
done

BUFFER="$(echo "$OPTIONS" | $1 $2 | grep -Ev "^$2\$" | grep -ve '^$' | fzf --tiebreak index --preview "bat --color=always -p {}")"
printf "evaluate-commands -client %s edit '%s'\n" "$3" "$BUFFER" | indiekak -p $4
} -- %opt{similar_sort_path} %val{bufname} %val{client} %val{session} %val{buflist}
} -- %opt{similar_sort_path} %val{bufname} %val{client} %val{session} %val{buflist} %sh{ echo $PWD }
}

0 comments on commit ecfca54

Please sign in to comment.