New feature in cmenu: List hosts from .ssh/config and start ssh session

This commit is contained in:
madmaurice 2015-06-02 12:07:25 +02:00
parent c8ffc1dea7
commit b6efa6ffd7
2 changed files with 17 additions and 2 deletions

View file

@ -1,6 +1,8 @@
#!/bin/bash
DMENU="$(dirname $0)/dmenu.sh"
cd $(dirname $0)
DMENU="./dmenu.sh"
menu() {
echo $@ | tr ' ' '\n' | $DMENU
}
@ -21,7 +23,7 @@ require-service() {
systemctl is-active --quiet $service || sysctl start $service
}
case "$(menu timer screenshot wallpaper wicd ncmpcpp zomnet power)" in
case "$(menu timer screenshot wallpaper wicd ncmpcpp ssh zomnet power)" in
timer)
exec urxvt -geometry 50x3 -e ~/.config/scripts/teatimer.sh
;;
@ -44,6 +46,12 @@ case "$(menu timer screenshot wallpaper wicd ncmpcpp zomnet power)" in
ncmpcpp)
exec urxvt -e ncmpcpp
;;
ssh)
host=$(menu `./ssh_hosts.sh`)
if [ -n "$host" ]; then
exec urxvt -e ssh $host
fi
;;
zomnet)
case "$(menu start-stop uservm ncmpcpp deluge)" in
start-stop)

7
scripts/ssh_hosts.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
CONFIG="$HOME/.ssh/config"
if [ -f "$CONFIG" ]; then
cat "$CONFIG" | awk '{if($1=="Host"){print $2}}'
fi