public
Created

uses dmenu to go directly to a ssh host, spawn a command without a shell or open a shell directly in a working directory of another.

  • Download Gist
terMenu.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/bin/sh
 
term=urxvtc
 
CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
(
IFS=:
if test "`ls -dt $PATH "$CACHE" 2> /dev/null | sed 1q`" != "$CACHE"; then
mkdir -p "`dirname "$CACHE"`" && lsx $PATH | sort -u > "$CACHE"
fi
)
 
choice=`awk -F'"' '/"\)/{print $2}' ~/bin/terMenu.sh | dmenu -p 'start:'`
case $choice in
"open")
cd $(for f in $(pidof zsh)
do echo $(ls -l /proc/$f/cwd | cut -d'>' -f2)
done | sort -u | dmenu -p 'open:') && exec $term
;;
 
"ssh")
host=`awk '/^Host/{print $2}' ~/.ssh/config | dmenu -p 'ssh:'` && exec $term -e ssh $host
;;
 
"hist")
;;
 
"root")
exec $term -e su -
;;
 
"window")
cmd=`dmenu -p 'Window:' < "$CACHE"` && exec $cmd
;;
 
"term")
cmd=`dmenu -p 'Term:' < "$CACHE"` && exec $term -e $cmd
;;
 
*)
cd $choice && exec $term
;;
esac

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.