diff --git a/s3h.sh b/s3h.sh index f4c7323..2e35b87 100755 --- a/s3h.sh +++ b/s3h.sh @@ -47,7 +47,13 @@ while [[ -z "$configFile" ]]; do # add file selectors files=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type f -printf "%f\n" |sort` for d in $files; do - para+=("$d" "$d") + # text before ~ is tag + if [[ "$d" == *"~"* ]]; then + tag="${d%%~*}" + para+=("$d" "$tag") + else + para+=("$d" "$d") + fi done if [[ ${#para[@]} -eq 0 ]]; then @@ -97,7 +103,13 @@ if [[ -f "$configFile" ]]; then # clear screen // remove dialog colors 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 - echo "Running 'ssh ${para[@]} `basename \"$configFile\"`'" - ssh ${para[@]} `basename "$configFile"` + echo "Running 'ssh ${para[@]} $login'" + ssh ${para[@]} "$login" fi diff --git a/test/blah~foobar@devloop.de b/test/blah~foobar@devloop.de new file mode 100644 index 0000000..e69de29