Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't clobber PWD in wd_show #139

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions wd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ wd_print_msg()
then
local color="${1:-$WD_BLUE}" # Default to blue if no color is provided
local msg="$2"

if [[ -z "$msg" ]]; then
print "${WD_RED}*${WD_NOC} Could not print message. Sorry!"
else
Expand Down Expand Up @@ -344,6 +344,7 @@ wd_path()
wd_show()
{
local name_arg=$1
local show_pwd
# if there's an argument we look up the value
if [[ -n $name_arg ]]
then
Expand All @@ -358,20 +359,20 @@ wd_show()
local wd_matches
wd_matches=()
# do a reverse lookup to check whether PWD is in $points
PWD="${PWD/$HOME/~}"
if [[ ${points[(r)$PWD]} == "$PWD" ]]
show_pwd="${PWD/$HOME/~}"
if [[ ${points[(r)$show_pwd]} == "$show_pwd" ]]
then
for name in ${(k)points}
do
if [[ $points[$name] == "$PWD" ]]
if [[ $points[$name] == "$show_pwd" ]]
then
wd_matches[$(($#wd_matches+1))]=$name
fi
done

wd_print_msg "$WD_BLUE" "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
else
wd_print_msg "$WD_YELLOW" "No warp point to $(echo "$PWD" | sed "s:$HOME:~:")"
wd_print_msg "$WD_YELLOW" "No warp point to $show_pwd"
fi
fi
}
Expand Down