Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

91 rader
3.1 KiB

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