Permalink
Browse files

Test the shell command with an example

  • Loading branch information...
1 parent 1d7cae6 commit fca01f577dde1b379e2b2023233182e5c6b88911 @gsamokovarov committed Mar 13, 2017
Showing with 113 additions and 2 deletions.
  1. +111 −0 cmd/shell_test.go
  2. +1 −1 shell/bash.go
  3. +1 −1 shell/zsh.go
View
@@ -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
+}
View
@@ -3,7 +3,7 @@ package shell
// Bash is the bash shell integration.
var Bash = Shell(`# Put the line below in ~/.bashrc or ~/bash_profile:
#
-# eval "$(jump shell bash)"
+# eval "$(jump shell bash)"
#
# The following lines are autogenerated:
View
@@ -3,7 +3,7 @@ package shell
// Zsh is the zsh shell integration.
var Zsh = Shell(`# Put the line below in ~/.zshrc:
#
-# eval "$(jump shell zsh)"
+# eval "$(jump shell zsh)"
#
# The following lines are autogenerated:

0 comments on commit fca01f5

Please sign in to comment.