diff --git a/.zsh-autosuggestionsrc b/.zsh-autosuggestionsrc new file mode 100755 index 0000000..b016456 --- /dev/null +++ b/.zsh-autosuggestionsrc @@ -0,0 +1,13 @@ +# 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 diff --git a/alt-install b/alt-install new file mode 100755 index 0000000..bdc737f --- /dev/null +++ b/alt-install @@ -0,0 +1,73 @@ +#!/bin/bash +# An alternative install script for zsh-autocomplete. +# +DESCRIPTION="this script adds/removes a +.zsh-autosuggestionsrc reference to your .zshrc file." +ZSHRC="" + +function usage() +{ + echo $0 : $DESCRIPTION + echo "Usage" + echo -e "\t" $0 " install : attempts to install" + echo -e "\t" $0 " uninstall : attempts to uninstall" + exit 1 +} + +function install() +{ + PATH_TO_RC="source "$(pwd)"/.zsh-autosuggestionsrc" + # check if line exists in zshrc, add it if missing + if grep -Fxq "$PATH_TO_RC" "$ZSHRC" + then + echo "currently installed, see $ZSHRC" + else + echo "Backing up $ZSHRC to $ZSHRC.bak" + cp "$ZSHRC" "$ZSHRC.bak" + echo "Adding $PATH_TO_RC to $ZSHRC" + echo "$PATH_TO_RC" >> "$ZSHRC" + fi +} + +function uninstall() +{ + PATH_TO_RC="source "$(pwd)"/.zsh-autosuggestionsrc" + # check if line exists in zshrc, remove if preset + if grep -Fxq "$PATH_TO_RC" "$ZSHRC" + then + echo "Removing $PATH_TO_RC from $ZSHRC" + grep -v "$PATH_TO_RC" "$ZSHRC" > "tmp-zsh-autosuggestion" + cat "tmp-zsh-autosuggestion" > "$ZSHRC" + rm "tmp-zsh-autosuggestion" + else + echo "not currently installed, see $ZSHRC" + fi +} + +function get_zhsrc() +{ + # attempt to find a .zshrc + # check if it exists and writeable + if [ -w "$HOME/.zshrc" ] ; then + ZSHRC="$HOME/.zshrc" + elif [ -w "$ZDOTDIR/.zshrc" ] ; then + ZSHRC="$ZDOTDIR/.zshrc" + else + echo "Cannot find .zshrc " + exit -1 + fi +} + +function main() +{ + if [ "$1" == "install" ] ; then + get_zhsrc + install "$@" + elif [ "$1" == "uninstall" ] ; then + get_zhsrc + uninstall "$@" + else + usage + fi +} +main "$@" # $@ passes args to main.