Last active
April 1, 2020 09:06
-
-
Save Lutzifer/68ec093c063124de89dd9f63ae2e1fb4 to your computer and use it in GitHub Desktop.
Interactive version of zsh's wd (warp/working directory) feature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
wd () { | |
source "$ZSH/plugins/wd/wd.sh" | |
} | |
CHOICES=( $(wd list | cut -d ">" -f 1 | sed "s/ -//g" | sed 's/^ *//g' | sed 's/ *$//g' | tail -n +2 | awk '{printf $0 " "}') ) | |
PS3="Please enter your choice: " | |
select ANSWER in "${CHOICES[@]}"; do | |
for ITEM in "${CHOICES[@]}"; do | |
if [[ $ITEM == $ANSWER ]]; then | |
break 2 | |
fi | |
done | |
done | |
TARGET_PATH="$(wd list | grep "$ANSWER " | cut -d ">" -f 2 | sed "s/ -//g" | sed 's/^ *//g' | sed 's/ *$//g' | awk '{printf $0 " "}')" | |
REAL_PATH="$(eval echo $TARGET_PATH)" | |
echo $REAL_PATH | |
cd $REAL_PATH | |
ls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add an alias like
alias iwd='. ~/iwd.sh'
and invoke it withiwd
for interactive selection.