fzf/uninstall

56 lines
1.1 KiB
Plaintext
Raw Normal View History

2014-05-20 08:17:03 -04:00
#!/bin/bash
remove_line() {
echo "Remove from $2:"
echo " - $1"
2014-05-20 11:05:02 -04:00
i=$(grep -c "$1" "$2")
if [ $i -eq 0 ]
then
2014-05-20 08:17:03 -04:00
echo " - Nothing found"
fi
2014-05-20 11:05:02 -04:00
while [ $i -gt 0 ]
do
line=$(grep -m1 -nF "$1" "$2")
lineNumber=$(grep -m1 -nF "$1" "$2" | sed 's/:.*//')
if [ -n "$lineNumber" ]; then
echo " - Remove line ($line)"
awk -v n=$lineNumber 'NR == n {next} {print}' $2 > $2.bak && mv $2.bak $2
else
echo " - Nothing found"
fi
i=`expr $i - 1`
done
2014-05-20 08:17:03 -04:00
echo
}
for shell in bash zsh; do
if [ -f ~/.fzf.${shell} ]
then
rm ~/.fzf.${shell}
fi
remove_line "source ~/.fzf.${shell}" ~/.${shell}rc
bind_file="~/.config/fish/functions/fish_user_key_bindings.fish"
if [ -f $bind_file ]
then
remove_line "fzf_key_bindings" "$bind_file"
fi
done
2014-05-20 11:05:02 -04:00
if [ -d ~/.config/fish/functions ]
2014-05-20 08:17:03 -04:00
then
2014-05-20 11:05:02 -04:00
if [ -f ~/.config/fish/functions/fzf.fish ]
then
rm ~/.config/fish/functions/fzf.fish
fi
if [ "$(ls -A ~/.config/fish/functions)" ]
then
echo "Can't delete non-empty directory: \"~/.config/fish/functions\""
else
rmdir ~/.config/fish/functions
fi
2014-05-20 08:17:03 -04:00
fi
2014-05-20 11:05:02 -04:00