Rework sniplet command
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
466c1cdbeb
commit
4e4775e877
1 changed files with 8 additions and 8 deletions
16
bin/sniplet
16
bin/sniplet
|
@ -15,7 +15,7 @@ trap cleanup EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find sniplet files
|
# Find sniplet files
|
||||||
names=$(find "${sniplet_dir}" -type f | sed "s|${sniplet_dir}||" | sort)
|
names=$(find "${sniplet_dir}" -type f | sed "s|${sniplet_dir}/||" | sort)
|
||||||
|
|
||||||
# Let the user select one of them
|
# Let the user select one of them
|
||||||
name=$(
|
name=$(
|
||||||
|
@ -36,15 +36,15 @@ sniplet="${sniplet_dir}/${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store clipboard away
|
# Store clipboard away
|
||||||
xsel -b -o >"${tmpdir}/b"
|
xclip -selection clipboard -o >"${tmpdir}/clipboard"
|
||||||
xsel -p -o >"${tmpdir}/p"
|
xclip -selection primary -o >"${tmpdir}/primary"
|
||||||
|
|
||||||
# Render the sniplet using korvike for templating
|
# Render the sniplet using korvike for templating
|
||||||
korvike -i "${sniplet}" -o "${tmpdir}/s"
|
korvike -i "${sniplet}" -o "${tmpdir}/sniplet"
|
||||||
|
|
||||||
# Set clipboard with sniplet
|
# Set clipboard with sniplet
|
||||||
xsel -b -i <"${tmpdir}/s"
|
xclip -selection clipboard -i <"${tmpdir}/sniplet"
|
||||||
xsel -p -i <"${tmpdir}/s"
|
xclip -selection primary -i <"${tmpdir}/sniplet"
|
||||||
|
|
||||||
# Do the paste magic
|
# Do the paste magic
|
||||||
sleep 0.3
|
sleep 0.3
|
||||||
|
@ -52,5 +52,5 @@ xdotool key shift+Insert
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
|
|
||||||
# Restore clipboard
|
# Restore clipboard
|
||||||
xsel -b -i <"${tmpdir}/b"
|
xclip -selection clipboard -i <"${tmpdir}/clipboard"
|
||||||
xsel -p -i <"${tmpdir}/p"
|
xclip -selection primary -i <"${tmpdir}/primary"
|
||||||
|
|
Loading…
Reference in a new issue