instant tunnel for ssh-tunnelier. bugfix in ansicodes
This commit is contained in:
@@ -11,6 +11,7 @@ if [[ "$OSTYPE" = "darwin"* ]]; then
|
||||
BASE="base64"
|
||||
UNBASE="base64 -D"
|
||||
fi
|
||||
LOCALHOSTSYMBOL="💻"
|
||||
|
||||
function _helpexit() {
|
||||
echo "SSH tunnel manager
|
||||
@@ -93,7 +94,7 @@ function read_config() {
|
||||
printf "%-3d %-7s %s\n" $i "$pid" "$line"
|
||||
ids+=( $id )
|
||||
i=$(( i + 1 ))
|
||||
done < <( grep -v ^# "$CONF" | grep '[a-zA-Z]' )
|
||||
done < <( grep -v ^# "$CONF" | grep '[a-zA-Z]' ) | sed 's,:localhost:,:'$LOCALHOSTSYMBOL':,g'
|
||||
}
|
||||
|
||||
function run_args() {
|
||||
@@ -119,6 +120,21 @@ function ask_to_kill() {
|
||||
[[ "$input2" = "t" ]] && kill -9 $1
|
||||
}
|
||||
|
||||
function instant_entry() {
|
||||
printf "${colMenu}Start a local forward tunnel${colZ}\n"
|
||||
printf "${colMenu}Host name?${colZ}\n"
|
||||
read -e HOST
|
||||
test -z "$HOST" && return
|
||||
printf "${colMenu}Target port at host?${colZ}\n"
|
||||
read -e REMOTE
|
||||
test -z "$REMOTE" && return
|
||||
printf "${colMenu}Local port where tunnel starts?${colZ}\n"
|
||||
read -e -i "$REMOTE" LOCAL
|
||||
test -z "$LOCAL" && return
|
||||
printf "${colRow}-L ${LOCAL}:localhost:${REMOTE} ${HOST}${colZ}\n"
|
||||
run_args "$HOST" "$LOCAL" "$REMOTE"
|
||||
printf "${colMenu}See the connection in 'list ssh'${colZ}\n"
|
||||
}
|
||||
|
||||
[[ -n "$2" ]] && {
|
||||
run_args "$@"
|
||||
@@ -128,8 +144,8 @@ while true; do
|
||||
ids=()
|
||||
i=1
|
||||
printf "\n${colTitle}=============================================\n"
|
||||
printf "${colTitle} List of tunnels:${colZ}\n"
|
||||
printf "${colTitle} (q)uit (e)dit (l)ist ssh [%s]${colZ}\n" $( date +%H:%M )
|
||||
printf "${colTitle} List of tunnels: (${LOCALHOSTSYMBOL}=localhost) [%s]${colZ}\n" $( date +%H:%M )
|
||||
printf "${colTitle} (q)uit (e)dit (l)ist ssh (i)nstant tunnel${colZ}\n"
|
||||
printf "${colTitle}=============================================\n"
|
||||
printf "${colRow}ID PID command\n"
|
||||
read_config
|
||||
@@ -137,6 +153,7 @@ while true; do
|
||||
read -t 600 input
|
||||
|
||||
[[ "$input" = "q" ]] && exit 0
|
||||
[[ "$input" = "i" ]] && instant_entry
|
||||
[[ "$input" = "e" ]] && vim "$CONF"
|
||||
[[ "$input" = "l" ]] && list_all_ssh
|
||||
[[ "$input" = "0" ]] && continue
|
||||
|
||||
Reference in New Issue
Block a user