diff --git a/main.go b/main.go index 3491e72..85a6124 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,8 @@ func main() { switch args[1] { case "fish": dirp.PrintFishHook() + case "es": + dirp.PrintEsHook() case "rc": dirp.PrintRcHook() default: diff --git a/src/hook.go b/src/hook.go index 7cd207f..db761bc 100644 --- a/src/hook.go +++ b/src/hook.go @@ -78,3 +78,23 @@ func PrintRcHook() { fmt.Println(strings.ReplaceAll(src, "\t", " ")) } + +// PrintEsHook emits code for es, a shell based on rc +func PrintEsHook() { + fmt.Println(`fn dir { + stdout=` + "`" + `{dirp $*}; + if {~ $bqstatus 2 } { + $EDITOR $stdout; + return $status; + }; + + if {~ "x$stdout" "x" } { + echo -n "How are we doing @"; + uptime; + return $status; + }; + + echo Switching to $stdout; + cd $stdout +}`) +}