Update uninstall script

pull/45/head
Junegunn Choi 10 years ago
parent 459c332351
commit f37be006c3

@ -345,7 +345,7 @@ Finished. Restart your shell or reload config file.
EOF EOF
[ $has_fish -eq 1 ] && echo " fzf_key_bindings # fish"; cat << EOF [ $has_fish -eq 1 ] && echo " fzf_key_bindings # fish"; cat << EOF
To uninstall fzf, simply remove the added lines. Use uninstall script to remove fzf.
For more information, see: https://github.com/junegunn/fzf For more information, see: https://github.com/junegunn/fzf
EOF EOF

@ -1,52 +1,42 @@
#!/bin/bash #!/bin/bash
remove_line() { remove_line() {
echo "Remove from $2:" src=$(readlink "$2")
echo " - $1" if [ $? -eq 0 ]; then
echo "Remove from $2 ($src):"
i=$(grep -c "$1" "$2") else
if [ $i -eq 0 ] src=$2
then echo "Remove from $2:"
echo " - Nothing found"
fi fi
echo " - $1"
while [ $i -gt 0 ]
do changed=0
line=$(grep -m1 -nF "$1" "$2") while [ 1 ]; do
lineNumber=$(grep -m1 -nF "$1" "$2" | sed 's/:.*//') line=$(grep -m1 -nF "$1" "$src") || break
if [ -n "$lineNumber" ]; then line_no=$(sed 's/:.*//' <<< "$line")
echo " - Remove line ($line)" echo " - Remove line ($line)"
awk -v n=$lineNumber 'NR == n {next} {print}' $2 > $2.bak && mv $2.bak $2 awk -v n=$line_no 'NR == n {next} {print}' "$src" > "$src.bak" &&
else mv "$src.bak" "$src" || break
echo " - Nothing found" changed=1
fi
i=`expr $i - 1`
done done
[ $changed -eq 0 ] && echo " - Nothing found"
echo echo
} }
for shell in bash zsh; do for shell in bash zsh; do
if [ -f ~/.fzf.${shell} ] rm -f ~/.fzf.${shell}
then
rm ~/.fzf.${shell}
fi
remove_line "source ~/.fzf.${shell}" ~/.${shell}rc 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 done
if [ -d ~/.config/fish/functions ] bind_file=~/.config/fish/functions/fish_user_key_bindings.fish
then if [ -f "$bind_file" ]; then
if [ -f ~/.config/fish/functions/fzf.fish ] remove_line "fzf_key_bindings" "$bind_file"
then fi
rm ~/.config/fish/functions/fzf.fish
fi if [ -d ~/.config/fish/functions ]; then
rm -f ~/.config/fish/functions/fzf.fish
if [ "$(ls -A ~/.config/fish/functions)" ] if [ "$(ls -A ~/.config/fish/functions)" ]; then
then
echo "Can't delete non-empty directory: \"~/.config/fish/functions\"" echo "Can't delete non-empty directory: \"~/.config/fish/functions\""
else else
rmdir ~/.config/fish/functions rmdir ~/.config/fish/functions

Loading…
Cancel
Save