ssh-menu initial release
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
rofi-forge-cache-own
|
||||
13
README.md
Normal file
13
README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
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.
|
||||
|
||||
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
|
||||
- install with `./install` (will only act on `~/.ssh-menu/` directory) and run with `./ssh-menu`.
|
||||
|
||||
Tips:
|
||||
- you can add ssh options by setting SSH_OPTIONS variable (for example `SSH_OPTIONS=-A ./ssh-menu` will forward SSH agent)
|
||||
- SSH agent is not loaded by default, I use `keychain` variables set in `~/.keychain/$(hostname)-sh`, adapt to your agent handling method
|
||||
22
install
Executable file
22
install
Executable file
@@ -0,0 +1,22 @@
|
||||
#! /bin/bash
|
||||
|
||||
if [ ! -e /usr/bin/rofi ]; then
|
||||
echo "error: rofi doesn't seem to be installed"
|
||||
exit 1
|
||||
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
|
||||
else
|
||||
cp rofi-config ~/.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
|
||||
else
|
||||
cp rofi-forge-cache ~/.ssh-menu/rofi-forge-cache
|
||||
fi
|
||||
8
rofi-config
Normal file
8
rofi-config
Normal file
@@ -0,0 +1,8 @@
|
||||
configuration {
|
||||
font: "DejaVu Sans Mono 10";
|
||||
terminal: "kitty";
|
||||
ssh-client: "ssh ${SSH_OPTIONS}";
|
||||
ssh-command: "{terminal} -e sh -c \". ~/.keychain/$(hostname)-sh && {ssh-client} {host}\"";
|
||||
sidebar-mode: true;
|
||||
}
|
||||
@theme "sidebar"
|
||||
7
rofi-forge-cache
Executable file
7
rofi-forge-cache
Executable file
@@ -0,0 +1,7 @@
|
||||
#! /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
|
||||
12
ssh-menu
Executable file
12
ssh-menu
Executable file
@@ -0,0 +1,12 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Generate ~/.cache/rofi-2.sshcache
|
||||
if [ -x ~/.ssh-menu/rofi-forge-cache ]; then
|
||||
~/.ssh-menu/rofi-forge-cache
|
||||
else
|
||||
echo "error: ~/.ssh-menu/rofi-forge-cache doesn't exist or can't be executed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Launch rofi
|
||||
rofi -lines 50 -modi ssh -show ssh -config ~/.ssh-menu/rofi-config
|
||||
Reference in New Issue
Block a user