Diff
1diff --git a/.github/dependencies.yml b/.github/dependencies.yml
2index a105f440d1541a11df3c2c2260123a548d9a27b5..6ae97ad4e5ecc36e73a8fa88d5f3298c0a8b615b 100644
3--- a/.github/dependencies.yml
4+++ b/.github/dependencies.yml
5@@ -39,7 +39,7 @@ dependencies:
6 plugins/wd:
7 repo: mfaerevaag/wd
8 branch: master
9- version: tag:v0.6.0
10+ version: tag:v0.6.1
11 precopy: |
12 set -e
13 rm -r test
14diff --git a/plugins/wd/README.md b/plugins/wd/README.md
15index 0ad74e8052165f8982bbd65e25b35c9dd8b57da5..0c71c05656f9b09779f8ed5b7d1dbdb0196bd622 100644
16--- a/plugins/wd/README.md
17+++ b/plugins/wd/README.md
18@@ -57,6 +57,24 @@ wd() {
19 }
20 ```
21
22+### [Home Manager](https://github.com/nix-community/home-manager)
23+
24+Add the following to your `home.nix` then run `home-manager switch`:
25+
26+```nix
27+programs.zsh.plugins = [
28+ {
29+ name = "wd";
30+ src = pkgs.fetchFromGitHub {
31+ owner = "mfaerevaag";
32+ repo = "wd";
33+ rev = "v0.5.2";
34+ sha256 = "sha256-4yJ1qhqhNULbQmt6Z9G22gURfDLe30uV1ascbzqgdhg=";
35+ };
36+ }
37+];
38+```
39+
40 ### [zplug](https://github.com/zplug/zplug)
41
42 ```zsh
43@@ -119,6 +137,14 @@ Also, you may have to force a rebuild of `zcompdump` by running:
44 rm -f ~/.zcompdump; compinit
45 ```
46
47+## Browse
48+
49+If you want to make use of the `fzf`-powered browse feature to fuzzy search through all your warp points, set up a keybind in your `.zshrc`:
50+
51+```zsh
52+bindkey '^G' wd_browse
53+```
54+
55 ## Usage
56
57 * Add warp point to current working directory:
58@@ -153,7 +179,7 @@ wd ..
59 wd ...
60 ```
61
62-This is a wrapper for the zsh's `dirs` function.
63+This is a wrapper for the zsh's `dirs` function.
64 _You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)._
65
66 * Remove warp point:
67diff --git a/plugins/wd/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh
68index ca2ca7c65c127e0b5f9fe5cf880f25f4b9745a12..9e0c7ff13ce3378506c97c6f39ea2c2c6e2ad556 100644
69--- a/plugins/wd/wd.plugin.zsh
70+++ b/plugins/wd/wd.plugin.zsh
71@@ -8,8 +8,13 @@
72 # @github.com/mfaerevaag/wd
73
74 # Handle $0 according to the standard:
75-# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
76+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
77 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
78 0="${${(M)0:#/*}:-$PWD/$0}"
79
80 eval "wd() { source '${0:A:h}/wd.sh' }"
81+wd > /dev/null
82+# Register the function as a Zsh widget
83+zle -N wd_browse
84+# Bind the widget to a key combination
85+bindkey '^G' wd_browse
86diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
87old mode 100644
88new mode 100755
89index 840e92d6159e9debc74d6c77a59dce47ac2281eb..c4f422cbffaa65f3a1d520a9142c8e94d178a733
90--- a/plugins/wd/wd.sh
91+++ b/plugins/wd/wd.sh
92@@ -8,7 +8,7 @@
93 # @github.com/mfaerevaag/wd
94
95 # version
96-readonly WD_VERSION=0.5.0
97+readonly WD_VERSION=0.6.1
98
99 # colors
100 readonly WD_BLUE="\033[96m"
101@@ -57,12 +57,11 @@ wd_print_msg()
102 {
103 if [[ -z $wd_quiet_mode ]]
104 then
105- local color=$1
106- local msg=$2
107+ local color="${1:-$WD_BLUE}" # Default to blue if no color is provided
108+ local msg="$2"
109
110- if [[ $color == "" || $msg == "" ]]
111- then
112- print " ${WD_RED}*${WD_NOC} Could not print message. Sorry!"
113+ if [[ -z "$msg" ]]; then
114+ print "${WD_RED}*${WD_NOC} Could not print message. Sorry!"
115 else
116 print " ${color}*${WD_NOC} ${msg}"
117 fi
118@@ -230,6 +229,20 @@ wd_remove()
119 done
120 }
121
122+wd_browse() {
123+ if ! command -v fzf >/dev/null; then
124+ echo "This functionality requires fzf. Please install fzf first."
125+ return 1
126+ fi
127+ local entries=("${(@f)$(sed "s:${HOME}:~:g" "$WD_CONFIG" | awk -F ':' '{print $1 " -> " $2}')}")
128+ local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 40% --reverse)
129+ if [[ -n $selected_entry ]]; then
130+ local selected_point="${selected_entry%% ->*}"
131+ selected_point=$(echo "$selected_point" | xargs)
132+ wd $selected_point
133+ fi
134+}
135+
136 wd_list_all()
137 {
138 wd_print_msg "$WD_BLUE" "All warp points:"
139@@ -396,7 +409,9 @@ fi
140 # disable extendedglob for the complete wd execution time
141 setopt | grep -q extendedglob
142 wd_extglob_is_set=$?
143-(( ! $wd_extglob_is_set )) && setopt noextendedglob
144+if (( wd_extglob_is_set == 0 )); then
145+ setopt noextendedglob
146+fi
147
148 # load warp points
149 typeset -A points
150@@ -436,6 +451,10 @@ else
151 wd_add "$2" "$wd_force_mode"
152 break
153 ;;
154+ "-b"|"browse")
155+ wd_browse
156+ break
157+ ;;
158 "-e"|"export")
159 wd_export_static_named_directories
160 break
161@@ -484,7 +503,9 @@ fi
162 # if not, next time warp will pick up variables from this run
163 # remember, there's no sub shell
164
165-(( ! $wd_extglob_is_set )) && setopt extendedglob
166+if (( wd_extglob_is_set == 0 )); then
167+ setopt extendedglob
168+fi
169
170 unset wd_extglob_is_set
171 unset wd_warp