root/closebracket/install.sh

Revision 1354, 2.9 kB (checked in by alpt, 1 year ago)

typo in install.sh

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/bash
2
3 install_alias() {
4     if grep -q CLOSEBRACKET_DIR $1; then
5         echo "* $1 seems to be already configured. It won't be touched."
6         return 0
7     fi
8
9     echo "* I'm going to append new aliases in your $1 file."
10     {   echo
11         echo "#### CLOSEBRACKET ####"
12         echo "export CLOSEBRACKET_DIR=\"$dstdir/\""
13         echo "alias ]=\"source $dstdir/cb I\""
14         echo "alias ][=\"source $dstdir/cb II\""
15         echo "#### CLOSEBRACKET ####"
16     } >> $1
17 }
18
19
20 if [ "$1" == "donotask" ]
21 then
22         donotask=1
23 fi
24
25 if [ -z "$donotask" ]
26 then
27         while [ -z $dstdir ]
28         do
29                 echo "Insert the installation directory. If you leave the default, everything"
30                 echo "will be installed under ~/.closebracket/. "
31                 echo "(just press enter for the default)"
32                 printf "[$HOME/.closebracket] "
33
34                 read -r dstdir
35                 if [ -z "$dstdir" ]; then
36                         dstdir=~/.closebracket
37                         break
38                 fi
39                 if [ ! -d "$dstdir" ]; then
40                         echo $dstdir isn\'t a valid directory
41                         dstdir=
42                         continue
43                 fi
44         done
45 fi
46
47 if [ -z "$dstdir" ]; then
48         dstdir=~/.closebracket
49 fi
50
51 if [ ! -z "$2" ]; then
52         dstdir="$2"
53 fi
54
55 echo "* Creating $dstdir"
56 if [ ! -d "$dstdir" ]; then
57     mkdir "$dstdir"
58     mkdir "$dstdir/scripts"
59 else
60     if [ ! -d "$dstdir/scripts" ]; then
61             mkdir "$dstdir/scripts"
62     fi
63 fi
64
65 echo "* Copying files in $dstdir"
66 cp  cb closebracket.conf file_extensions $dstdir/
67 cp scripts/* $dstdir/scripts
68 if [ ! -f $dstdir/shells ]; then
69         cp shells $dstdir/
70 fi
71
72 if [ -e ~/.bashrc ]; then
73     echo ""
74     echo "* You have a ~/.bashrc file."
75     if grep -q "alias \]\[=.*/\]\[" ~/.bashrc; then
76         echo ""
77         echo "*WARNING*"
78         echo ""
79         echo "You have an old version of closebracket."
80         echo "Please, remove the old aliases to have a clean .bashrc."
81         echo "Then, rerun the install script or add the following lines"
82         echo "manually:"
83         echo
84         echo "#### CLOSEBRACKET ####"
85         echo "export CLOSEBRACKET_DIR=\"$dstdir/\""
86         echo "alias ]=\"source $dstdir/cb I\""
87         echo "alias ][=\"source $dstdir/cb II\""
88         echo "#### CLOSEBRACKET ####"
89         echo
90         echo "*WARNING"
91         echo ""
92     else
93         install_alias ~/.bashrc
94     fi
95 fi
96
97 if [ -e ~/.zshrc ]; then
98     echo
99     echo "* You have a ~/.zshrc file."
100     install_alias ~/.zshrc
101 fi
102
103 if [ -z "$donotask" ]
104 then
105         echo ""
106         echo "Ok, now you should put the list of your remote shells in \"$dstdir/shells\""
107         echo "The format is one hostname per line, or if you want user@hostname per line"
108         echo "Hit Return when you've finished"
109         read -r nothing
110         echo ""
111         echo ""
112         echo "The installation is now complete, restart your shell and"
113         echo "Enjoy the speed ^_^"
114         echo ""
115         echo "PS: If you want to install closebracket in all your remote shells with a"
116         echo "single command, use ./install-rshells.sh"
117         echo "PPS: If you aren't using an US keyboard, you may find difficult"
118         echo "to use the ']' and '][' keys, therefore define two alias in"
119         echo "your ~/.bashrc"
120 fi
Note: See TracBrowser for help on using the browser.