~ubuntu-branches/ubuntu/saucy/autojump/saucy

« back to all changes in this revision

Viewing changes to install.zsh

  • Committer: Bazaar Package Importer
  • Author(s): Tanguy Ortolo
  • Date: 2010-08-10 10:22:17 UTC
  • Revision ID: james.westby@ubuntu.com-20100810102217-an0j349xl7sfiiv9
Tags: upstream-11
ImportĀ upstreamĀ versionĀ 11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/zsh
 
2
#Copyright Joel Schaerer 2008, 2009
 
3
#This file is part of autojump
 
4
 
 
5
#autojump is free software: you can redistribute it and/or modify
 
6
#it under the terms of the GNU General Public License as published by
 
7
#the Free Software Foundation, either version 3 of the License, or
 
8
#(at your option) any later version.
 
9
#
 
10
#autojump is distributed in the hope that it will be useful,
 
11
#but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#GNU General Public License for more details.
 
14
#
 
15
#You should have received a copy of the GNU General Public License
 
16
#along with autojump.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
function show_help {
 
19
        echo "sudo ./install.sh [--prefix /usr/local]"
 
20
}
 
21
 
 
22
prefix=/usr
 
23
 
 
24
#command line parsing
 
25
while true; do
 
26
    case "$1" in
 
27
      -h|--help|-\?) show_help; exit 0;;
 
28
      -p|--prefix) if [ $# -gt 1 ]; then
 
29
            prefix=$2; shift 2
 
30
          else 
 
31
            echo "--prefix or -p require an argument" 1>&2
 
32
            exit 1
 
33
          fi ;;
 
34
      --) shift; break;;
 
35
      -*) echo "invalid option: $1" 1>&2; show_help; exit 1;;
 
36
      *)  break;;
 
37
    esac
 
38
done
 
39
 
 
40
echo "Installing to ${prefix} ..."
 
41
 
 
42
sudo mkdir -p ${prefix}/share/autojump/
 
43
sudo cp icon.png ${prefix}/share/autojump/
 
44
sudo cp jumpapplet ${prefix}/bin/
 
45
sudo cp autojump ${prefix}/bin/
 
46
sudo cp autojump.1 ${prefix}/share/man/man1/
 
47
 
 
48
# autocompletion file in the first directory of the FPATH variable
 
49
sudo cp _j $(echo $FPATH | cut -d":" -f 1)
 
50
 
 
51
if [ -d "/etc/profile.d" ]; then
 
52
    sudo cp autojump.zsh /etc/profile.d/
 
53
    sudo cp autojump.sh /etc/profile.d/
 
54
    echo "Remember to add the line" 
 
55
    echo "    source /etc/profile.d/autojump.zsh"
 
56
    echo "or"
 
57
    echo "    source /etc/profile"
 
58
    echo "to your ~/.zshrc if it's not there already"
 
59
else
 
60
    echo "Your distribution does not have a /etc/profile.d directory, the default that we install one of the scripts to. Would you like us to copy it into your ~/.zshrc file to make it work? (If you have done this once before, delete the old version before doing it again.) [y/n]"
 
61
    read ans
 
62
    if [ ${#ans} -gt 0 ]; then
 
63
        if [ $ans = "y" -o $ans = "Y" -o $ans = "yes" -o $ans = "Yes" ]; then
 
64
            echo "" >> ~/.zshrc
 
65
            echo "#autojump" >> ~/.zshrc
 
66
            cat autojump.zsh >> ~/.zshrc
 
67
        else
 
68
            echo "Then you need to put autojump.zsh, or the code from it, somewhere where it will get read. Good luck!"
 
69
        fi
 
70
    else
 
71
            echo "Then you need to put autojump.zsh, or the code from it, somewhere where it will get read. Good luck!"
 
72
    fi
 
73
fi