File tree Expand file tree Collapse file tree 5 files changed +28
-12
lines changed Expand file tree Collapse file tree 5 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -59,4 +59,10 @@ autoload -U +X bashcompinit && bashcompinit
5959
6060## Usage
6161
62- TBD
62+ Type ` up ` followed by pressing the tab key twice to get a list of parent directory names.
63+
64+ ``` sh
65+ up < tab><tab>
66+ ```
67+
68+ Type ` up `
Original file line number Diff line number Diff line change 55 local -r pwd_without_leading_slash=${PWD: 1}
66
77 local basenames=()
8- while IFS= read -r -d/; do
9- basenames+=(" $REPLY " )
10- done <<< " $pwd_without_leading_slash"
8+ while IFS= read -r -d/; do
9+ basenames+=(" $REPLY " )
10+ done <<< " $pwd_without_leading_slash"
1111
1212 [[ $PWD != / ]] && basenames+=(/)
1313
Original file line number Diff line number Diff line change @@ -26,14 +26,14 @@ assert_contains() {
2626}
2727
2828@test ' _up should not autocomplete the current directory name when given no arguments' {
29- mkdir -p " ${BATS_TEST_TMPDIR} " /src/main/java
30- cd " ${BATS_TEST_TMPDIR} " /src/main/java
29+ mkdir -p " ${BATS_TEST_TMPDIR} " /src/main/java
30+ cd " ${BATS_TEST_TMPDIR} " /src/main/java
3131
32- COMP_WORDS=(up)
33- COMP_CWORD=1
34- _up
32+ COMP_WORDS=(up)
33+ COMP_CWORD=1
34+ _up
3535
36- ! assert_contains java " ${COMPREPLY[@]} "
36+ ! assert_contains java " ${COMPREPLY[@]} "
3737}
3838
3939@test ' _up should autocomplete the parent directory name' {
Original file line number Diff line number Diff line change 55 [[ $1 == / ]] && cd / && return
66
77 # shellcheck disable=SC2164
8- cd " ${PWD% " ${PWD##*/ " $1 " } " } "
8+ cd " ${PWD% " ${PWD##*/ " $1 " / } " } "
99}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ load up
1111 [[ $PWD == " ${BATS_TEST_TMPDIR} /src/main" ]]
1212}
1313
14- @test ' up should jump to the parent directory ending on the given name' {
14+ @test ' up should jump to the parent directory with the given name' {
1515 local -r path=${BATS_TEST_TMPDIR} /src/main/java
1616 mkdir -p " $path "
1717 cd " $path "
@@ -48,3 +48,13 @@ load up
4848
4949 [[ $PWD == " ${BATS_TEST_TMPDIR} /com/git hub" ]]
5050}
51+
52+ @test ' up should jump to the parent directory with the exact given name' {
53+ local -r path=${BATS_TEST_TMPDIR} /java/build/libs/java-0.0.1-SNAPSHOT
54+ mkdir -p " $path "
55+ cd " $path "
56+
57+ up java
58+
59+ [[ $PWD == " ${BATS_TEST_TMPDIR} /java" ]]
60+ }
You can’t perform that action at this time.
0 commit comments