zsh-autosuggestions/install

39 lines
1 KiB
Text
Raw Normal View History

2015-02-22 20:45:25 +01:00
#!/bin/bash
2014-11-21 22:51:19 +01:00
# 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
2015-01-23 23:38:46 +01:00
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
2014-11-21 22:51:19 +01:00
# appends the string to ~/.zshrc file
cat >> ~/.zshrc << EOF
# Setup zsh-autosuggestions
source $DIR/autosuggestions.zsh
# Enable autosuggestions automatically
zle-line-init() {
zle autosuggest-start
}
zle -N zle-line-init
# use ctrl+t to toggle autosuggestions(hopefully this wont be needed as
# zsh-autosuggestions is designed to be unobtrusive)
bindkey '^T' autosuggest-toggle
EOF
echo "\nSetup completed successfully!\n"
exit 0