summaryrefslogtreecommitdiffstats
path: root/uninstall
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2014-09-18 19:21:11 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2014-09-18 19:21:58 +0900
commit4c923a2d19f3b82e416644e28581fb78623c16b7 (patch)
treecc0cfcad16552b3e951ac17670a30b475b37f16f /uninstall
parent4ee85f11e8b3474ae5ea4a292799f849c5fd9c02 (diff)
[uninstall] Remove both patterns of source command (#97)
- `[ -f ~/.fzf.${shell} ] && source ~/.fzf.${shell}"` - `source ~/.fzf.${shell}"`
Diffstat (limited to 'uninstall')
-rwxr-xr-xuninstall24
1 files changed, 16 insertions, 8 deletions
diff --git a/uninstall b/uninstall
index 3cb3afef..aef61bf4 100755
--- a/uninstall
+++ b/uninstall
@@ -18,18 +18,24 @@ remove() {
}
remove_line() {
- src=$(readlink "$2")
+ src=$(readlink "$1")
if [ $? -eq 0 ]; then
- echo "Remove from $2 ($src):"
+ echo "Remove from $1 ($src):"
else
- src=$2
- echo "Remove from $2:"
+ src=$1
+ echo "Remove from $1:"
fi
+ shift
line_no=1
match=0
- while [ 1 ]; do
- line=$(sed -n "$line_no,\$p" "$src" | \grep -m1 -nF "$1") || break
+ while [ -n "$1" ]; do
+ line=$(sed -n "$line_no,\$p" "$src" | \grep -m1 -nF "$1")
+ if [ $? -ne 0 ]; then
+ shift
+ line_no=1
+ continue
+ fi
line_no=$(( $(sed 's/:.*//' <<< "$line") + line_no - 1 ))
content=$(sed 's/^[0-9]*://' <<< "$line")
match=1
@@ -50,12 +56,14 @@ remove_line() {
for shell in bash zsh; do
remove ~/.fzf.${shell}
- # remove_line "source ~/.fzf.${shell}" ~/.${shell}rc
+ remove_line ~/.${shell}rc \
+ "[ -f ~/.fzf.${shell} ] && source ~/.fzf.${shell}" \
+ "source ~/.fzf.${shell}"
done
bind_file=~/.config/fish/functions/fish_user_key_bindings.fish
if [ -f "$bind_file" ]; then
- remove_line "fzf_key_bindings" "$bind_file"
+ remove_line "$bind_file" "fzf_key_bindings"
fi
if [ -d ~/.config/fish/functions ]; then