add custom prompts with PS1 and PS2
PS1 and PS2 support the backslash escapes of bash (\u \h \w \W \$ \t \j
\e \[ \] ...) and expand $VAR, ${...}, $(...) and $((...)) before each
prompt. Values of escapes and expansions are sanitized. Lines before the
last one and non-SGR escape sequences are written before readline's
prompt. Without PS1, the default prompt is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
af5281eed2
commit
82f9c90a39
6 files changed
+528
-13
No files matched your search
@@ -399,6 +399,7 @@ func TestExecInput_CdDashNoPrevious(t *testing.T) {
|
||||
// =============================================================================
|
||||
|
||||
func TestGetPrompt_Format(t *testing.T) {
|
||||
unsetPS1(t)
|
||||
prompt := getPrompt()
|
||||
|
||||
// Should contain username@hostname:path $ pattern
|
||||
@@ -414,6 +415,7 @@ func TestGetPrompt_Format(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPrompt_IncludesHome(t *testing.T) {
|
||||
unsetPS1(t)
|
||||
// Save and restore current directory
|
||||
origDir, _ := os.Getwd()
|
||||
defer os.Chdir(origDir)
|
||||
@@ -1037,6 +1039,7 @@ func TestSanitize(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPrompt_EscapesControlCharacters(t *testing.T) {
|
||||
unsetPS1(t)
|
||||
t.Setenv("NO_COLOR", "1")
|
||||
origDir, _ := os.Getwd()
|
||||
defer os.Chdir(origDir)
|
||||
|
||||
Reference in new issue
Block a user