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