From b6efa6ffd71c1d75f2ae38d2a2c99322695ea6b4 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Tue, 2 Jun 2015 12:07:25 +0200 Subject: [PATCH] New feature in cmenu: List hosts from .ssh/config and start ssh session --- scripts/cmenu.sh | 12 ++++++++++-- scripts/ssh_hosts.sh | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 scripts/ssh_hosts.sh diff --git a/scripts/cmenu.sh b/scripts/cmenu.sh index 89d2a2f..97938a4 100755 --- a/scripts/cmenu.sh +++ b/scripts/cmenu.sh @@ -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) diff --git a/scripts/ssh_hosts.sh b/scripts/ssh_hosts.sh new file mode 100755 index 0000000..e95e219 --- /dev/null +++ b/scripts/ssh_hosts.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +CONFIG="$HOME/.ssh/config" + +if [ -f "$CONFIG" ]; then + cat "$CONFIG" | awk '{if($1=="Host"){print $2}}' +fi