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.
This commit is contained in:
Matthieu Coudron 2015-05-03 22:57:03 +02:00
parent 59699a0946
commit 24ac946dd9

21
install
View file

@ -2,11 +2,18 @@
# Install script for zsh-autocomplete # Install script for zsh-autocomplete
#first checks if ~/.zshrc file exists and is readable config="$HOME/.zshrc"
if [ ! -r ~/.zshrc ]; then for config in "$HOME/.zshrc" "$ZDOTDIR/.zshrc" "$1"
echo "\nError: ~/.zshrc file does not exist or is not readable!\n" do
exit 1 echo $config
fi #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]}" SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink 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 done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# appends the string to ~/.zshrc file # appends the string to $config (usually ~/.zshrc) file
cat >> ~/.zshrc << EOF cat >> "$config" << EOF
# Setup zsh-autosuggestions # Setup zsh-autosuggestions
source $DIR/autosuggestions.zsh source $DIR/autosuggestions.zsh