Add a new version of bashdown
This commit is contained in:
parent
ee60bd3432
commit
00df7628e9
13
snippy
13
snippy
@ -62,11 +62,20 @@ trap 'rm -f $tmpfile' EXIT HUP INT TRAP TERM
|
|||||||
# @param string - string with bash(down) syntax (usually surrounded by ' quotes instead of ")
|
# @param string - string with bash(down) syntax (usually surrounded by ' quotes instead of ")
|
||||||
bashdown() {
|
bashdown() {
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
line="$(eval "printf -- \"$( printf "%s" "$line" | sed 's/"/\\"/g')\"")";
|
line="$(eval "printf -- \"$( printf "%s" "$line" | sed 's/"/\\"/g' )\"")";
|
||||||
echo -e "$line"
|
echo -e "$line"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Simplified version of bashdown, use echo and bash var search and replace
|
||||||
|
# Better handling of symbol char
|
||||||
|
bashdown2() {
|
||||||
|
while IFS= read -r line; do
|
||||||
|
line="$(eval "echo \"${line//\"/\\\"}\"")"
|
||||||
|
echo "$line"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Detect if focused app is a terminal or a gui
|
# Detect if focused app is a terminal or a gui
|
||||||
is_gui() {
|
is_gui() {
|
||||||
name="$(xprop -id "$(xdotool getwindowfocus)" WM_CLASS | cut -d'"' -f2 | tr '[:upper:]' '[:lower:]')"
|
name="$(xprop -id "$(xdotool getwindowfocus)" WM_CLASS | cut -d'"' -f2 | tr '[:upper:]' '[:lower:]')"
|
||||||
@ -129,7 +138,7 @@ run() {
|
|||||||
|
|
||||||
# default action
|
# default action
|
||||||
else
|
else
|
||||||
content="$( bashdown < "${snippets_directory}/${snippet}" )"
|
content="$( bashdown2 < "${snippets_directory}/${snippet}" )"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "%s" "$content" > "$tmpfile"
|
printf "%s" "$content" > "$tmpfile"
|
||||||
|
Loading…
Reference in New Issue
Block a user