Skip to content

Commit

Permalink
Merge pull request #41 from 3ximus/master
Browse files Browse the repository at this point in the history
added possibilty to paste a directory
  • Loading branch information
urbainvaes authored Dec 28, 2020
2 parents 5400c3a + 6e487c4 commit 4000f29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions fzf-marks.plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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 @@ -92,7 +92,7 @@ function _color_marks {
function fzm {
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 @@ -106,6 +106,8 @@ function fzm {

if [[ $key == "${FZF_MARKS_DELETE:-ctrl-d}" ]]; then
dmark "-->-->-->" "$(sed 1d <<< "$lines")"
elif [[ $key == "${FZF_MARKS_PASTE:-ctrl-k}" ]]; then
pmark "$(tail -1 <<< "$lines")"
else
jump "-->-->-->" "$(tail -1 <<< "${lines}")"
fi
Expand All @@ -129,6 +131,10 @@ function jump {
fi
}

function pmark {
echo $(echo "${1}" | sed 's/.*: \(.*\)$/\1/' | sed "s#^~#${HOME}#")
}

function dmark {
local marks_to_delete line bookmarks
if [[ $1 == "-->-->-->" ]]; then
Expand Down
11 changes: 9 additions & 2 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,8 @@ function fzm {

if [[ $key == "${FZF_MARKS_DELETE:-ctrl-d}" ]]; then
dmark "-->-->-->" "$(sed 1d <<< "$lines")"
elif [[ $key == "${FZF_MARKS_PASTE:-ctrl-k}" ]]; then
pmark "$(tail -1 <<< "$lines")"
else
jump "-->-->-->" "$(tail -1 <<< "${lines}")"
fi
Expand All @@ -135,6 +137,10 @@ function jump {
zle && zle redraw-prompt
}

function pmark {
echo $(echo "${1}" | sed 's/.*: \(.*\)$/\1/' | sed "s#^~#${HOME}#")
}

function dmark {
local marks_to_delete line bookmarks
if [[ $1 == "-->-->-->" ]]; then
Expand All @@ -158,6 +164,7 @@ function dmark {
}

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

Expand Down

0 comments on commit 4000f29

Please sign in to comment.