diff --git a/.gitignore b/.gitignore index 93a5f70..8570652 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -rofi-forge-cache-own \ No newline at end of file +generate-hosts +rofi-config diff --git a/README.md b/README.md index bca70e8..eb4d2f1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ssh-menu ======== -SSH menu using rofi and forging cache file. By default, it will search for host files named after target hosts in `$INFRA/host/` directory. +SSH menu using rofi and forging cache file. You can: -- copy `rofi-forge-cache` as `rofi-forge-cache-own` and adapt to your needs -- copy `rofi-config` as `rofi-config-own` and adapt to your needs +- create `generate-hosts` script to forge rofi SSH cache (see generate-hosts-sample) +- copy `rofi-config-sample` as `rofi-config` and adapt to your needs - install with `./install` (will only act on `~/.ssh-menu/` directory) and run with `./ssh-menu`. Tips: diff --git a/generate-hosts-sample b/generate-hosts-sample new file mode 100755 index 0000000..0b3c919 --- /dev/null +++ b/generate-hosts-sample @@ -0,0 +1,7 @@ +#! /bin/bash + +# Clean cache +echo -n > ~/.cache/rofi-2.sshcache + +# Add only root@localhost +echo "1 root@localhost" >> ~/.cache/rofi-2.sshcache diff --git a/install b/install index 0d6268e..22b7edc 100755 --- a/install +++ b/install @@ -8,15 +8,15 @@ fi mkdir -p ~/.ssh-menu # Install rofi-config-own or default rofi-config -if [ -e rofi-config-own ]; then - cp rofi-config-own ~/.ssh-menu/rofi-config +if [ -e rofi-config ]; then + cp rofi-config ~/.ssh-menu/rofi-config else - cp rofi-config ~/.ssh-menu/rofi-config + cp rofi-config-sample ~/.ssh-menu/rofi-config fi # Install rofi-forge-cache-own script or default rofi-forge-cache -if [ -e rofi-forge-cache-own ]; then - cp rofi-forge-cache-own ~/.ssh-menu/rofi-forge-cache +if [ -e generate-hosts ]; then + cp generate-hosts ~/.ssh-menu/generate-hosts else - cp rofi-forge-cache ~/.ssh-menu/rofi-forge-cache + cp generate-hosts-sample ~/.ssh-menu/generate-hosts fi diff --git a/rofi-config b/rofi-config-sample similarity index 100% rename from rofi-config rename to rofi-config-sample diff --git a/rofi-forge-cache b/rofi-forge-cache deleted file mode 100755 index 74ceeb1..0000000 --- a/rofi-forge-cache +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - -# Clean cache -echo -n > ~/.cache/rofi-2.sshcache - -# Look for hostfiles named after target names in $INFRA/host/ -ls ${INFRA}/host/ | sed "s/^/1 root@/" >> ~/.cache/rofi-2.sshcache diff --git a/ssh-menu b/ssh-menu index 1683a3f..b8b6385 100755 --- a/ssh-menu +++ b/ssh-menu @@ -1,10 +1,10 @@ #! /bin/bash # Generate ~/.cache/rofi-2.sshcache -if [ -x ~/.ssh-menu/rofi-forge-cache ]; then - ~/.ssh-menu/rofi-forge-cache +if [ -x ~/.ssh-menu/generate-hosts ]; then + ~/.ssh-menu/generate-hosts else - echo "error: ~/.ssh-menu/rofi-forge-cache doesn't exist or can't be executed" + echo "error: ~/.ssh-menu/generate-hosts doesn't exist or can't be executed" exit 1 fi