2343ad517d3439877e85c03846a38e4b3bf6d984

Author
ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(wd): update to v0.9.3 (#12954)

Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>

Diff

  1diff --git a/.github/dependencies.yml b/.github/dependencies.yml
  2index 02995d6cd24bd75015eaebded21c764cdead37d9..46e7727b8a8e7b0ac956e755717065691396c2bf 100644
  3--- a/.github/dependencies.yml
  4+++ b/.github/dependencies.yml
  5@@ -30,7 +30,7 @@ dependencies:
  6   plugins/wd:
  7     repo: mfaerevaag/wd
  8     branch: master
  9-    version: tag:v0.9.2
 10+    version: tag:v0.9.3
 11     precopy: |
 12       set -e
 13       rm -r test
 14diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
 15index 962ad9afa22f2615af9bf4c9d8b1b34fdddf3302..f8b27828f1162c8015c90f6df018dcfece460172 100755
 16--- a/plugins/wd/wd.sh
 17+++ b/plugins/wd/wd.sh
 18@@ -8,7 +8,7 @@
 19 # @github.com/mfaerevaag/wd
 20 
 21 # version
 22-readonly WD_VERSION=0.9.2
 23+readonly WD_VERSION=0.9.3
 24 
 25 # colors
 26 readonly WD_BLUE="\033[96m"
 27@@ -256,20 +256,47 @@ wd_remove()
 28 }
 29 
 30 wd_browse() {
 31+    # Check if fzf is installed
 32     if ! command -v fzf >/dev/null; then
 33-        echo "This functionality requires fzf. Please install fzf first."
 34+        wd_print_msg "$WD_RED" "This functionality requires fzf. Please install fzf first."
 35         return 1
 36     fi
 37+
 38+    # Ensure wd_config_file is properly set
 39+    if [[ -z $wd_config_file ]]; then
 40+        wd_config_file="${WD_CONFIG:-$HOME/.warprc}"
 41+    fi
 42+
 43+    # Check if config file exists
 44+    if [[ ! -f $wd_config_file ]]; then
 45+        wd_print_msg "$WD_RED" "Config file $wd_config_file does not exist. Please create it first."
 46+        return 1
 47+    fi
 48+
 49+    # Read entries from the config file
 50     local entries=("${(@f)$(sed "s:${HOME}:~:g" "$wd_config_file" | awk -F ':' '{print $1 " -> " $2}')}")
 51+    if [[ -z $entries ]]; then
 52+        wd_print_msg "$WD_YELLOW" "You don't have any warp points to browse"
 53+        return 1
 54+    fi
 55+
 56+    # Temp file for remove operations
 57     local script_path="${${(%):-%x}:h}"
 58     local wd_remove_output=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
 59+
 60+    # Create fzf bindings
 61     entries=("All warp points:" "Press enter to select. Press delete to remove" "${entries[@]}")
 62-    local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} "$script_path/wd.sh" rm {} > "$wd_remove_output")+abort"
 63+    local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} \"$script_path/wd.sh\" rm {} > \"$wd_remove_output\")+abort"
 64+
 65+    # Run fzf
 66     local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 100% --reverse --header-lines=2 --bind="$fzf_bind")
 67+
 68+    # Handle selection
 69     if [[ -e $wd_remove_output ]]; then
 70         cat "$wd_remove_output"
 71-        rm "$wd_remove_output"
 72+        rm -f "$wd_remove_output"
 73     fi
 74+
 75     if [[ -n $selected_entry ]]; then
 76         local selected_point="${selected_entry%% ->*}"
 77         selected_point=$(echo "$selected_point" | xargs)
 78@@ -278,14 +305,26 @@ wd_browse() {
 79 }
 80 
 81 wd_browse_widget() {
 82-  if [[ -e $wd_config_file ]]; then
 83+    # Ensure wd_config_file is properly set
 84+    if [[ -z $wd_config_file ]]; then
 85+        wd_config_file="${WD_CONFIG:-$HOME/.warprc}"
 86+    fi
 87+
 88+    # Check if config file exists
 89+    if [[ ! -f $wd_config_file ]]; then
 90+        wd_print_msg "$WD_RED" "Config file $wd_config_file does not exist. Please create it first."
 91+        return 1
 92+    fi
 93+
 94+    # Call wd_browse to handle the selection
 95     wd_browse
 96+
 97+    # Restore the zsh buffer and cursor after running wd_browse
 98     saved_buffer=$BUFFER
 99     saved_cursor=$CURSOR
100     BUFFER=
101     zle redisplay
102     zle accept-line
103-  fi
104 }
105 
106 wd_restore_buffer() {
107@@ -578,7 +617,7 @@ unset wd_print_msg
108 unset wd_yesorno
109 unset wd_print_usage
110 unset wd_alt_config
111-unset wd_config_file
112+#unset wd_config_file do not unset this - breaks keybind
113 unset wd_quiet_mode
114 unset wd_print_version
115 unset wd_force_mode