From f3d00f06715f3ae0eb4d905cfe3451a2fd6c9596 Mon Sep 17 00:00:00 2001 From: William Ting Date: Sun, 24 Apr 2011 18:54:55 -1000 Subject: [PATCH 1/8] combining cd && ls into j function --- autojump.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autojump.bash b/autojump.bash index e512640..f3811b6 100644 --- a/autojump.bash +++ b/autojump.bash @@ -45,6 +45,6 @@ fi AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null' if [[ ! $PROMPT_COMMAND =~ autojump ]]; then export PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; $AUTOJUMP" -fi +fi alias jumpstat="autojump --stat" -function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path";else false; fi } +function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path" && ls;else false; fi } From 4f7690fd2810b53e3f7cf3d730556745ee9556f5 Mon Sep 17 00:00:00 2001 From: William Ting Date: Sun, 24 Apr 2011 23:20:57 -1000 Subject: [PATCH 2/8] fixed regex matching vs existing source /etc/profile line in .bashrc --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a4ea759..1733728 100755 --- a/install.sh +++ b/install.sh @@ -55,7 +55,7 @@ if [ -d "/etc/profile.d" ]; then # Make sure that the code we just copied has been sourced. # check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash - if [ `grep -c "^[[:space:]]*source\|\. /etc/profile(\.d/autojump\.bash)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then + if [ `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" echo "" >> ~/.bashrc @@ -80,7 +80,7 @@ else # Makes the assumption that if they have a line: source ~/.bashrc or . ~/.bashrc, that # .bashrc has been properly sourced and you don't need to add it. OS=`uname` - if [ $OS == 'Darwin' -a `grep -c "^[[:space:]]*source\|\. ~/\.bashrc[[:space:]]*$" ~/.bash_profile` -eq 0 ]; then + if [ $OS == 'Darwin' -a `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bash_profile` -eq 0 ]; then echo "You are using OSX and your .bash_profile doesn't seem to be sourcing .bashrc" echo "Adding source ~/.bashrc to your bashrc" echo -e "\n# Get the aliases and functions" >> ~/.bash_profile From b021f23327c50517677858573807d1a32aea1be9 Mon Sep 17 00:00:00 2001 From: William Ting Date: Mon, 25 Apr 2011 00:39:30 -1000 Subject: [PATCH 3/8] change default location to /usr/local/, remove existing installation in /usr/ if detected. --- README.rst | 14 +++++++------- install.sh | 36 ++++++++++++++++++++++++++++-------- jumpapplet | 4 ++-- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/README.rst b/README.rst index ecc587d..b2891da 100644 --- a/README.rst +++ b/README.rst @@ -104,9 +104,9 @@ before the first step. Manual installation of autojump is very simple: copy -- autojump to /usr/bin, +- autojump to /usr/local/bin, - autojump.sh to /etc/profile.d, -- autojump.1 to /usr/share/man/man1. +- autojump.1 to /usr/local/share/man/man1. Make sure to source ``/etc/profile`` in your ``.bashrc`` or ``.zshrc`` :: @@ -136,15 +136,15 @@ To completely remove autojump you should remove these files: ``/etc/profile.d/autojump.zsh`` -``/usr/bin/autojump`` +``/usr/local/bin/autojump`` -``/usr/bin/jumpapplet`` +``/usr/local/bin/jumpapplet`` -``/usr/share/autojump/icon.png`` +``/usr/local/share/autojump/icon.png`` -``/usr/share/autojump/`` +``/usr/local/share/autojump/`` -``/usr/share/man/man1/autojump.1`` +``/usr/local/share/man/man1/autojump.1`` Remove any mention of autojump in your ``.bashrc`` or ``.zshrc``, then in currently running shells do:``source /etc/profile``. diff --git a/install.sh b/install.sh index 1733728..169d5cf 100755 --- a/install.sh +++ b/install.sh @@ -20,7 +20,7 @@ function show_help { } # Default install directory. -prefix=/usr +prefix=/usr/local # Command line parsing while true; do @@ -38,6 +38,26 @@ while true; do esac done +uninstall=0; +if [ -f "/usr/bin/autojump" ]; then + while true; do + read -p "Old installation detected, remove? [Yn] " yn + case $yn in + [Yy]* ) uninstall=1; break;; + [Nn]* ) "Already installed, exiting." exit 1;; + * ) uninstall=1; break;; + esac + done +fi + +if [ ${uninstall} == 1 ]; then + echo "Deleting old installation files ..." + sudo rm -r /usr/share/autojump/ + sudo rm /usr/bin/autojump + sudo rm /usr/bin/jumpapplet + sudo rm /usr/share/man/man1/autojump.1 +fi + echo "Installing to ${prefix} ..." # INSTALL AUTOJUMP @@ -69,12 +89,12 @@ else 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 ~/.bashrc file to make it work? (If you have done this once before, delete the old version before doing it again.) [y/n]" read ans if [ ${#ans} -gt 0 ]; then - if [ $ans = "y" -o $ans = "Y" -o $ans = "yes" -o $ans = "Yes" ]; then + if [ $ans = "y" -o $ans = "Y" -o $ans = "yes" -o $ans = "Yes" ]; then # Answered yes. Go ahead and add the autojump code - echo "" >> ~/.bashrc - echo "#autojump" >> ~/.bashrc - cat autojump.bash | grep -v "^#" >> ~/.bashrc + echo "" >> ~/.bashrc + echo "#autojump" >> ~/.bashrc + cat autojump.bash | grep -v "^#" >> ~/.bashrc # Since OSX uses .bash_profile, we need to make sure that .bashrc is properly sourced. # Makes the assumption that if they have a line: source ~/.bashrc or . ~/.bashrc, that @@ -87,9 +107,9 @@ else echo -e "if [ -f ~/.bashrc ]; then\n . ~/.bashrc\nfi" >> ~/.bash_profile fi echo "You need to source your ~/.bashrc (source ~/.bashrc) before you can start using autojump." - else - echo "Then you need to put autojump.sh, or the code from it, somewhere where it will get read. Good luck!" - fi + else + echo "Then you need to put autojump.sh, or the code from it, somewhere where it will get read. Good luck!" + fi else echo "Then you need to put autojump.sh, or the code from it, somewhere where it will get read. Good luck!" fi diff --git a/jumpapplet b/jumpapplet index 4b44826..5ef9688 100755 --- a/jumpapplet +++ b/jumpapplet @@ -168,7 +168,7 @@ def settings(sender): window.set_border_width(3) window.set_resizable(False) if os.path.isfile("icon.png"): window.set_icon_from_file("icon.png") - elif os.path.isfile("/usr/share/autojump/icon.png"): window.set_icon_from_file("/usr/share/autojump/icon.png") + elif os.path.isfile("/usr/local/share/autojump/icon.png"): window.set_icon_from_file("/usr/local/share/autojump/icon.png") vbox=gtk.Table(5,2) vbox.set_row_spacings(3) @@ -234,7 +234,7 @@ def save_settings(sender,response,entries,window): def init(): load_settings_file() if os.path.isfile("icon.png"): icon=gtk.status_icon_new_from_file("icon.png") - elif os.path.isfile("/usr/share/autojump/icon.png"): icon=gtk.status_icon_new_from_file("/usr/share/autojump/icon.png") + elif os.path.isfile("/usr/local/share/autojump/icon.png"): icon=gtk.status_icon_new_from_file("/usr/local/share/autojump/icon.png") else: icon=gtk.status_icon_new_from_icon_name("help") icon.set_visible(True) icon.connect("popup-menu",popup) From 7add5c601ed58fbfc24d17c3c4c437da2742bd73 Mon Sep 17 00:00:00 2001 From: William Ting Date: Sat, 14 May 2011 00:09:02 -0500 Subject: [PATCH 4/8] modify install script to support local installs --- autojump.bash | 22 +++++-------------- install.sh | 58 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/autojump.bash b/autojump.bash index f3811b6..8e851d4 100644 --- a/autojump.bash +++ b/autojump.bash @@ -25,26 +25,14 @@ _autojump() done < <(autojump --bash --completion $cur) } complete -F _autojump j -#data_dir=${XDG_DATA_HOME:-$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)} -data_dir=$([ -e ~/.local/share ] && echo ~/.local/share || echo ~) + export AUTOJUMP_HOME=${HOME} -if [[ "$data_dir" = "${HOME}" ]] -then - export AUTOJUMP_DATA_DIR=${data_dir} -else - export AUTOJUMP_DATA_DIR=${data_dir}/autojump -fi -if [ ! -e "${AUTOJUMP_DATA_DIR}" ] -then - mkdir "${AUTOJUMP_DATA_DIR}" - mv ~/.autojump_py "${AUTOJUMP_DATA_DIR}/autojump_py" 2>>/dev/null #migration - mv ~/.autojump_py.bak "${AUTOJUMP_DATA_DIR}/autojump_py.bak" 2>>/dev/null - mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null -fi +export AUTOJUMP_DATA_DIR=${HOME}/.autojump AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null' if [[ ! $PROMPT_COMMAND =~ autojump ]]; then - export PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; $AUTOJUMP" + export PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; $AUTOJUMP" fi + alias jumpstat="autojump --stat" -function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path" && ls;else false; fi } +function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path"; else false; fi } diff --git a/install.sh b/install.sh index 169d5cf..3504f87 100755 --- a/install.sh +++ b/install.sh @@ -19,9 +19,6 @@ function show_help { echo "sudo ./install.sh [--prefix /usr/local]" } -# Default install directory. -prefix=/usr/local - # Command line parsing while true; do case "$1" in @@ -58,6 +55,21 @@ if [ ${uninstall} == 1 ]; then sudo rm /usr/share/man/man1/autojump.1 fi +all_users=0; +while true; do + read -p "Install for all users (requires root)? [Yn] " yn + case $yn in + [Yy]* ) all_users=1; break;; + [Nn]* ) all_users=0; break;; + * ) all_users=1; break;; + esac +done + +prefix=/usr/local +if [ ${all_users} == 0 ]; then + prefix=${HOME}/.autojump +fi + echo "Installing to ${prefix} ..." # INSTALL AUTOJUMP @@ -69,24 +81,42 @@ sudo cp jumpapplet ${prefix}/bin/ sudo cp autojump ${prefix}/bin/ sudo cp autojump.1 ${prefix}/share/man/man1/ -if [ -d "/etc/profile.d" ]; then - sudo cp autojump.bash /etc/profile.d/ - sudo cp autojump.sh /etc/profile.d/ +if [ `uname` != "Darwin" ]; then + if [ ${all_users} == 1 ]; then + sudo mkdir -p /etc/profile.d/ + sudo cp autojump.bash /etc/profile.d/ + sudo cp autojump.sh /etc/profile.d/ - # Make sure that the code we just copied has been sourced. - # check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash - if [ `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then - echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" - echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" - echo "" >> ~/.bashrc - echo "# Added by autojump install.sh" >> ~/.bashrc - echo "source /etc/profile.d/autojump.bash" >> ~/.bashrc + # Make sure that the code we just copied has been sourced. + # check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash + if [ `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then + echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" + echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" + echo "" >> ~/.bashrc + echo "# Added by autojump install.sh" >> ~/.bashrc + echo "source /etc/profile.d/autojump.bash" >> ~/.bashrc + fi + else + mkdir -p ${prefix}/etc/profile.d/ + cp autojump.bash ${prefix}/etc/profile.d/ + cp autojump.sh ${prefix}/etc/profile.d/ + + if [ `grep -c "^[[:space:]]*\(source\|\.\) ${prefix}/etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then + echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" + echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" + echo "" >> ~/.bashrc + echo "# Added by autojump install.sh" >> ~/.bashrc + echo "source ${prefix}/etc/profile.d/autojump.bash" >> ~/.bashrc + fi fi + echo "Done!" echo echo "You need to source your ~/.bashrc (source ~/.bashrc) before you can start using autojump." + else 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 ~/.bashrc file to make it work? (If you have done this once before, delete the old version before doing it again.) [y/n]" + read ans if [ ${#ans} -gt 0 ]; then if [ $ans = "y" -o $ans = "Y" -o $ans = "yes" -o $ans = "Yes" ]; then From 69fb7bb79298277efd0472986752806ab1dd7813 Mon Sep 17 00:00:00 2001 From: William Ting Date: Fri, 13 May 2011 19:27:16 -1000 Subject: [PATCH 5/8] fix sudo installation, testing proper sudo installation, and changed data directory to ~/.autojump/ --- autojump.bash | 3 +++ install.sh | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/autojump.bash b/autojump.bash index 8e851d4..f83cc97 100644 --- a/autojump.bash +++ b/autojump.bash @@ -28,6 +28,9 @@ complete -F _autojump j export AUTOJUMP_HOME=${HOME} export AUTOJUMP_DATA_DIR=${HOME}/.autojump +if [ ! -d ${AUTOJUMP_DATA_DIR} ]; then + mkdir -p ${AUTOJUMP_DATA_DIR} +fi AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null' if [[ ! $PROMPT_COMMAND =~ autojump ]]; then diff --git a/install.sh b/install.sh index 3504f87..0b70156 100755 --- a/install.sh +++ b/install.sh @@ -73,20 +73,25 @@ fi echo "Installing to ${prefix} ..." # INSTALL AUTOJUMP -sudo mkdir -p ${prefix}/share/autojump/ -sudo mkdir -p ${prefix}/bin/ -sudo mkdir -p ${prefix}/share/man/man1/ -sudo cp icon.png ${prefix}/share/autojump/ -sudo cp jumpapplet ${prefix}/bin/ -sudo cp autojump ${prefix}/bin/ -sudo cp autojump.1 ${prefix}/share/man/man1/ - if [ `uname` != "Darwin" ]; then if [ ${all_users} == 1 ]; then + sudo mkdir -p ${prefix}/share/autojump/ + sudo mkdir -p ${prefix}/bin/ + sudo mkdir -p ${prefix}/share/man/man1/ + sudo cp icon.png ${prefix}/share/autojump/ + sudo cp jumpapplet ${prefix}/bin/ + sudo cp autojump ${prefix}/bin/ + sudo cp autojump.1 ${prefix}/share/man/man1/ sudo mkdir -p /etc/profile.d/ sudo cp autojump.bash /etc/profile.d/ sudo cp autojump.sh /etc/profile.d/ + # Fail sudo install + if [ ! -f ${prefix}/bin/autojump ] || [ ! -f ${prefix}/share/man/man1/autojump.1 ] || [ ! -f /etc/profile.d/autojump.bash ] || [ ! -f /etc/profile.d/autojump.sh ]; then + echo "Autojump was not installed, please try again using single user installation or with the correct sudo password." + exit 1 + fi + # Make sure that the code we just copied has been sourced. # check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash if [ `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then @@ -97,6 +102,13 @@ if [ `uname` != "Darwin" ]; then echo "source /etc/profile.d/autojump.bash" >> ~/.bashrc fi else + mkdir -p ${prefix}/share/autojump/ + mkdir -p ${prefix}/bin/ + mkdir -p ${prefix}/share/man/man1/ + cp icon.png ${prefix}/share/autojump/ + cp jumpapplet ${prefix}/bin/ + cp autojump ${prefix}/bin/ + cp autojump.1 ${prefix}/share/man/man1/ mkdir -p ${prefix}/etc/profile.d/ cp autojump.bash ${prefix}/etc/profile.d/ cp autojump.sh ${prefix}/etc/profile.d/ From 6ac2bd897c43d98105a2bf13cec22052cbda2915 Mon Sep 17 00:00:00 2001 From: William Ting Date: Fri, 13 May 2011 19:48:51 -1000 Subject: [PATCH 6/8] test for ~/.autojump/bin within .bashrc PATH and add if necessary for single user installs --- autojump.bash | 3 +++ install.sh | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/autojump.bash b/autojump.bash index f83cc97..d0e6586 100644 --- a/autojump.bash +++ b/autojump.bash @@ -30,6 +30,9 @@ export AUTOJUMP_HOME=${HOME} export AUTOJUMP_DATA_DIR=${HOME}/.autojump if [ ! -d ${AUTOJUMP_DATA_DIR} ]; then mkdir -p ${AUTOJUMP_DATA_DIR} + mv ~/.autojump_py "${AUTOJUMP_DATA_DIR}/autojump_py" 2>>/dev/null #migration + mv ~/.autojump_py.bak "${AUTOJUMP_DATA_DIR}/autojump_py.bak" 2>>/dev/null + mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null fi AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null' diff --git a/install.sh b/install.sh index 0b70156..d4d7ce6 100755 --- a/install.sh +++ b/install.sh @@ -120,6 +120,15 @@ if [ `uname` != "Darwin" ]; then echo "# Added by autojump install.sh" >> ~/.bashrc echo "source ${prefix}/etc/profile.d/autojump.bash" >> ~/.bashrc fi + + if [ `grep -c ".*PATH.*.autojump/bin" ~/.bashrc` -eq 0 ]; then + echo "Your .bashrc doesn't seem to have ${prefix}/bin in your \$PATH" + echo "Adding the ${prefix}/bin/ to your PATH" + echo "" >> ~/.bashrc + echo "# Added by autojump install.sh" >> ~/.bashrc + echo 'export PATH=${PATH}:~/.autojump/bin' >> ~/.bashrc + fi + fi echo "Done!" From 71f3d876c91e49c3d562b1f7009726ee1298ccd5 Mon Sep 17 00:00:00 2001 From: William Ting Date: Fri, 13 May 2011 20:24:11 -1000 Subject: [PATCH 7/8] fixed and tested single user / all user installation on OS X. --- install.sh | 148 +++++++++++++++++++++++------------------------------ 1 file changed, 63 insertions(+), 85 deletions(-) diff --git a/install.sh b/install.sh index d4d7ce6..b5b1057 100755 --- a/install.sh +++ b/install.sh @@ -73,95 +73,73 @@ fi echo "Installing to ${prefix} ..." # INSTALL AUTOJUMP -if [ `uname` != "Darwin" ]; then - if [ ${all_users} == 1 ]; then - sudo mkdir -p ${prefix}/share/autojump/ - sudo mkdir -p ${prefix}/bin/ - sudo mkdir -p ${prefix}/share/man/man1/ - sudo cp icon.png ${prefix}/share/autojump/ - sudo cp jumpapplet ${prefix}/bin/ - sudo cp autojump ${prefix}/bin/ - sudo cp autojump.1 ${prefix}/share/man/man1/ - sudo mkdir -p /etc/profile.d/ - sudo cp autojump.bash /etc/profile.d/ - sudo cp autojump.sh /etc/profile.d/ - - # Fail sudo install - if [ ! -f ${prefix}/bin/autojump ] || [ ! -f ${prefix}/share/man/man1/autojump.1 ] || [ ! -f /etc/profile.d/autojump.bash ] || [ ! -f /etc/profile.d/autojump.sh ]; then - echo "Autojump was not installed, please try again using single user installation or with the correct sudo password." - exit 1 - fi - - # Make sure that the code we just copied has been sourced. - # check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash - if [ `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then - echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" - echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" - echo "" >> ~/.bashrc - echo "# Added by autojump install.sh" >> ~/.bashrc - echo "source /etc/profile.d/autojump.bash" >> ~/.bashrc - fi - else - mkdir -p ${prefix}/share/autojump/ - mkdir -p ${prefix}/bin/ - mkdir -p ${prefix}/share/man/man1/ - cp icon.png ${prefix}/share/autojump/ - cp jumpapplet ${prefix}/bin/ - cp autojump ${prefix}/bin/ - cp autojump.1 ${prefix}/share/man/man1/ - mkdir -p ${prefix}/etc/profile.d/ - cp autojump.bash ${prefix}/etc/profile.d/ - cp autojump.sh ${prefix}/etc/profile.d/ - - if [ `grep -c "^[[:space:]]*\(source\|\.\) ${prefix}/etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then - echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" - echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" - echo "" >> ~/.bashrc - echo "# Added by autojump install.sh" >> ~/.bashrc - echo "source ${prefix}/etc/profile.d/autojump.bash" >> ~/.bashrc - fi - - if [ `grep -c ".*PATH.*.autojump/bin" ~/.bashrc` -eq 0 ]; then - echo "Your .bashrc doesn't seem to have ${prefix}/bin in your \$PATH" - echo "Adding the ${prefix}/bin/ to your PATH" - echo "" >> ~/.bashrc - echo "# Added by autojump install.sh" >> ~/.bashrc - echo 'export PATH=${PATH}:~/.autojump/bin' >> ~/.bashrc - fi +if [ ${all_users} == 1 ]; then + sudo mkdir -p ${prefix}/share/autojump/ + sudo mkdir -p ${prefix}/bin/ + sudo mkdir -p ${prefix}/share/man/man1/ + sudo cp icon.png ${prefix}/share/autojump/ + sudo cp jumpapplet ${prefix}/bin/ + sudo cp autojump ${prefix}/bin/ + sudo cp autojump.1 ${prefix}/share/man/man1/ + sudo mkdir -p /etc/profile.d/ + sudo cp autojump.bash /etc/profile.d/ + sudo cp autojump.sh /etc/profile.d/ + # Fail sudo install + if [ ! -f ${prefix}/bin/autojump ] || [ ! -f ${prefix}/share/man/man1/autojump.1 ] || [ ! -f /etc/profile.d/autojump.bash ] || [ ! -f /etc/profile.d/autojump.sh ]; then + echo "Autojump was not installed, please try again using single user installation or with the correct sudo password." + exit 1 fi - echo "Done!" - echo - echo "You need to source your ~/.bashrc (source ~/.bashrc) before you can start using autojump." - + # Make sure that the code we just copied has been sourced. + # check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash + if [ `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then + echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" + echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" + echo "" >> ~/.bashrc + echo "# Added by autojump install.sh" >> ~/.bashrc + echo "source /etc/profile.d/autojump.bash" >> ~/.bashrc + fi else - 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 ~/.bashrc file to make it work? (If you have done this once before, delete the old version before doing it again.) [y/n]" + mkdir -p ${prefix}/share/autojump/ + mkdir -p ${prefix}/bin/ + mkdir -p ${prefix}/share/man/man1/ + cp icon.png ${prefix}/share/autojump/ + cp jumpapplet ${prefix}/bin/ + cp autojump ${prefix}/bin/ + cp autojump.1 ${prefix}/share/man/man1/ + mkdir -p ${prefix}/etc/profile.d/ + cp autojump.bash ${prefix}/etc/profile.d/ + cp autojump.sh ${prefix}/etc/profile.d/ - read ans - if [ ${#ans} -gt 0 ]; then - if [ $ans = "y" -o $ans = "Y" -o $ans = "yes" -o $ans = "Yes" ]; then - - # Answered yes. Go ahead and add the autojump code - echo "" >> ~/.bashrc - echo "#autojump" >> ~/.bashrc - cat autojump.bash | grep -v "^#" >> ~/.bashrc - - # Since OSX uses .bash_profile, we need to make sure that .bashrc is properly sourced. - # Makes the assumption that if they have a line: source ~/.bashrc or . ~/.bashrc, that - # .bashrc has been properly sourced and you don't need to add it. - OS=`uname` - if [ $OS == 'Darwin' -a `grep -c "^[[:space:]]*\(source\|\.\) /etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bash_profile` -eq 0 ]; then - echo "You are using OSX and your .bash_profile doesn't seem to be sourcing .bashrc" - echo "Adding source ~/.bashrc to your bashrc" - echo -e "\n# Get the aliases and functions" >> ~/.bash_profile - echo -e "if [ -f ~/.bashrc ]; then\n . ~/.bashrc\nfi" >> ~/.bash_profile - fi - echo "You need to source your ~/.bashrc (source ~/.bashrc) before you can start using autojump." - else - echo "Then you need to put autojump.sh, or the code from it, somewhere where it will get read. Good luck!" - fi - else - echo "Then you need to put autojump.sh, or the code from it, somewhere where it will get read. Good luck!" + if [ `grep -c "^[[:space:]]*\(source\|\.\) ${prefix}/etc/profile\(\.d/autojump\.bash\)[[:space:]]*$" ~/.bashrc` -eq 0 ]; then + echo "Your .bashrc doesn't seem to source /etc/profile or /etc/profile.d/autojump.bash" + echo "Adding the /etc/profile.d/autojump.bash to your .bashrc" + echo "" >> ~/.bashrc + echo "# Added by autojump install.sh" >> ~/.bashrc + echo "source ${prefix}/etc/profile.d/autojump.bash" >> ~/.bashrc fi + + if [ `grep -c ".*PATH.*.autojump/bin" ~/.bashrc` -eq 0 ]; then + echo "Your .bashrc doesn't seem to have ${prefix}/bin in your \$PATH" + echo "Adding the ${prefix}/bin/ to your PATH" + echo "" >> ~/.bashrc + echo "# Added by autojump install.sh" >> ~/.bashrc + echo 'export PATH=${PATH}:~/.autojump/bin' >> ~/.bashrc + fi + +fi + +echo "Done!" +echo +echo "You need to source your ~/.bashrc (source ~/.bashrc) before you can start using autojump." + +# Since OSX uses .bash_profile, we need to make sure that .bashrc is properly sourced. +# Makes the assumption that if they have a line: source ~/.bashrc or . ~/.bashrc, that +# .bashrc has been properly sourced and you don't need to add it. +if [ `uname` == "Darwin" ] && [ `grep -c "^[[:space:]]*\(source\|\.\).*\.bashrc[[:space:]]*$" ~/.bash_profile` -eq 0 ]; then + echo "Your .bash_profile doesn't seem to be sourcing .bashrc" + echo "Adding source ~/.bashrc to your bashrc" + echo -e "\n# Get the aliases and functions" >> ~/.bash_profile + echo -e "if [ -f ~/.bashrc ]; then\n . ~/.bashrc\nfi" >> ~/.bash_profile fi From 450787682f31219f236fd09f63d91bf9ec87ca83 Mon Sep 17 00:00:00 2001 From: William Ting Date: Fri, 13 May 2011 20:32:41 -1000 Subject: [PATCH 8/8] minor edit, reposition OS X output before the done message --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index b5b1057..93ea0e0 100755 --- a/install.sh +++ b/install.sh @@ -130,10 +130,6 @@ else fi -echo "Done!" -echo -echo "You need to source your ~/.bashrc (source ~/.bashrc) before you can start using autojump." - # Since OSX uses .bash_profile, we need to make sure that .bashrc is properly sourced. # Makes the assumption that if they have a line: source ~/.bashrc or . ~/.bashrc, that # .bashrc has been properly sourced and you don't need to add it. @@ -143,3 +139,7 @@ if [ `uname` == "Darwin" ] && [ `grep -c "^[[:space:]]*\(source\|\.\).*\.bashrc[ echo -e "\n# Get the aliases and functions" >> ~/.bash_profile echo -e "if [ -f ~/.bashrc ]; then\n . ~/.bashrc\nfi" >> ~/.bash_profile fi + +echo "Done!" +echo +echo "You need to source your ~/.bashrc (source ~/.bashrc) before you can start using autojump."