diff --git a/texpander.sh b/texpander.sh index 5e7e9ca..0f5bb5b 100755 --- a/texpander.sh +++ b/texpander.sh @@ -14,18 +14,18 @@ if [ ! -d ${HOME}/.texpander ]; then mkdir ${HOME}/.texpander fi -# Store base directory path, expand complete path using HOME environemtn variable +# Store base directory path, expand complete path using HOME environment variable base_dir=$(realpath "${HOME}/.texpander") # Set globstar shell option (turn on) ** for filename matching glob patterns on subdirectories of ~/.texpander shopt -s globstar # Find regular files in base_dir, pipe output to sed -abbrvs=$(find "${base_dir}" -type f | sort | sed "s?^${base_dir}/??g") +abbrvs=$(find "${base_dir}" -type f \( ! -iname ".*" \) | sort | sed "s?^${base_dir}/??g") # 'Echo'ing the options instead of passing them directly # to zenity allows names like '+1' or '-1' -name=$(echo ${abbrvs} | tr ' ' '\n' | zenity --list --title=Texpander --width=275 --height=400 --column=Abbreviations) +name=$(echo "$abbrvs" | zenity --list --title="Texpander" --width=275 --height=400 --column="Abbreviations" --mid-search) path="${base_dir}/${name}" @@ -36,12 +36,20 @@ then # Preserve the current value of the clipboard clipboard=$(xsel -b -o) - # Put text in primary buffer for Shift+Insert pasting - echo -n "$(cat "$path")" | xsel -p -i - - # Put text in clipboard selection for apps like Firefox that - # insist on using the clipboard for all pasting - echo -n "$(cat "$path")" | xsel -b -i + if [ "${path: -4}" == ".cmd" ] + then + # Put text in primary buffer for Shift+Insert pasting + echo -n $($(cat "$path")) | xsel -p -i + # Put text in clipboard selection for apps like Firefox that + # insist on using the clipboard for all pasting + echo -n $($(cat "$path")) | xsel -b -i + else + # Put text in primary buffer for Shift+Insert pasting + echo -n "$(cat "$path")" | xsel -p -i + # Put text in clipboard selection for apps like Firefox that + # insist on using the clipboard for all pasting + echo -n "$(cat "$path")" | xsel -b -i + fi # Paste text into current active window sleep 0.3