Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions harpoon
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ _getFZFCmd() {
return 0
fi
if type fzf-tmux >/dev/null 2>&1; then
echo "fzf-tmux -p '50%,50%'"
echo "fzf-tmux -p 50%,50%"
return 0
fi
echo "fzf"
Expand Down Expand Up @@ -138,7 +138,29 @@ switch() {
done <"$cachefile"
}

edit_file() { exec tmux popup -E "$EDITOR $cachefile"; }
# Tmux options (vim/nvim only):
# @tmux-harpoon-faithful-vim-controls bool, default true
# Remap `q` -> :q!, `:w` -> :wq, and <CR> -> jump to session on the
# current line, mirroring how harpoon's UI navigates.
# @tmux-harpoon-editor-args string, default empty
# Extra args appended to the editor command (e.g. `--clean`, `-u NONE`).
Comment on lines +141 to +146
edit_file() {
cmd="$EDITOR $cachefile"
Comment on lines +147 to +148
editor_basename="${EDITOR##*/}"
editor_basename="${editor_basename%% *}"
case "$editor_basename" in
vim | nvim)
faithful=$(tmux show-option -gqv "@tmux-harpoon-faithful-vim-controls" 2>/dev/null)
[ -z "$faithful" ] && faithful="true"
if [ "$faithful" = "true" ]; then
cmd="$cmd -c \"nnoremap q :q!<CR>\" -c \"cnoreabbrev w wq\" -c \"nnoremap <silent> <CR> :execute '!$0 -s ' . line('.') <bar> q!<CR>\""
Comment on lines +153 to +156
fi
vim_args=$(tmux show-option -gqv "@tmux-harpoon-editor-args" 2>/dev/null)
[ -n "$vim_args" ] && cmd="$cmd $vim_args"
;;
esac
exec tmux popup -E "$cmd"
}

sessions_has_match() { list_sessions | grep -wq "^$1"; }

Expand Down