Skip to content

Commit

Permalink
Breaking: shell hook defaults
Browse files Browse the repository at this point in the history
Fish is not the default shell anymore. For traditional
shells, users now need to call:

```sh
eval "$(dirp hook)"
```

Fish users should use:

```fish
dirp hook fish | source
```

Previously, users would call `dirp hook bash`. Now
the shell hook is compatible with BusyBox and a few
other variants, so the default has been changed.
  • Loading branch information
avindra committed Jan 24, 2021
1 parent 9c951f4 commit 62ad9ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func main() {
cfg := dirp.FindDirs(arg0)
dirp.Selector(cfg)
} else if arg0 == "hook" {
if len(args) >= 2 && args[1] == "bash" {
dirp.PrintBashHook()
if len(args) >= 2 && args[1] == "fish" {
dirp.PrintFishHook()
} else {
dirp.PrintHook() // fish
dirp.PrintHook()
}
} else if arg0 == "cfg" {
fmt.Print(dirp.GetConfigPath())
Expand Down
8 changes: 4 additions & 4 deletions src/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package dirp

import "fmt"

// PrintBashHook emits shell code for Bash, ZSH, sh, BusyBox, etc
func PrintBashHook() {
// PrintHook emits shell code for Bash, ZSH, sh, BusyBox, etc
func PrintHook() {
// 1) Remove existing "dir" aliases, if any exit
// 2) Detect and prefer pushd over cd
// 3) Provide "dir" function
Expand Down Expand Up @@ -34,8 +34,8 @@ function dir() {
export -f dir &> /dev/null`)
}

// PrintHook emits shell code for Fish
func PrintHook() {
// PrintFishHook emits shell code for Fish
func PrintFishHook() {
fmt.Println(`function dir
set stdout (dirp $argv)
if [ $status = 2 ]
Expand Down

0 comments on commit 62ad9ef

Please sign in to comment.