add preselection of last selected item #1
This commit is contained in:
parent
a3c476ca20
commit
d975e38ef3
22
s3h.sh
22
s3h.sh
@ -24,6 +24,19 @@ if [[ ! -d "$START_DIR" ]]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
LAST="$START_DIR/.last"
|
||||
|
||||
# check if there was a last call, if so fake while loop variable
|
||||
preselect=''
|
||||
if [[ -f "$LAST" ]]; then
|
||||
last=`cat "$LAST"`
|
||||
# check if config file still exists
|
||||
if [[ -f "$last" ]]; then
|
||||
dir=`dirname "$last"`
|
||||
preselect=`basename "$last"`
|
||||
fi
|
||||
fi
|
||||
|
||||
# select config file
|
||||
configFile=''
|
||||
while [[ -z "$configFile" ]]; do
|
||||
@ -65,7 +78,11 @@ while [[ -z "$configFile" ]]; do
|
||||
fi
|
||||
|
||||
# run dialog
|
||||
ret=$("$DIALOG" --no-tags --stdout --menu "select connection" 0 0 0 ${para[@]} 2>&1)
|
||||
dialogOptions=''
|
||||
if [[ ! -z "$preselect" ]]; then
|
||||
dialogOptions="$dialogOptions --default-item $preselect"
|
||||
fi
|
||||
ret=$("$DIALOG" --no-tags --stdout $dialogOptions --menu "select connection" 0 0 0 ${para[@]} 2>&1)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
clear
|
||||
exit 1
|
||||
@ -104,6 +121,9 @@ if [[ -f "$configFile" ]]; then
|
||||
# clear screen // remove dialog colors
|
||||
echo "config file '$configFile' selected. connecting..."
|
||||
|
||||
# save selected configFile for next call of s3h
|
||||
echo "$configFile" > "$LAST"
|
||||
|
||||
# extract user@host if ~ in config file name
|
||||
login=`basename "$configFile"`
|
||||
if [[ "$login" == *"~"* ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user