Skip to content

Commit

Permalink
Merge pull request #77 from basherpm/remove-shell-detection
Browse files Browse the repository at this point in the history
Remove shell detection in basher init
  • Loading branch information
juanibiapina authored Apr 15, 2020
2 parents b13e79b + 59fee60 commit adc9c19
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
26 changes: 5 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,20 @@ Even though it is called basher, it also works with zsh and fish.
$ git clone https://github.com/basherpm/basher.git ~/.basher
~~~

2. Add `~/.basher/bin` to `$PATH` for easy access to the basher command-line utility.
2. Initialize basher in your shell initialization

~~~ sh
$ echo 'export PATH="$HOME/.basher/bin:$PATH"' >> ~/.bash_profile
export PATH="$HOME/.basher/bin:$PATH"'
eval "$(basher init -)"
~~~
**Ubuntu Desktop note**: Modify your `~/.bashrc` instead of `~/.bash_profile`.

**Zsh note**: Modify your `~/.zshrc` file instead of `~/.bash_profile`.

**For Fish**: Add the following to you `~/.config/fish/config.fish`
**Fish**: Use the following commands instead:
~~~ sh
if test -d ~/.basher
set basher ~/.basher/bin
end
set -gx PATH $basher $PATH
~~~

3. Add `basher init` to your shell to enable basher runtime functions

~~~ sh
$ echo 'eval "$(basher init -)"' >> ~/.bash_profile
~~~

_Same as in previous step, use `~/.bashrc` on Ubuntu, `~/.zshrc` for Zsh._

_For **Fish**, use the following line on your `~/.config/fish/config.fish`._

~~~ sh
status --is-interactive; and . (basher init -|psub)
~~~
Expand All @@ -63,7 +47,7 @@ $ git pull
## Usage
### Installing packages from github.com
### Installing packages from Github
~~~ sh
$ basher install sstephenson/bats
Expand Down
11 changes: 7 additions & 4 deletions libexec/basher-init
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ set -e

shell="$2"
if [ -z "$shell" ]; then
shell="$(ps -o comm= -o pid= | grep "$PPID" 2>/dev/null || true)"
shell="${shell##-}"
shell="${shell%% *}"
shell="$(basename "${shell:-$SHELL}")"
echo "echo 'basher init usage has changed, please specify the name of your shell as an argument:
eval \"\$(basher init - bash)\" # or zsh, fish, sh etc
For more information, check this PR: https://github.com/basherpm/basher/pull/77
'"
exit 1
fi

print_fish_commands() {
Expand Down
13 changes: 9 additions & 4 deletions tests/basher-init.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

load test_helper

@test "detects the shell" {
SHELL=/bin/false run basher-init -
assert_success
assert_line -n 0 'export BASHER_SHELL=bash'
@test "without enough arguments, prints a useful message" {
run basher-init -
assert_failure
assert_output "echo 'basher init usage has changed, please specify the name of your shell as an argument:
eval \"\$(basher init - bash)\" # or zsh, fish, sh etc
For more information, check this PR: https://github.com/basherpm/basher/pull/77
'"
}

@test "exports BASHER_ROOT" {
Expand Down

0 comments on commit adc9c19

Please sign in to comment.