1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 13:50:09 +00:00
ohmyzsh/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh

56 lines
1.8 KiB
Bash
Raw Normal View History

2015-09-20 12:39:46 +00:00
#!/usr/bin/env zsh
2016-11-02 12:08:58 +00:00
0="${(%):-%N}" # this gives immunity to functionargzero being unset
export ZNT_REPO_DIR="${0%/*}"
export ZNT_CONFIG_DIR="$HOME/.config/znt"
2015-09-20 12:39:46 +00:00
#
# Copy configs
#
2016-11-02 12:08:58 +00:00
if [[ ! -d "$HOME/.config" ]]; then
command mkdir "$HOME/.config"
2015-09-20 12:39:46 +00:00
fi
2016-11-02 12:08:58 +00:00
if [[ ! -d "$ZNT_CONFIG_DIR" ]]; then
command mkdir "$ZNT_CONFIG_DIR"
2015-09-20 12:39:46 +00:00
fi
2016-04-30 13:16:00 +00:00
# 9 files
2016-11-02 12:08:58 +00:00
unset __ZNT_CONFIG_FILES
typeset -ga __ZNT_CONFIG_FILES
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
2015-09-20 12:39:46 +00:00
2016-04-30 13:16:00 +00:00
# Check for random 2 files if they exist
# This will shift 0 - 7 elements
2016-11-02 12:08:58 +00:00
shift $(( RANDOM % 8 )) __ZNT_CONFIG_FILES
if [[ ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[1]}" || ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[2]}" ]]; then
2016-04-30 13:16:00 +00:00
# Something changed - examine every file
2016-11-02 12:08:58 +00:00
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
unset __ZNT_CONFIG_FILE
typeset -g __ZNT_CONFIG_FILE
for __ZNT_CONFIG_FILE in "${__ZNT_CONFIG_FILES[@]}"; do
if [[ ! -f "$ZNT_CONFIG_DIR/$__ZNT_CONFIG_FILE" ]]; then
command cp "$ZNT_REPO_DIR/.config/znt/$__ZNT_CONFIG_FILE" "$ZNT_CONFIG_DIR"
2016-04-30 13:16:00 +00:00
fi
done
2016-11-02 12:08:58 +00:00
unset __ZNT_CONFIG_FILE
2016-04-30 13:16:00 +00:00
fi
2015-09-20 12:39:46 +00:00
2016-11-02 12:08:58 +00:00
unset __ZNT_CONFIG_FILES
2015-09-20 12:39:46 +00:00
#
# Load functions
#
2016-04-30 13:16:00 +00:00
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
2015-09-20 12:39:46 +00:00
autoload znt-usetty-wrapper znt-history-widget znt-cd-widget znt-kill-widget
alias naliases=n-aliases ncd=n-cd nenv=n-env nfunctions=n-functions nhistory=n-history
2016-04-30 13:16:00 +00:00
alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help
2015-09-20 12:39:46 +00:00
zle -N znt-history-widget
bindkey '^R' znt-history-widget
setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS
2016-04-30 13:16:00 +00:00
zstyle ':completion::complete:n-kill::bits' matcher 'r:|=** l:|=*'
2015-09-20 12:39:46 +00:00