Parent directory

install.sh

2033 bytes
 1#!/bin/sh
 2
 3if ! type git 2>/dev/null 1>&2; then
 4    echo "Please install GIT first"
 5    echo "Exiting"
 6    exit 1
 7fi
 8
 9#
10# Clone or pull
11#
12
13if ! test -d "$HOME/.config"; then
14    mkdir "$HOME/.config"
15fi
16
17if ! test -d "$HOME/.config/znt"; then
18    mkdir "$HOME/.config/znt"
19fi
20
21echo ">>> Downloading zsh-navigation-tools to ~/.config/znt"
22if test -d ~/.config/znt/zsh-navigation-tools; then
23    cd ~/.config/znt/zsh-navigation-tools
24    git pull origin master
25else
26    cd ~/.config/znt
27    git clone https://github.com/psprint/zsh-navigation-tools.git zsh-navigation-tools
28fi
29echo ">>> Done"
30
31#
32# Copy configs
33#
34
35echo ">>> Copying config files"
36
37cd ~/.config/znt
38
39set 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
41for i; do
42    if ! test -f "$i"; then
43        cp -v zsh-navigation-tools/.config/znt/$i .
44    fi
45done
46
47echo ">>> Done"
48
49#
50# Modify .zshrc
51#
52
53echo ">>> Updating .zshrc"
54if ! 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"
68else
69    echo ">>> .zshrc already updated, not making changes"
70fi