4 # No plugin manager is needed to use this file. All that is needed is adding:
5 # source {where-znt-is}/zsh-navigation-tools.plugin.zsh
10 # According to the standard:
11 # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
12 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
13 0="${${(M)0:#/*}:-$PWD/$0}"
15 export ZNT_REPO_DIR="${0:h}"
16 export ZNT_CONFIG_DIR="$HOME/.config/znt"
20 # 1. Not loading with a plugin manager
21 # 2. Not having fpath already updated
24 if [[ ${zsh_loaded_plugins[-1]} != */zsh-navigation-tools && -z ${fpath[(r)${0:h}]} ]]
33 if [[ ! -d "$HOME/.config" ]]; then
34 command mkdir "$HOME/.config"
37 if [[ ! -d "$ZNT_CONFIG_DIR" ]]; then
38 command mkdir "$ZNT_CONFIG_DIR"
42 unset __ZNT_CONFIG_FILES
43 typeset -ga __ZNT_CONFIG_FILES
44 set +A __ZNT_CONFIG_FILES 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
46 # Check for random 2 files if they exist
47 # This will shift 0 - 7 elements
48 shift $(( RANDOM % 8 )) __ZNT_CONFIG_FILES
49 if [[ ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[1]}" || ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[2]}" ]]; then
50 # Something changed - examine every file
51 set +A __ZNT_CONFIG_FILES 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
52 unset __ZNT_CONFIG_FILE
53 typeset -g __ZNT_CONFIG_FILE
54 for __ZNT_CONFIG_FILE in "${__ZNT_CONFIG_FILES[@]}"; do
55 if [[ ! -f "$ZNT_CONFIG_DIR/$__ZNT_CONFIG_FILE" ]]; then
56 command cp "$ZNT_REPO_DIR/.config/znt/$__ZNT_CONFIG_FILE" "$ZNT_CONFIG_DIR"
59 unset __ZNT_CONFIG_FILE
62 unset __ZNT_CONFIG_FILES
68 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
69 autoload znt-usetty-wrapper znt-history-widget znt-cd-widget znt-kill-widget
70 alias naliases=n-aliases ncd=n-cd nenv=n-env nfunctions=n-functions nhistory=n-history
71 alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help
73 zle -N znt-history-widget
74 bindkey '^R' znt-history-widget
75 setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS
76 zstyle ':completion::complete:n-kill::bits' matcher 'r:|=** l:|=*'