install.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. if ! type git 2>/dev/null 1>&2; then
  3. echo "Please install GIT first"
  4. echo "Exiting"
  5. exit 1
  6. fi
  7. #
  8. # Clone or pull
  9. #
  10. if ! test -d "$HOME/.config"; then
  11. mkdir "$HOME/.config"
  12. fi
  13. if ! test -d "$HOME/.config/znt"; then
  14. mkdir "$HOME/.config/znt"
  15. fi
  16. echo ">>> Downloading zsh-navigation-tools to ~/.config/znt"
  17. if test -d ~/.config/znt/zsh-navigation-tools; then
  18. cd ~/.config/znt/zsh-navigation-tools
  19. git pull origin master
  20. else
  21. cd ~/.config/znt
  22. git clone https://github.com/psprint/zsh-navigation-tools.git zsh-navigation-tools
  23. fi
  24. echo ">>> Done"
  25. #
  26. # Copy configs
  27. #
  28. echo ">>> Copying config files"
  29. cd ~/.config/znt
  30. set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
  31. for i; do
  32. if ! test -f "$i"; then
  33. cp -v zsh-navigation-tools/.config/znt/$i .
  34. fi
  35. done
  36. echo ">>> Done"
  37. #
  38. # Modify .zshrc
  39. #
  40. echo ">>> Updating .zshrc"
  41. if ! grep zsh-navigation-tools ~/.zshrc >/dev/null 2>&1; then
  42. echo >> ~/.zshrc
  43. echo "### ZNT's installer added snippet ###" >> ~/.zshrc
  44. echo "fpath=( \"\$fpath[@]\" \"\$HOME/.config/znt/zsh-navigation-tools\" )" >> ~/.zshrc
  45. echo "autoload n-aliases n-cd n-env n-functions n-history n-kill n-list n-list-draw n-list-input n-options n-panelize n-help" >> ~/.zshrc
  46. echo "autoload znt-usetty-wrapper znt-history-widget znt-cd-widget znt-kill-widget" >> ~/.zshrc
  47. echo "alias naliases=n-aliases ncd=n-cd nenv=n-env nfunctions=n-functions nhistory=n-history" >> ~/.zshrc
  48. echo "alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help" >> ~/.zshrc
  49. echo "zle -N znt-history-widget" >> ~/.zshrc
  50. echo "bindkey '^R' znt-history-widget" >> ~/.zshrc
  51. echo "setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS" >> ~/.zshrc
  52. echo "zstyle ':completion::complete:n-kill::bits' matcher 'r:|=** l:|=*'" >> ~/.zshrc
  53. echo "### END ###" >> ~/.zshrc
  54. echo ">>> Done"
  55. else
  56. echo ">>> .zshrc already updated, not making changes"
  57. fi