Compare commits

...

4 Commits

Author SHA1 Message Date
a3c476ca20 clear screen on cancel 2024-04-28 21:42:52 +02:00
db7f539bd1 version bump 2023-12-17 20:58:13 +01:00
0c1c0d4788 set custom text by using ~ (tilde) in filename
foo~bar@example.org will show "foo" in s3h and connect to
"bar@example.org"
2023-12-17 20:56:55 +01:00
53212b705a ~/.s3h might be a symlink 2023-10-09 19:46:27 +02:00
2 changed files with 20 additions and 5 deletions

23
s3h.sh
View File

@ -2,8 +2,8 @@
# config # config
DIALOG=dialog #gdialog kdialog DIALOG=dialog #gdialog kdialog
START_DIR='~/.s3h' START_DIR="$HOME/.s3h"
VERSION="1.4" VERSION="1.5"
# TODO: use opt parsing # TODO: use opt parsing
if [[ $# -eq 1 && "$1" == "-v" ]]; then if [[ $# -eq 1 && "$1" == "-v" ]]; then
@ -15,6 +15,8 @@ if [[ $# -eq 1 && -d "$1" ]]; then
START_DIR="$1" START_DIR="$1"
fi fi
START_DIR=`realpath "$START_DIR"`
if [[ ! -d "$START_DIR" ]]; then if [[ ! -d "$START_DIR" ]]; then
echo "start directory '$START_DIR' does not exist" >&2 echo "start directory '$START_DIR' does not exist" >&2
echo -e "either create or set 'start directory' parameter\n" >&2 echo -e "either create or set 'start directory' parameter\n" >&2
@ -45,7 +47,13 @@ while [[ -z "$configFile" ]]; do
# add file selectors # add file selectors
files=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type f -printf "%f\n" |sort` files=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type f -printf "%f\n" |sort`
for d in $files; do for d in $files; do
# text before ~ is tag
if [[ "$d" == *"~"* ]]; then
tag="${d%%~*}"
para+=("$d" "$tag")
else
para+=("$d" "$d") para+=("$d" "$d")
fi
done done
if [[ ${#para[@]} -eq 0 ]]; then if [[ ${#para[@]} -eq 0 ]]; then
@ -59,6 +67,7 @@ while [[ -z "$configFile" ]]; do
# run dialog # run dialog
ret=$("$DIALOG" --no-tags --stdout --menu "select connection" 0 0 0 ${para[@]} 2>&1) ret=$("$DIALOG" --no-tags --stdout --menu "select connection" 0 0 0 ${para[@]} 2>&1)
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
clear
exit 1 exit 1
fi fi
@ -95,7 +104,13 @@ if [[ -f "$configFile" ]]; then
# clear screen // remove dialog colors # clear screen // remove dialog colors
echo "config file '$configFile' selected. connecting..." echo "config file '$configFile' selected. connecting..."
# extract user@host if ~ in config file name
login=`basename "$configFile"`
if [[ "$login" == *"~"* ]]; then
login="${login#*~}"
fi
# execute ssh # execute ssh
echo "Running 'ssh ${para[@]} `basename \"$configFile\"`'" echo "Running 'ssh ${para[@]} $login'"
ssh ${para[@]} `basename "$configFile"` ssh ${para[@]} "$login"
fi fi

View File