fzf/uninstall

46 lines
1.0 KiB
Plaintext
Raw Normal View History

2014-05-20 08:17:03 -04:00
#!/bin/bash
remove_line() {
2014-05-20 12:14:21 -04:00
src=$(readlink "$2")
if [ $? -eq 0 ]; then
echo "Remove from $2 ($src):"
else
src=$2
echo "Remove from $2:"
2014-05-20 08:17:03 -04:00
fi
2014-05-20 12:14:21 -04:00
echo " - $1"
changed=0
while [ 1 ]; do
line=$(grep -m1 -nF "$1" "$src") || break
line_no=$(sed 's/:.*//' <<< "$line")
echo " - Remove line ($line)"
awk -v n=$line_no 'NR == n {next} {print}' "$src" > "$src.bak" &&
mv "$src.bak" "$src" || break
changed=1
2014-05-20 11:05:02 -04:00
done
2014-05-20 12:14:21 -04:00
[ $changed -eq 0 ] && echo " - Nothing found"
2014-05-20 08:17:03 -04:00
echo
}
for shell in bash zsh; do
2014-05-20 12:14:21 -04:00
rm -f ~/.fzf.${shell}
2014-05-20 08:17:03 -04:00
remove_line "source ~/.fzf.${shell}" ~/.${shell}rc
done
2014-05-20 12:14:21 -04:00
bind_file=~/.config/fish/functions/fish_user_key_bindings.fish
if [ -f "$bind_file" ]; then
remove_line "fzf_key_bindings" "$bind_file"
fi
if [ -d ~/.config/fish/functions ]; then
rm -f ~/.config/fish/functions/fzf.fish
2014-05-20 11:05:02 -04:00
2014-05-20 12:14:21 -04:00
if [ "$(ls -A ~/.config/fish/functions)" ]; then
2014-05-20 11:05:02 -04:00
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