Permalink
Please sign in to comment.
Showing
with
113 additions
and 2 deletions.
- +111 −0 cmd/shell_test.go
- +1 −1 shell/bash.go
- +1 −1 shell/zsh.go
| @@ -0,0 +1,111 @@ | ||
| +package cmd | ||
| + | ||
| +import ( | ||
| + "github.com/gsamokovarov/jump/cli" | ||
| +) | ||
| + | ||
| +func ExampleShellCmd_Bash() { | ||
| + shellCmd(cli.Args{"bash"}, nil) | ||
| + | ||
| + // Output: | ||
| + // # Put the line below in ~/.bashrc or ~/bash_profile: | ||
| + // # | ||
| + // # eval "$(jump shell bash)" | ||
| + // # | ||
| + // # The following lines are autogenerated: | ||
| + // | ||
| + // __jump_prompt_command() { | ||
| + // local status=$? | ||
| + // jump chdir && return $status | ||
| + // } | ||
| + // | ||
| + // [[ "$PROMPT_COMMAND" =~ __jump_prompt_command ]] || { | ||
| + // PROMPT_COMMAND="__jump_prompt_command;$PROMPT_COMMAND" | ||
| + // } | ||
| + // | ||
| + // j() { | ||
| + // local dir="$(jump cd $@)" | ||
| + // test -d "$dir" && cd "$dir" | ||
| + // } | ||
| + // | ||
| + // complete -o dirnames -C 'jump hint "${COMP_LINE/#j /}" --smart' j | ||
| +} | ||
| + | ||
| +func ExampleShellCmd_Zsh() { | ||
| + shellCmd(cli.Args{"zsh"}, nil) | ||
| + | ||
| + // Output: | ||
| + // # Put the line below in ~/.zshrc: | ||
| + // # | ||
| + // # eval "$(jump shell zsh)" | ||
| + // # | ||
| + // # The following lines are autogenerated: | ||
| + // | ||
| + // __jump_chpwd() { | ||
| + // jump chdir | ||
| + // } | ||
| + // | ||
| + // typeset -gaU chpwd_functions | ||
| + // chpwd_functions+=__jump_chpwd | ||
| + // | ||
| + // j() { | ||
| + // local dir="$(jump cd $@)" | ||
| + // test -d "$dir" && cd "$dir" | ||
| + // } | ||
| + // | ||
| + // jump_completion() { | ||
| + // reply=($(jump hint "$1" --smart)) | ||
| + // } | ||
| + // | ||
| + // compctl -U -K jump_completion j | ||
| +} | ||
| + | ||
| +func ExampleShellCmd_Fish() { | ||
| + shellCmd(cli.Args{"fish"}, nil) | ||
| + | ||
| + // Output: | ||
| + // # Put the line below in ~/.config/fish/config.fish: | ||
| + // # | ||
| + // # status --is-interactive; and source (jump shell fish | psub) | ||
| + // # | ||
| + // # The following lines are autogenerated: | ||
| + // | ||
| + // function __jump_add --on-variable PWD | ||
| + // status --is-command-substitution; and return | ||
| + // jump chdir | ||
| + // end | ||
| + // | ||
| + // function j | ||
| + // set -l dir (jump cd $argv) | ||
| + // test -d "$dir"; and cd "$dir" | ||
| + // end | ||
| + // | ||
| + // complete --command j --exclusive --arguments '(jump hint)' | ||
| +} | ||
| + | ||
| +func ExampleShellCmd_Bind() { | ||
| + shellCmd(cli.Args{"bash", "--bind=z"}, nil) | ||
| + | ||
| + // Output: | ||
| + // # Put the line below in ~/.bashrc or ~/bash_profile: | ||
| + // # | ||
| + // # eval "$(jump shell bash)" | ||
| + // # | ||
| + // # The following lines are autogenerated: | ||
| + // | ||
| + // __jump_prompt_command() { | ||
| + // local status=$? | ||
| + // jump chdir && return $status | ||
| + // } | ||
| + // | ||
| + // [[ "$PROMPT_COMMAND" =~ __jump_prompt_command ]] || { | ||
| + // PROMPT_COMMAND="__jump_prompt_command;$PROMPT_COMMAND" | ||
| + // } | ||
| + // | ||
| + // z() { | ||
| + // local dir="$(jump cd $@)" | ||
| + // test -d "$dir" && cd "$dir" | ||
| + // } | ||
| + // | ||
| + // complete -o dirnames -C 'jump hint "${COMP_LINE/#z /}" --smart' z | ||
| +} |
0 comments on commit
fca01f5