@@ -58,13 +58,19 @@ fi |
| 58 | 58 | r#" |
| 59 | 59 | # Jump function |
| 60 | 60 | {cmd}() {{ |
| 61 | | - local result |
| 62 | | - result=$(command gump query -- "$@") |
| 63 | | - if [[ -n "$result" ]]; then |
| 64 | | - builtin cd -- "$result" && __gump_hook |
| 61 | + if [[ $# -eq 0 ]]; then |
| 62 | + builtin cd ~ && __gump_hook |
| 63 | + elif [[ $# -eq 1 && "$1" == "-" ]]; then |
| 64 | + builtin cd - && __gump_hook |
| 65 | 65 | else |
| 66 | | - echo "gump: no match found" >&2 |
| 67 | | - return 1 |
| 66 | + local result |
| 67 | + result=$(command gump query -- "$@") |
| 68 | + if [[ -n "$result" ]]; then |
| 69 | + builtin cd -- "$result" && __gump_hook |
| 70 | + else |
| 71 | + echo "gump: no match found" >&2 |
| 72 | + return 1 |
| 73 | + fi |
| 68 | 74 | fi |
| 69 | 75 | }} |
| 70 | 76 | |
@@ -141,13 +147,19 @@ __gump_hook() { |
| 141 | 147 | r#" |
| 142 | 148 | # Jump function |
| 143 | 149 | {cmd}() {{ |
| 144 | | - local result |
| 145 | | - result=$(command gump query -- "$@") |
| 146 | | - if [[ -n "$result" ]]; then |
| 147 | | - builtin cd -- "$result" |
| 150 | + if [[ $# -eq 0 ]]; then |
| 151 | + builtin cd ~ |
| 152 | + elif [[ $# -eq 1 && "$1" == "-" ]]; then |
| 153 | + builtin cd - |
| 148 | 154 | else |
| 149 | | - echo "gump: no match found" >&2 |
| 150 | | - return 1 |
| 155 | + local result |
| 156 | + result=$(command gump query -- "$@") |
| 157 | + if [[ -n "$result" ]]; then |
| 158 | + builtin cd -- "$result" |
| 159 | + else |
| 160 | + echo "gump: no match found" >&2 |
| 161 | + return 1 |
| 162 | + fi |
| 151 | 163 | fi |
| 152 | 164 | }} |
| 153 | 165 | |
@@ -242,12 +254,18 @@ end |
| 242 | 254 | r#" |
| 243 | 255 | # Jump function |
| 244 | 256 | function {cmd} --description "Jump to a directory" |
| 245 | | - set -l result (command gump query -- $argv) |
| 246 | | - if test -n "$result" |
| 247 | | - cd $result |
| 257 | + if test (count $argv) -eq 0 |
| 258 | + cd ~ |
| 259 | + else if test (count $argv) -eq 1 -a "$argv[1]" = "-" |
| 260 | + cd - |
| 248 | 261 | else |
| 249 | | - echo "gump: no match found" >&2 |
| 250 | | - return 1 |
| 262 | + set -l result (command gump query -- $argv) |
| 263 | + if test -n "$result" |
| 264 | + cd $result |
| 265 | + else |
| 266 | + echo "gump: no match found" >&2 |
| 267 | + return 1 |
| 268 | + end |
| 251 | 269 | end |
| 252 | 270 | end |
| 253 | 271 | |