You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
2.0 KiB

15 years ago
15 years ago
  1. #Copyright Joel Schaerer 2008, 2009
  2. #This file is part of autojump
  3. #autojump is free software: you can redistribute it and/or modify
  4. #it under the terms of the GNU General Public License as published by
  5. #the Free Software Foundation, either version 3 of the License, or
  6. #(at your option) any later version.
  7. #
  8. #autojump is distributed in the hope that it will be useful,
  9. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. #GNU General Public License for more details.
  12. #
  13. #You should have received a copy of the GNU General Public License
  14. #along with autojump. If not, see <http://www.gnu.org/licenses/>.
  15. #This shell snippet sets the prompt command and the necessary aliases
  16. _autojump()
  17. {
  18. local cur
  19. cur=${COMP_WORDS[*]:1}
  20. while read i
  21. do
  22. COMPREPLY=("${COMPREPLY[@]}" "${i}")
  23. done < <(autojump --bash --completion $cur)
  24. }
  25. complete -F _autojump j
  26. #data_dir=${XDG_DATA_HOME:-$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)}
  27. data_dir=$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)
  28. export AUTOJUMP_HOME=${HOME}
  29. if [[ "$data_dir" = "${HOME}" ]]
  30. then
  31. export AUTOJUMP_DATA_DIR=${data_dir}
  32. else
  33. export AUTOJUMP_DATA_DIR=${data_dir}/autojump
  34. fi
  35. if [ ! -e "${AUTOJUMP_DATA_DIR}" ]
  36. then
  37. mkdir "${AUTOJUMP_DATA_DIR}"
  38. mv ~/.autojump_py "${AUTOJUMP_DATA_DIR}/autojump_py" 2>>/dev/null #migration
  39. mv ~/.autojump_py.bak "${AUTOJUMP_DATA_DIR}/autojump_py.bak" 2>>/dev/null
  40. mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null
  41. fi
  42. AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null'
  43. if [[ ! $PROMPT_COMMAND =~ autojump ]]; then
  44. export PROMPT_COMMAND="$AUTOJUMP ; ${PROMPT_COMMAND:-:}"
  45. fi
  46. alias jumpstat="autojump --stat"
  47. function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path";else false; fi }