Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added possibilty to paste a directory #41

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
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
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