zsh-navigation-tools.plugin.zsh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env zsh
  2. REPO_DIR="${0%/*}"
  3. CONFIG_DIR="$HOME/.config/znt"
  4. #
  5. # Copy configs
  6. #
  7. if ! test -d "$HOME/.config"; then
  8. mkdir "$HOME/.config"
  9. fi
  10. if ! test -d "$CONFIG_DIR"; then
  11. mkdir "$CONFIG_DIR"
  12. fi
  13. # 9 files
  14. 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
  15. # Check for random 2 files if they exist
  16. # This will shift 0 - 7 elements
  17. shift $(( RANDOM % 8 ))
  18. if ! test -f "$CONFIG_DIR/$1" || ! test -f "$CONFIG_DIR/$2"; then
  19. # Something changed - examine every file
  20. 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
  21. for i; do
  22. if ! test -f "$CONFIG_DIR/$i"; then
  23. cp "$REPO_DIR/.config/znt/$i" "$CONFIG_DIR"
  24. fi
  25. done
  26. fi
  27. # Don't leave positional parameters being set
  28. set --
  29. #
  30. # Load functions
  31. #
  32. 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
  33. autoload znt-usetty-wrapper znt-history-widget znt-cd-widget znt-kill-widget
  34. alias naliases=n-aliases ncd=n-cd nenv=n-env nfunctions=n-functions nhistory=n-history
  35. alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help
  36. zle -N znt-history-widget
  37. bindkey '^R' znt-history-widget
  38. setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS
  39. zstyle ':completion::complete:n-kill::bits' matcher 'r:|=** l:|=*'