handle {cursor} to place the cursor after gui paste
This commit is contained in:
parent
7d01e47369
commit
8c500aefe0
17
snippy
17
snippy
@ -80,19 +80,32 @@ run(){
|
|||||||
${FILE} &> $TMPFILE # execute as bashcommand
|
${FILE} &> $TMPFILE # execute as bashcommand
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local current_clip
|
local current_clip cursor
|
||||||
current_clip=$(xsel -b)
|
current_clip=$(xsel -b)
|
||||||
|
cursor=0
|
||||||
# replace {clipboard} by the cliboard comtent
|
# replace {clipboard} by the cliboard comtent
|
||||||
sed -i -e "s/{clipboard}/$current_clip/g" "$TMPFILE"
|
sed -i -e "s/{clipboard}/$current_clip/g" "$TMPFILE"
|
||||||
|
|
||||||
|
if grep -qF '{cursor}' "$TMPFILE";then
|
||||||
|
local file_lines
|
||||||
|
cursor=$(grep -n '{cursor}' "$TMPFILE" | cut -d: -f1)
|
||||||
|
file_lines=$(wc -l < "$TMPFILE")
|
||||||
|
cursor=$((file_lines - cursor))
|
||||||
|
sed -i -e "s/{cursor}//g" "$TMPFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
xsel -b --input < "$TMPFILE"
|
xsel -b --input < "$TMPFILE"
|
||||||
# Paste into the current application.
|
# Paste into the current application.
|
||||||
if is_window; then
|
if is_window; then
|
||||||
${GUIPASTE}
|
${GUIPASTE}
|
||||||
|
until [ $cursor -lt 0 ]; do
|
||||||
|
xdotool key Up
|
||||||
|
let cursor-=1
|
||||||
|
done
|
||||||
else
|
else
|
||||||
${CLIPASTE}
|
${CLIPASTE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -ne "$current_clip" | xsel -b --input
|
echo -ne "$current_clip" | xsel -b --input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user