From 24ac946dd9704dbc75417640b222a534610be745 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 3 May 2015 22:57:03 +0200 Subject: [PATCH] Install script now looks for .zshrc in $ZDOTDIR as well. User can also supply as a first parameter the script to append to zsh-autosuggestions. --- install | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/install b/install index 351aefa..5cf7d42 100755 --- a/install +++ b/install @@ -2,11 +2,18 @@ # Install script for zsh-autocomplete -#first checks if ~/.zshrc file exists and is readable -if [ ! -r ~/.zshrc ]; then - echo "\nError: ~/.zshrc file does not exist or is not readable!\n" - exit 1 -fi +config="$HOME/.zshrc" +for config in "$HOME/.zshrc" "$ZDOTDIR/.zshrc" "$1" +do + echo $config + #first checks if ~/.zshrc file exists and is readable + if [ -r "$config" ]; then + break + elif [ "$config" = "$1" ]; then + echo "\nError: Please specify as first argument the file in which to load zsh-autosuggestions (usually ~/.zshrc)!\n" + exit 1 + fi +done SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink @@ -16,8 +23,8 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" -# appends the string to ~/.zshrc file -cat >> ~/.zshrc << EOF +# appends the string to $config (usually ~/.zshrc) file +cat >> "$config" << EOF # Setup zsh-autosuggestions source $DIR/autosuggestions.zsh