mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-11 00:10:08 +00:00
feat(wd): update to latest upstream release (#11235)
Based on https://github.com/mfaerevaag/wd/releases/tag/v0.5.2
This commit is contained in:
parent
3eda3e5650
commit
4806f75569
2 changed files with 21 additions and 5 deletions
|
@ -1,12 +1,12 @@
|
||||||
# wd
|
# wd
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
|
[![Build Status](https://github.com/mfaerevaag/wd/actions/workflows/test.yml/badge.svg)](https://github.com/mfaerevaag/wd/actions)
|
||||||
|
|
||||||
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`.
|
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`.
|
||||||
Why?
|
Why?
|
||||||
Because `cd` seems inefficient when the folder is frequently visited or has a long path.
|
Because `cd` seems inefficient when the folder is frequently visited or has a long path.
|
||||||
|
|
||||||
![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
|
![Demo](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@ In your `.zshrc`:
|
||||||
antibody bundle mfaerevaag/wd
|
antibody bundle mfaerevaag/wd
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### [Fig](https://fig.io)
|
||||||
|
|
||||||
|
Install `wd` here: [![Fig plugin store](https://fig.io/badges/install-with-fig.svg)](https://fig.io/plugins/other/wd_mfaerevaag)
|
||||||
|
|
||||||
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
|
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
|
||||||
|
|
||||||
1. Install from the AUR
|
1. Install from the AUR
|
||||||
|
|
|
@ -163,6 +163,7 @@ wd_add()
|
||||||
{
|
{
|
||||||
local point=$1
|
local point=$1
|
||||||
local force=$2
|
local force=$2
|
||||||
|
cmdnames=(add rm show list ls path clean help)
|
||||||
|
|
||||||
if [[ $point == "" ]]
|
if [[ $point == "" ]]
|
||||||
then
|
then
|
||||||
|
@ -178,6 +179,9 @@ wd_add()
|
||||||
elif [[ $point =~ : ]] || [[ $point =~ / ]]
|
elif [[ $point =~ : ]] || [[ $point =~ / ]]
|
||||||
then
|
then
|
||||||
wd_exit_fail "Warp point contains illegal character (:/)"
|
wd_exit_fail "Warp point contains illegal character (:/)"
|
||||||
|
elif (($cmdnames[(Ie)$point]))
|
||||||
|
then
|
||||||
|
wd_exit_fail "Warp point name cannot be a wd command (see wd -h for a full list)"
|
||||||
elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
|
elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
|
||||||
then
|
then
|
||||||
wd_remove "$point" > /dev/null
|
wd_remove "$point" > /dev/null
|
||||||
|
@ -185,7 +189,7 @@ wd_add()
|
||||||
if (whence sort >/dev/null); then
|
if (whence sort >/dev/null); then
|
||||||
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
|
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
|
||||||
# use 'cat' below to ensure we respect $WD_CONFIG as a symlink
|
# use 'cat' below to ensure we respect $WD_CONFIG as a symlink
|
||||||
command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" > "$WD_CONFIG" && command rm "${config_tmp}"
|
command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" >| "$WD_CONFIG" && command rm "${config_tmp}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wd_export_static_named_directories
|
wd_export_static_named_directories
|
||||||
|
@ -214,7 +218,7 @@ wd_remove()
|
||||||
then
|
then
|
||||||
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
|
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
|
||||||
# Copy and delete in two steps in order to preserve symlinks
|
# Copy and delete in two steps in order to preserve symlinks
|
||||||
if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" > "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp"
|
if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" >| "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp"
|
||||||
then
|
then
|
||||||
wd_print_msg "$WD_GREEN" "Warp point removed"
|
wd_print_msg "$WD_GREEN" "Warp point removed"
|
||||||
else
|
else
|
||||||
|
@ -251,7 +255,7 @@ wd_list_all()
|
||||||
then
|
then
|
||||||
arr=(${(s,:,)line})
|
arr=(${(s,:,)line})
|
||||||
key=${arr[1]}
|
key=${arr[1]}
|
||||||
val=${arr[2]}
|
val=${line#"${arr[1]}:"}
|
||||||
|
|
||||||
if [[ -z $wd_quiet_mode ]]
|
if [[ -z $wd_quiet_mode ]]
|
||||||
then
|
then
|
||||||
|
@ -389,6 +393,11 @@ else
|
||||||
wd_export_static_named_directories
|
wd_export_static_named_directories
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# disable extendedglob for the complete wd execution time
|
||||||
|
setopt | grep -q extendedglob
|
||||||
|
wd_extglob_is_set=$?
|
||||||
|
[[ $wd_extglob_is_set ]] && setopt noextendedglob
|
||||||
|
|
||||||
# load warp points
|
# load warp points
|
||||||
typeset -A points
|
typeset -A points
|
||||||
while read -r line
|
while read -r line
|
||||||
|
@ -475,6 +484,9 @@ fi
|
||||||
# if not, next time warp will pick up variables from this run
|
# if not, next time warp will pick up variables from this run
|
||||||
# remember, there's no sub shell
|
# remember, there's no sub shell
|
||||||
|
|
||||||
|
[[ $wd_extglob_is_set ]] && setopt extendedglob
|
||||||
|
|
||||||
|
unset wd_extglob_is_set
|
||||||
unset wd_warp
|
unset wd_warp
|
||||||
unset wd_add
|
unset wd_add
|
||||||
unset wd_remove
|
unset wd_remove
|
||||||
|
|
Loading…
Reference in a new issue