[ADD] conf for archlinux, <init>
[arrow.git] / archlinux_conf / home / .bin / shell / ge
blob201bb6659ab66341d5eeeb9f037fb3d63aa776b3
1 #!/bin/bash
2 #author: arrow
3 #copyright(c) 29/06/2006 arrowworld@gmail.com
4 #use: enhance my vim, implement remote server, and use tab
6 . arrow-lib
7 GEO="-geom 106x37+0+25"
8 V_EXEFILE="gvim"
9 V_CURRENT_DIR="`pwd`"
10 #hostname will change to uppercase
11 #V_SERVERNAME="`hostname`"
12 if [ "$1" = "" ]; then
13 echo "check parameter please"
14 exit 0
16 V_SERVERNAME="$1"
17 shift
18 V_SERVERNAME=`echo "$V_SERVERNAME" | tr "a-z" "A-Z"`
19 V_REMOTE_TAB_SILENT="--remote-tab-silent"
20 #set to empty if you do like it
21 #V_REMOTE_TAB_SILENT=""
22 V_KEEP_DIR=""
23 V_KEEP_QUIET=""
24 V_NEED_WAIT="`$V_EXEFILE --serverlist | grep "$V_SERVERNAME" | grep -v grep`"
25 #test for go on if has error
26 V_SHOULD_EXIT=""
27 V_HAS_ERROR="$V_SERVERNAME"
28 if [ "$V_NEED_WAIT" = "" ]; then
29 echo "NEED wait: yes"
30 else
31 echo "NEED wait: no"
33 #V_FILENAMES="$*"
34 #set -- `getopt "ks" "$@"`
35 set -- `getopt "ks" "$@"`
36 while [ ! -z "$1" ]
38 case "$1" in
39 -k) #keep current dir
40 V_KEEP_DIR="YES";;
41 -s) #silent, do not echo msg when open a file
42 V_KEEP_QUIET="YES";;
43 *) break;;
44 esac
45 #delete this parameter
46 shift
47 done
48 #delete --
49 shift
51 #----------function open file with editor
52 function arrow_change_dir()
54 if [ "$V_HAS_ERROR" != "" ] && [ "$V_KEEP_DIR" != "YES" ]; then
55 #sleep 1
56 "$V_EXEFILE" --servername "$V_SERVERNAME" --remote-send ":lcd $V_CURRENT_DIR<CR>:<CR>"
57 echo "send lcd success"
60 function arrow_openfile()
62 #first parameter is the filename
63 if [ "$V_KEEP_QUIET" != "YES" ]; then
64 echo -e "server open: ${CL_GREEN}$1${CL_END}"
66 "$V_EXEFILE" $GEO --servername "$V_SERVERNAME" "$V_REMOTE_TAB_SILENT" "$1" 2>/dev/null
67 # usleep 700
68 sleep 1
69 if [ "$V_NEED_WAIT" != "$V_SERVERNAME" ]; then
70 sleep 2
71 #arrow_change_dir #now change dir at init
73 #check open gvim success, bcs remote used with x server only
74 V_HAS_ERROR="`$V_EXEFILE --serverlist | grep "$V_SERVERNAME" | grep -v grep`"
76 #----------function end
77 #V_GVIM="-g"
78 #remove it for a while, we can use {EXE} -g {FILENAME} to open files
80 #check parameter at first, echo err msg if is empty
81 if [ "$1" = "" ]; then
82 echo "arrow: make sure has file name -_-"
83 arrow_openfile "/tmp/tmp"
84 exit 0
87 #now open file with loop
88 echo -e "server name: [${CL_YELLOW}$V_SERVERNAME${CL_END}]"
90 until [ -z "$1" ]
92 #check err no, ask for go on
93 #check if here does not exists a xserver, ask for continue
94 if [ "$V_HAS_ERROR" = "" ]; then
95 echo "ERROR: here may do not exists a x server"
96 echo -n "->Question: do you want open rest files(y,n) "
97 read V_SHOULD_EXIT
98 if [ "$V_SHOULD_EXIT" != "y" ]; then
99 echo "END: check your xserver"
100 exit 0
103 #open file now
104 arrow_openfile "$1"
105 #revert wait variable
106 if [ "$V_NEED_WAIT" != "$V_SERVERNAME" ]; then
107 V_NEED_WAIT="$V_SERVERNAME"
109 shift
110 #arrow_change_dir #change current dir for every file to local
111 done
113 #end
115 # $Log:
116 # v1.0 create open gvim server with remote command
117 # v1.1 fix can not open multi files, set current dir for new file
118 # v1.2 fix open file will wait every time when exec "ge"
119 # UP: ask for to open rest files when can not open xserver
120 # and do not send lcd command when open xserver fail