Skip to content

Commit

Permalink
Add possibility to paste directory
Browse files Browse the repository at this point in the history
See pull request #41
  • Loading branch information
urbainvaes committed Dec 28, 2020
1 parent 96d34c6 commit b0ff00d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fzf-marks.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [[ -z "${FZF_MARKS_COMMAND}" ]] ; then
MINIMUM_VERSION=16001

if [[ $FZF_VERSION -gt $MINIMUM_VERSION ]]; then
FZF_MARKS_COMMAND="fzf --height 40% --reverse --header='ctrl-y:jump, ctrl-t:toggle, ctrl-d:delete'"
FZF_MARKS_COMMAND="fzf --height 40% --reverse --header='ctrl-y:jump, ctrl-t:toggle, ctrl-d:delete, ctrl-k:paste'"
elif [[ ${FZF_TMUX:-1} -eq 1 ]]; then
FZF_MARKS_COMMAND="fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}"
else
Expand Down Expand Up @@ -96,7 +96,7 @@ function fzm {
local lines key
lines=$(_color_marks < "${FZF_MARKS_FILE}" | eval ${FZF_MARKS_COMMAND} \
--ansi \
--expect="${FZF_MARKS_DELETE:-ctrl-d}" \
--expect="${FZF_MARKS_DELETE:-ctrl-d},${FZM_MARKS_PASTE:-ctrl-k}" \
--multi \
--bind=ctrl-y:accept,ctrl-t:toggle \
--query="\"$*\"" \
Expand All @@ -111,6 +111,10 @@ function fzm {

if [[ $key == "${FZF_MARKS_DELETE:-ctrl-d}" ]]; then
dmark "-->-->-->" "$(sed 1d <<< "$lines")"
elif [[ $key == "${FZF_MARKS_PASTE:-ctrl-k}" ]]; then
directory=$(tail -1 <<< "$lines" | sed 's/.*: \(.*\)$/\1/' | sed "s#^~#${HOME}#")
LBUFFER="${LBUFFER}$directory"
zle reset-prompt > /dev/null 2>&1 || echo $directory
else
jump "-->-->-->" "$(tail -1 <<< "${lines}")"
fi
Expand Down Expand Up @@ -157,7 +161,6 @@ function dmark {
zle && zle reset-prompt
}

zle -N jump
zle -N dmark
zle -N fzm

Expand Down

0 comments on commit b0ff00d

Please sign in to comment.