Last active
June 5, 2025 11:23
-
-
Save coderofsalvation/46549e3788ade2f3a938 to your computer and use it in GitHub Desktop.
Revisions
-
coderofsalvation revised this gist
Mar 23, 2015 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,6 +33,7 @@ DMENU_ARGS="-b" TMPFILE="/tmp/.snippy.tmp"; :>$TMPFILE # if nothing happens, try "xdotool click 2", "xdotool key ctrl+v" or "xdotool key ctrl+shift+v" GUIPASTE="xdotool click 2" CLIPASTE="xdotool key ctrl+v" # smarty like template engine which executes inline bash in (bashdown) strings (replaces variables with values e.g.) # @link http://github.com/coderofsalvation/bashdown @@ -78,15 +79,14 @@ run(){ fi xsel --input < $TMPFILE # Paste into the current application. [[ is_window ]] && ${GUIPASTE} || ${CLIPASTE} # cli or gui paste } is_window(){ name="$(xdotool getwindowname $(xdotool getwindowfocus) | tr '[:upper:]' '[:lower:]')" [[ ! "$name" =~ term|tilda ]] && return 1 return 0 } init && run -
coderofsalvation revised this gist
Mar 5, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -71,7 +71,8 @@ run(){ FILE=`find -L . -type f | grep -v '^\.$' | sed 's!\.\/!!' | /usr/bin/dmenu ${DMENU_ARGS}` if [ -f ${DIR}/${FILE} ]; then # Put the contents of the selected file into the paste buffer. content="$(cat ${DIR}/${FILE} | bashdown)" [[ "${#content}" == 0 ]] && printf "${FILE}" > $TMPFILE || printf "%s" "$content" > $TMPFILE else ${FILE} &> $TMPFILE # execute as bashcommand fi @@ -88,3 +89,4 @@ paste_cli(){ } init && run -
coderofsalvation revised this gist
Dec 16, 2014 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,6 +31,8 @@ DIR=${HOME}/.snippy APPS="xdotool xsel dmenu" DMENU_ARGS="-b" TMPFILE="/tmp/.snippy.tmp"; :>$TMPFILE # if nothing happens, try "xdotool click 2", "xdotool key ctrl+v" or "xdotool key ctrl+shift+v" GUIPASTE="xdotool click 2" # smarty like template engine which executes inline bash in (bashdown) strings (replaces variables with values e.g.) # @link http://github.com/coderofsalvation/bashdown @@ -75,14 +77,14 @@ run(){ fi xsel --input < $TMPFILE # Paste into the current application. paste_cli || ${GUIPASTE} # cli or gui paste } paste_cli(){ name="$(xdotool getwindowname $(xdotool getwindowfocus) | tr '[:upper:]' '[:lower:]')" [[ ! "$name" =~ term|tilda ]] && return 1 ${GUIPASTE} } init && run -
coderofsalvation revised this gist
Dec 9, 2014 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,6 @@ DIR=${HOME}/.snippy APPS="xdotool xsel dmenu" DMENU_ARGS="-b" TMPFILE="/tmp/.snippy.tmp"; :>$TMPFILE # smarty like template engine which executes inline bash in (bashdown) strings (replaces variables with values e.g.) # @link http://github.com/coderofsalvation/bashdown @@ -74,15 +73,16 @@ run(){ else ${FILE} &> $TMPFILE # execute as bashcommand fi xsel --input < $TMPFILE # Paste into the current application. paste_cli || xdotool key ctrl+v # cli or gui paste } paste_cli(){ name="$(xdotool getwindowname $(xdotool getwindowfocus) | tr '[:upper:]' '[:lower:]')" [[ ! "$name" =~ term|tilda ]] && return 1 [[ "$name" =~ xterm$ ]] && xdotool click 2 || xdotool key ctrl+shift+v } init && run -
coderofsalvation revised this gist
Dec 2, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,7 +67,7 @@ run(){ cd ${DIR} # Use the filenames in the snippy directory as menu entries. # Get the menu selection from the user. FILE=`find -L . -type f | grep -v '^\.$' | sed 's!\.\/!!' | /usr/bin/dmenu ${DMENU_ARGS}` if [ -f ${DIR}/${FILE} ]; then # Put the contents of the selected file into the paste buffer. cat ${DIR}/${FILE} | bashdown > $TMPFILE -
coderofsalvation revised this gist
Nov 14, 2014 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ DIR=${HOME}/.snippy APPS="xdotool xsel dmenu" DMENU_ARGS="-b" TMPFILE="/tmp/.snippy.tmp"; :>$TMPFILE XSEL_ARGS="--clipboard --input" # smarty like template engine which executes inline bash in (bashdown) strings (replaces variables with values e.g.) @@ -71,10 +71,12 @@ run(){ if [ -f ${DIR}/${FILE} ]; then # Put the contents of the selected file into the paste buffer. cat ${DIR}/${FILE} | bashdown > $TMPFILE else ${FILE} &> $TMPFILE # execute as bashcommand fi xsel ${XSEL_ARGS} < $TMPFILE # Paste into the current application. is_terminal && xdotool key ctrl+shift+v || xdotool key ctrl+v # cli or gui paste } is_terminal(){ -
coderofsalvation revised this gist
Nov 10, 2014 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -73,9 +73,14 @@ run(){ cat ${DIR}/${FILE} | bashdown > $TMPFILE xsel ${XSEL_ARGS} < $TMPFILE # Paste into the current application. is_terminal && xdotool key ctrl+shift+v || xdotool key ctrl+v # cli or gui paste fi } is_terminal(){ name="$(xdotool getwindowname $(xdotool getwindowfocus) | tr '[:upper:]' '[:lower:]')" [[ "$name" =~ term|tilda ]] && return 0 || return 1 } init && run -
coderofsalvation revised this gist
Nov 1, 2014 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,9 +40,11 @@ XSEL_ARGS="--clipboard --input" # fetches a document and interprets bashsyntax in string (bashdown) templates # @param string - string with bash(down) syntax (usually surrounded by ' quotes instead of ") bashdown(){ txt="$(cat - )"; lines="$(cat ${DIR}/${FILE} | wc -l )" (( lines > 1 )) && enter="\n" || enter="" IFS=''; echo "$txt" | while read line; do [[ "$line" =~ '$' ]] && line="$(eval "printf \"$( printf "%s" "$line" | sed 's/"/\\"/g')\"")"; printf "$line""$enter" done } -
coderofsalvation revised this gist
Oct 30, 2014 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,12 +5,13 @@ # Based on "snippy" by "sessy" # (https://bbs.archlinux.org/viewtopic.php?id=71938) # # You will also need "dmenu", "xsel" and "xdotool". Get them from your linux # distro in the usual way. # # To use: # 1. Create the directory ~/.snippy # # 2. Create a file in that directory for each snippet that you want. # The filename will be used as a menu item, so you might want to # omit the file extension when you name the file. # @@ -24,7 +25,7 @@ # 3. Bind a convenient key combination to this script. # # TIP: If you're using XMonad, add something like this to xmonad.hs # ((mod4Mask, xK_s), spawn "/path/to/snippy") # DIR=${HOME}/.snippy APPS="xdotool xsel dmenu" @@ -40,8 +41,8 @@ XSEL_ARGS="--clipboard --input" # @param string - string with bash(down) syntax (usually surrounded by ' quotes instead of ") bashdown(){ IFS=''; cat - | while read line; do [[ "$line" =~ '$' ]] && line="$(eval "printf \"$( printf "%s" "$line" | sed 's/"/\\"/g')\"")"; printf "$line" done } @@ -75,3 +76,4 @@ run(){ } init && run -
coderofsalvation revised this gist
Oct 30, 2014 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,13 +5,12 @@ # Based on "snippy" by "sessy" # (https://bbs.archlinux.org/viewtopic.php?id=71938) # # You will also need "dmenu", "xsel" and "xdotool", it will be installed # automatically when using debianbased distros (ubuntu). # # To use: # 1. run snippy # 2. Create a file in ~/.snippy for each snippet that you want. # The filename will be used as a menu item, so you might want to # omit the file extension when you name the file. # @@ -25,7 +24,7 @@ # 3. Bind a convenient key combination to this script. # # TIP: If you're using XMonad, add something like this to xmonad.hs # ((mod4Mask, xK_s), spawn "/path/to/snippy"). In XFCE its Settings->Keyboard->Shortcuts # DIR=${HOME}/.snippy APPS="xdotool xsel dmenu" -
coderofsalvation created this gist
Oct 30, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ #!/bin/bash # video demo at: http://www.youtube.com/watch?v=90xoathBYfk # written by "mhwombat": https://bbs.archlinux.org/viewtopic.php?id=71938&p=2 # Based on "snippy" by "sessy" # (https://bbs.archlinux.org/viewtopic.php?id=71938) # # You will also need "dmenu", "xsel" and "xdotool". Get them from your linux # distro in the usual way. # # To use: # 1. Create the directory ~/.snippy # # 2. Create a file in that directory for each snippet that you want. # The filename will be used as a menu item, so you might want to # omit the file extension when you name the file. # # TIP: If you have a lot of snippets, you can organise them into # subdirectories under ~/.snippy. # # TIP: The contents of the file will be pasted asis, so if you # don't want a newline at the end when the text is pasted, don't # put one in the file. # # 3. Bind a convenient key combination to this script. # # TIP: If you're using XMonad, add something like this to xmonad.hs # ((mod4Mask, xK_s), spawn "/path/to/snippy") # DIR=${HOME}/.snippy APPS="xdotool xsel dmenu" DMENU_ARGS="-b" TMPFILE="/tmp/.snippy.tmp" XSEL_ARGS="--clipboard --input" # smarty like template engine which executes inline bash in (bashdown) strings (replaces variables with values e.g.) # @link http://github.com/coderofsalvation/bashdown # @dependancies: sed cat # @example: echo 'hi $NAME it is $(date)' | bashdown # fetches a document and interprets bashsyntax in string (bashdown) templates # @param string - string with bash(down) syntax (usually surrounded by ' quotes instead of ") bashdown(){ IFS=''; cat - | while read line; do [[ "$line" =~ '$' ]] && line="$(eval "echo \"$( echo "$line" | sed 's/"/\\"/g')\"")"; echo "$line" done } init(){ for APP in $APPS; do which $APP &>/dev/null || { read -p "install the following required utils? : $APPS (y/n)" reply [[ "$reply" == "y" ]] && sudo apt-get install ${APPS}; } done [[ ! -d "$DIR" ]] && { echo -e "created $DIR\n"; mkdir "$DIR"; printf 'hi it is $(date)' > "$DIR""/test"; } return 0 } run(){ cd ${DIR} # Use the filenames in the snippy directory as menu entries. # Get the menu selection from the user. FILE=`find . -type f | grep -v '^\.$' | sed 's!\.\/!!' | /usr/bin/dmenu ${DMENU_ARGS}` if [ -f ${DIR}/${FILE} ]; then # Put the contents of the selected file into the paste buffer. cat ${DIR}/${FILE} | bashdown > $TMPFILE xsel ${XSEL_ARGS} < $TMPFILE # Paste into the current application. [[ -t 0 ]] && xdotool key ctrl+shift+v || xdotool key ctrl+v # cli or gui paste fi } init && run