-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e29fac
commit 6608789
Showing
5 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
GOKART_PROMPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" | ||
|
||
gokart_prompt_precmd() { | ||
export EXIT_CODE=$? | ||
export GOKART_SHELL=bash | ||
|
||
PS1=$("$GOKART_PROMPT_DIR/gokart" ps1) | ||
PS2=$("$GOKART_PROMPT_DIR/gokart" ps2) | ||
} | ||
|
||
gokart_prompt_setup() { | ||
PROMPT_COMMAND=gokart_prompt_precmd | ||
} | ||
|
||
gokart_prompt_setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
package ansi | ||
|
||
import "os" | ||
|
||
const esc = "\x1B" | ||
const reset = "0" | ||
|
||
// See: https://stackoverflow.com/a/19731390/2831123 | ||
const zeroWidthStart = "%{" | ||
const zeroWidthEnd = "%}" | ||
const zshZeroWidthStart = "%{" | ||
const zshZeroWidthEnd = "%}" | ||
|
||
// See: https://unix.stackexchange.com/a/504152/176402 | ||
const bashZeroWidthStart = "\x01" | ||
const bashZeroWidthEnd = "\x02" | ||
|
||
func mode(mode string) string { | ||
return zeroWidthStart + esc + "[" + mode + "m" + zeroWidthEnd | ||
return zeroWidth(esc + "[" + mode + "m") | ||
} | ||
|
||
func Reset() string { | ||
return mode(reset) | ||
} | ||
|
||
func zeroWidth(s string) string { | ||
if os.Getenv("GOKART_SHELL") == "zsh" { | ||
return zshZeroWidthStart + s + zshZeroWidthEnd | ||
} | ||
return bashZeroWidthStart + s + bashZeroWidthEnd | ||
} |