f6b3fc84d192274f245a7322c3994767c5e68691
- Author
- ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/.github/dependencies.yml b/.github/dependencies.yml
2index 6ae97ad4e5ecc36e73a8fa88d5f3298c0a8b615b..d3b26936180be6a48507113787fb54c8b3269cff 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.1
10+ version: tag:v0.7.0
11 precopy: |
12 set -e
13 rm -r test
14diff --git a/plugins/wd/README.md b/plugins/wd/README.md
15index 0c71c05656f9b09779f8ed5b7d1dbdb0196bd622..bf19031f822411063d853d3c84e9e5c6fe63b87e 100644
16--- a/plugins/wd/README.md
17+++ b/plugins/wd/README.md
18@@ -142,7 +142,7 @@ rm -f ~/.zcompdump; compinit
19 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`:
20
21 ```zsh
22-bindkey '^G' wd_browse
23+bindkey ${FZF_WD_BINDKEY:-'^B'} fuzzy_wd_widget
24 ```
25
26 ## Usage
27@@ -158,6 +158,19 @@ If a warp point with the same name exists, use `wd add foo --force` to overwrite
28 **Note:** a warp point cannot contain colons, or consist of only spaces and dots.
29 The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
30
31+* Add warp point to any directory with default name:
32+
33+```zsh
34+wd addcd /foo/ bar
35+```
36+
37+* Add warp point to any directory with a custom name:
38+
39+```zsh
40+wd addcd /foo/
41+```
42+
43+
44 You can omit point name to automatically use the current directory's name instead.
45
46 * From any directory, warp to `foo` with:
47diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
48index 52ecb12e6a7e6305e3625e4354fddbe41e4fc664..46b032f7800d4208968e77c0f3bce57e16538948 100644
49--- a/plugins/wd/_wd.sh
50+++ b/plugins/wd/_wd.sh
51@@ -31,6 +31,7 @@ function _wd() {
52
53 commands=(
54 'add:Adds the current working directory to your warp points'
55+ 'addcd:Adds a directory to your warp points'
56 'add!:Overwrites existing warp point'
57 'export:Export warp points as static named directories'
58 'rm:Removes the given warp point'
59@@ -63,6 +64,9 @@ function _wd() {
60 add)
61 _message 'Write the name of your warp point' && ret=0
62 ;;
63+ addcd)
64+ _message 'Write the name of your path' && ret=0
65+ ;;
66 show)
67 _describe -t points "Warp points" warp_points && ret=0
68 ;;
69diff --git a/plugins/wd/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh
70index 9e0c7ff13ce3378506c97c6f39ea2c2c6e2ad556..9910cb968323b3f04a9e92e5e5995458eeed657b 100644
71--- a/plugins/wd/wd.plugin.zsh
72+++ b/plugins/wd/wd.plugin.zsh
73@@ -14,7 +14,8 @@
74
75 eval "wd() { source '${0:A:h}/wd.sh' }"
76 wd > /dev/null
77-# Register the function as a Zsh widget
78-zle -N wd_browse
79-# Bind the widget to a key combination
80-bindkey '^G' wd_browse
81+zle -N wd_browse_widget
82+zle -N wd_restore_buffer
83+autoload -Uz add-zle-hook-widget
84+add-zle-hook-widget line-init wd_restore_buffer
85+bindkey ${FZF_WD_BINDKEY:-'^B'} wd_browse_widget
86diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
87index c4f422cbffaa65f3a1d520a9142c8e94d178a733..160ab3be364682ceee8dfe9e4089d2729138fd2f 100755
88--- a/plugins/wd/wd.sh
89+++ b/plugins/wd/wd.sh
90@@ -8,7 +8,7 @@
91 # @github.com/mfaerevaag/wd
92
93 # version
94-readonly WD_VERSION=0.6.1
95+readonly WD_VERSION=0.7.0
96
97 # colors
98 readonly WD_BLUE="\033[96m"
99@@ -59,7 +59,7 @@ wd_print_msg()
100 then
101 local color="${1:-$WD_BLUE}" # Default to blue if no color is provided
102 local msg="$2"
103-
104+
105 if [[ -z "$msg" ]]; then
106 print "${WD_RED}*${WD_NOC} Could not print message. Sorry!"
107 else
108@@ -74,18 +74,20 @@ wd_print_usage()
109 Usage: wd [command] [point]
110
111 Commands:
112- <point> Warps to the directory specified by the warp point
113- <point> <path> Warps to the directory specified by the warp point with path appended
114- add <point> Adds the current working directory to your warp points
115- add Adds the current working directory to your warp points with current directory's name
116- rm <point> Removes the given warp point
117- rm Removes the given warp point with current directory's name
118- show <point> Print path to given warp point
119- show Print warp points to current directory
120- list Print all stored warp points
121- ls <point> Show files from given warp point (ls)
122- path <point> Show the path to given warp point (pwd)
123- clean Remove points warping to nonexistent directories (will prompt unless --force is used)
124+ <point> Warps to the directory specified by the warp point
125+ <point> <path> Warps to the directory specified by the warp point with path appended
126+ add <point> Adds the current working directory to your warp points
127+ add Adds the current working directory to your warp points with current directory's name
128+ addcd <path> Adds a path to your warp points with the directory's name
129+ addcd <path> <point> Adds a path to your warp points with a custom name
130+ rm <point> Removes the given warp point
131+ rm Removes the given warp point with current directory's name
132+ show <point> Print path to given warp point
133+ show Print warp points to current directory
134+ list Print all stored warp points
135+ ls <point> Show files from given warp point (ls)
136+ path <point> Show the path to given warp point (pwd)
137+ clean Remove points warping to nonexistent directories (will prompt unless --force is used)
138
139 -v | --version Print version
140 -d | --debug Exit after execution with exit codes (for testing)
141@@ -203,6 +205,28 @@ wd_add()
142 fi
143 }
144
145+wd_addcd() {
146+ local folder="$1"
147+ local point=$2
148+ local force=$3
149+ local currentdir=$PWD
150+
151+ if [[ -z "$folder" ]]; then
152+ wd_exit_fail "You must specify a path"
153+ return
154+ fi
155+
156+ if [[ ! -d "$folder" ]]; then
157+ wd_exit_fail "The directory does not exist"
158+ return
159+ fi
160+
161+ cd "$folder" || return
162+ wd_add "$point" "$force"
163+ cd "$currentdir" || return
164+}
165+
166+
167 wd_remove()
168 {
169 local point_list=$1
170@@ -235,7 +259,15 @@ wd_browse() {
171 return 1
172 fi
173 local entries=("${(@f)$(sed "s:${HOME}:~:g" "$WD_CONFIG" | awk -F ':' '{print $1 " -> " $2}')}")
174- local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 40% --reverse)
175+ local script_path="${${(%):-%x}:h}"
176+ local wd_remove_output=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
177+ local entries_with_headers=("All warp points:" "Press enter to select. Press delete to remove" "${entries[@]}")
178+ local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} "$script_path/wd.sh" rm {} > "$wd_remove_output")+abort"
179+ local fzf_command=$(printf '%s\n' "${entries_with_headers[@]}" | fzf --height 100% --reverse --header-lines=2 --bind="$fzf_bind")
180+ if [[ -e $wd_remove_output ]]; then
181+ cat "$wd_remove_output"
182+ rm "$wd_remove_output"
183+ fi
184 if [[ -n $selected_entry ]]; then
185 local selected_point="${selected_entry%% ->*}"
186 selected_point=$(echo "$selected_point" | xargs)
187@@ -243,6 +275,24 @@ wd_browse() {
188 fi
189 }