up, add new config files and delete old tar conf file
[arrow.git] / conf_slk120 / bin / .bin / shell / arrow-kill-vim
blobd1871eddd8823d24441c41d975f44da54c2907f5
1 #!/bin/sh
2 # close all gvim by remote -_-
4 . arrow-lib
6 VIM="/usr/local/bin/vim"
7 SINGLE=$1
8 #arrow_c
9 #SINGLE=test
10 LISTALL=`$VIM --serverlist`
11 ECHO="/bin/echo -e"
13 function kill_force()
15 server=$1
16 $ECHO -n "force kill:[${CL_RED}$server${CL_END}] "
17 $VIM --servername $server --remote-send "<ESC>:qa!<CR>"
18 $VIM --serverlist | /bin/grep -qw $server
19 if [ "$?" = "0" ]; then
20 $ECHO "${CL_RED}fail${CL_END} !!"
21 return 1
22 else
23 $ECHO "${CL_GREEN}success${CL_END}"
24 return 0
28 function start()
30 arrowbanner #call
31 if [ "$LISTALL" = "" ]; then
32 $ECHO "all have killed before ${CL_RED}-_-${CL_END}"
33 return 0
36 if [ "$SINGLE" = "" ]; then
37 # LIST=`/bin/echo $LISTALL | tr "a-z" "A-Z"`
38 $ECHO -n "${CL_RED}will kill all exist gvim, [y/n] "
39 read iskall
40 $ECHO -n "${CL_END}"
41 if [ "$iskall" = "y" ]; then
42 LIST=$LISTALL
43 else
44 return 400
46 else
47 SINGLE=`$ECHO $SINGLE | tr "a-z" "A-Z"`
48 $ECHO $LISTALL | /bin/grep -qw $SINGLE
49 if [ "$?" = "0" ]; then
50 $ECHO "will close your specialed:$SINGLE"
51 LIST=$SINGLE
52 else
53 $ECHO "your input:[${CL_RED}$SINGLE${CL_END}] do not exists yet"
54 return 1
57 #$ECHO -e "LIST\n$LIST\n"
60 for server in $LIST
62 server=`$ECHO $server | tr "a-z" "A-Z"` #can remote it
63 $ECHO -n "kill: $server "
64 $VIM --servername $server --remote-send "<ESC>:qa<CR>"
65 $VIM --serverlist | /bin/grep -qw $server
66 if [ "$?" = "0" ]; then
67 $ECHO "${CL_RED}fail${CL_END}"
68 $ECHO -n "DO YOU WANT KILL IT FORCE:${CL_RED}[$server]${CL_END} [y/n] "
69 read FORCE
70 if [ "$FORCE" = "y" ]; then
71 kill_force $server
73 else
74 $ECHO "${CL_GREEN}success${CL_END}"
76 done
79 # run it -_-
80 start
81 exit 0