diff options
Diffstat (limited to 'dot-oh-my-zsh/custom/plugins/fzf/uninstall')
| m--------- | dot-oh-my-zsh | 0 | ||||
| -rwxr-xr-x | dot-oh-my-zsh/custom/plugins/fzf/uninstall | 113 |
2 files changed, 0 insertions, 113 deletions
diff --git a/dot-oh-my-zsh b/dot-oh-my-zsh new file mode 160000 +Subproject 6fe84bf5c82da7b1f6d7c5ec3e5c447721ac8ce diff --git a/dot-oh-my-zsh/custom/plugins/fzf/uninstall b/dot-oh-my-zsh/custom/plugins/fzf/uninstall deleted file mode 100755 index 4e587211..00000000 --- a/dot-oh-my-zsh/custom/plugins/fzf/uninstall +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash - -xdg=0 -prefix='~/.fzf' -prefix_expand=~/.fzf -fish_dir=${XDG_CONFIG_HOME:-$HOME/.config}/fish - -help() { - cat << EOF -usage: $0 [OPTIONS] - - --help Show this message - --xdg Remove files generated under \$XDG_CONFIG_HOME/fzf -EOF -} - -for opt in "$@"; do - case $opt in - --help) - help - exit 0 - ;; - --xdg) - xdg=1 - prefix='"${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf' - prefix_expand=${XDG_CONFIG_HOME:-$HOME/.config}/fzf/fzf - ;; - *) - echo "unknown option: $opt" - help - exit 1 - ;; - esac -done - -ask() { - while true; do - read -p "$1 ([y]/n) " -r - REPLY=${REPLY:-"y"} - if [[ $REPLY =~ ^[Yy]$ ]]; then - return 0 - elif [[ $REPLY =~ ^[Nn]$ ]]; then - return 1 - fi - done -} - -remove() { - echo "Remove $1" - rm -f "$1" -} - -remove_line() { - src=$1 - echo "Remove from $1:" - - shift - line_no=1 - match=0 - 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 - echo " - Line #$line_no: $content" - [ "$content" = "$1" ] || ask " - Remove?" - if [ $? -eq 0 ]; then - temp=$(mktemp) - awk -v n=$line_no 'NR == n {next} {print}' "$src" > "$temp" && - cat "$temp" > "$src" && rm -f "$temp" || break - echo " - Removed" - else - echo " - Skipped" - line_no=$(( line_no + 1 )) - fi - done - [ $match -eq 0 ] && echo " - Nothing found" - echo -} - -for shell in bash zsh; do - shell_config=${prefix_expand}.${shell} - remove "${shell_config}" - remove_line ~/.${shell}rc \ - "[ -f ${prefix}.${shell} ] && source ${prefix}.${shell}" \ - "source ${prefix}.${shell}" -done - -bind_file="${fish_dir}/functions/fish_user_key_bindings.fish" -if [ -f "$bind_file" ]; then - remove_line "$bind_file" "fzf_key_bindings" -fi - -if [ -d "${fish_dir}/functions" ]; then - remove "${fish_dir}/functions/fzf.fish" - remove "${fish_dir}/functions/fzf_key_bindings.fish" - - if [ -z "$(ls -A "${fish_dir}/functions")" ]; then - rmdir "${fish_dir}/functions" - else - echo "Can't delete non-empty directory: \"${fish_dir}/functions\"" - fi -fi - -config_dir=$(dirname "$prefix_expand") -if [[ "$xdg" = 1 ]] && [[ "$config_dir" = */fzf ]] && [[ -d "$config_dir" ]]; then - rmdir "$config_dir" -fi |
