Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
7d9648e6
Commit
7d9648e6
authored
Nov 23, 2015
by
Markus Faerevaag
Browse files
[wd] update minor version (v0.4.2)
parent
22632aac
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/wd/wd.sh
View file @
7d9648e6
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd
# @github.com/mfaerevaag/wd
# version
# version
readonly
WD_VERSION
=
0.4
readonly
WD_VERSION
=
0.4
.2
# colors
# colors
readonly
WD_BLUE
=
"
\0
33[96m"
readonly
WD_BLUE
=
"
\0
33[96m"
...
@@ -143,7 +143,7 @@ wd_warp()
...
@@ -143,7 +143,7 @@ wd_warp()
fi
fi
elif
[[
${
points
[
$point
]
}
!=
""
]]
elif
[[
${
points
[
$point
]
}
!=
""
]]
then
then
cd
${
points
[
$point
]
}
cd
${
points
[
$point
]
/#\~/
$HOME
}
else
else
wd_exit_fail
"Unknown warp point '
${
point
}
'"
wd_exit_fail
"Unknown warp point '
${
point
}
'"
fi
fi
...
@@ -169,7 +169,7 @@ wd_add()
...
@@ -169,7 +169,7 @@ wd_add()
elif
[[
${
points
[
$2
]
}
==
""
]]
||
$force
elif
[[
${
points
[
$2
]
}
==
""
]]
||
$force
then
then
wd_remove
$point
>
/dev/null
wd_remove
$point
>
/dev/null
printf
"%q:%s
\n
"
"
${
point
}
"
"
${
PWD
}
"
>>
$WD_CONFIG
printf
"%q:%s
\n
"
"
${
point
}
"
"
${
PWD
/#
$HOME
/~
}
"
>>
$WD_CONFIG
wd_print_msg
$WD_GREEN
"Warp point added"
wd_print_msg
$WD_GREEN
"Warp point added"
...
@@ -203,6 +203,21 @@ wd_list_all()
...
@@ -203,6 +203,21 @@ wd_list_all()
{
{
wd_print_msg
$WD_BLUE
"All warp points:"
wd_print_msg
$WD_BLUE
"All warp points:"
entries
=
$(
sed
"s:
${
HOME
}
:~:g"
$WD_CONFIG
)
max_warp_point_length
=
0
while
IFS
=
read
-r
line
do
arr
=(
${
(s,
:,
)line
}
)
key
=
${
arr
[1]
}
length
=
${#
key
}
if
[[
length
-gt
max_warp_point_length
]]
then
max_warp_point_length
=
$length
fi
done
<<<
$entries
while
IFS
=
read
-r
line
while
IFS
=
read
-r
line
do
do
if
[[
$line
!=
""
]]
if
[[
$line
!=
""
]]
...
@@ -213,16 +228,16 @@ wd_list_all()
...
@@ -213,16 +228,16 @@ wd_list_all()
if
[[
-z
$wd_quiet_mode
]]
if
[[
-z
$wd_quiet_mode
]]
then
then
printf
"%
20
s -> %s
\n
"
$key
$val
printf
"%
${
max_warp_point_length
}
s -> %s
\n
"
$key
$val
fi
fi
fi
fi
done
<<<
$
(
sed
"s:
${
HOME
}
:~:g"
$WD_CONFIG
)
done
<<<
$
entries
}
}
wd_ls
()
wd_ls
()
{
{
wd_getdir
$1
wd_getdir
$1
ls
$dir
ls
$
{
dir
/#\~/
$HOME
}
}
}
wd_path
()
wd_path
()
...
@@ -248,6 +263,7 @@ wd_show()
...
@@ -248,6 +263,7 @@ wd_show()
local
wd_matches
local
wd_matches
wd_matches
=()
wd_matches
=()
# do a reverse lookup to check whether PWD is in $points
# do a reverse lookup to check whether PWD is in $points
PWD
=
"
${
PWD
/
$HOME
/~
}
"
if
[[
${
points
[(r)
$PWD
]
}
==
$PWD
]]
if
[[
${
points
[(r)
$PWD
]
}
==
$PWD
]]
then
then
for
name
in
${
(k)points
}
for
name
in
${
(k)points
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment