From f375704067f16a6e287ef8bdc0c2f29bbb5a726a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Fri, 24 Mar 2023 13:26:23 +0900 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E4=BA=86=E3=81=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - README.md | 2 +- colors.txt | 12 ++++++++++++ servers.example.txt => servers.txt | 0 sshpick | 29 +++++++++-------------------- 5 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 .gitignore create mode 100644 colors.txt rename servers.example.txt => servers.txt (100%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ef397ee..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -servers.txt diff --git a/README.md b/README.md index 7e04eac..0116192 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Used to be サーバーを選択するのは easy ```sh mkdir -p ~/.config/sshpick ~/.local/bin -cp servers.example.txt ~/.config/servers.txt +cp *.txt ~/.config/sshpick cp sshpick ~/.local/bin && chmod +x ~/.local/bin/sshpick echo "export PATH=$PATH:~/.local/bin" >> ~/.xprofile && source ~/.xprofile ``` diff --git a/colors.txt b/colors.txt new file mode 100644 index 0000000..4573213 --- /dev/null +++ b/colors.txt @@ -0,0 +1,12 @@ +root=,magenta +window=,black +shadow=,magenta +border=magenta,black +title=magenta,black +textbox=magenta,black +listbox=magenta,black +actlistbox=gray,brightmagenta +actsellistbox=black,magenta +label=magenta,black +compactbutton=magenta,black +button=black,magenta diff --git a/servers.example.txt b/servers.txt similarity index 100% rename from servers.example.txt rename to servers.txt diff --git a/sshpick b/sshpick index ab1259d..64898ef 100755 --- a/sshpick +++ b/sshpick @@ -1,33 +1,22 @@ #!/bin/sh -SRVCNT=$(cat ~/.config/servers.txt | wc -l) -SERVERS=$(cat ~/.config/servers.txt) +SERVERS=$(cat ~/.config/sshpick/servers.txt) +SRVCNT=$($SERVERS | wc -l) +TMPFILE=/tmp/contosrv.tmp.$$ -export NEWT_COLORS=" -root=,magenta -window=,black -shadow=,magenta -border=magenta,black -title=magenta,black -textbox=magenta,black -listbox=magenta,black -actlistbox=gray,brightmagenta -actsellistbox=black,magenta -label=magenta,black -compactbutton=magenta,black -button=black,magenta" +export NEWT_COLORS=$(cat ~/.config/sshpick/colors.txt) -whiptail --menu "サーバーを選んで下さい" $(($SRVCNT+10)) 50 $SRVCNT $SERVERS 2> /tmp/contosrv.tmp.$$ -RVAL=$(cat /tmp/contosrv.tmp.$$) +whiptail --menu "サーバーを選んで下さい" $(($SRVCNT+10)) 50 $SRVCNT $SERVERS 2> $TMPFILE +RVAL=$(cat $TMPFILE) if [ "$RVAL" = "" ]; then - rm -f /tmp/contosrv.tmp.$$ + rm -f $TMPFILE clear echo "キャンセル" elif [ "$RVAL" = "#" ]; then - rm -f /tmp/contosrv.tmp.$$ + rm -f $TMPFILE clear echo "これは選択出来ません。" else clear ssh $RVAL - rm -f /tmp/contosrv.tmp.$$ + rm -f $TMPFILE fi