Skip to content

Instantly share code, notes, and snippets.

@cryptix
Created November 14, 2012 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cryptix/4072755 to your computer and use it in GitHub Desktop.
Save cryptix/4072755 to your computer and use it in GitHub Desktop.
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.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment