Skip to content

Commit

Permalink
fix: clear screen after setting shell
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Feb 21, 2023
1 parent 609f95a commit 7cb57d1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Output examples/demo.gif

Require echo

Set Shell "bash"
Set FontSize 32
Set Width 1200
Set Height 600
Expand Down
4 changes: 2 additions & 2 deletions examples/welcome.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,39 @@ const (
type Shell struct {
Prompt string
Command string
Clear string
}

// Shells contains a mapping from shell names to their Shell struct.
var Shells = map[string]Shell{
bash: {
Prompt: "\\[\\e[38;2;90;86;224m\\]> \\[\\e[0m\\]",
Command: ` PS1="%s" bash --login --norc --noprofile +o history; clear;`,
Clear: "clear",
},
zsh: {
Prompt: `%F{#5B56E0}> %F{reset_color}`,
Command: ` PROMPT="%s" zsh --login --histnostore --no-rcs; clear;`,
Clear: "clear",
},
fish: {
Prompt: `function fish_prompt; echo -e "$(set_color 5B56E0)> $(set_color normal)"; end`,
Command: ` fish --login --no-config --private -C 'function fish_greeting; end' -C '%s'; clear;`,
Clear: "clear",
},
powershell: {
Prompt: `Set-PSReadLineOption -HistorySaveStyle SaveNothing; Function prompt { Write-Host -ForegroundColor Blue -NoNewLine '>'; return ' ' }`,
Command: ` clear; powershell -Login -NoLogo -NoExit -NoProfile -Command %q`,
Clear: "clear",
},
pwsh: {
Prompt: `Set-PSReadLineOption -HistorySaveStyle SaveNothing; Function prompt { Write-Host -ForegroundColor Blue -NoNewLine '>'; return ' ' }`,
Command: ` clear; pwsh -Login -NoLogo -NoExit -NoProfile -Command %q`,
Clear: "clear",
},
cmdexe: {
Prompt: "$g",
Command: ` cls && set prompt=%s && cls`,
Clear: "cls",
},
}
4 changes: 4 additions & 0 deletions vhs.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func (vhs *VHS) Setup() {
MustInput(shellCommand).
MustType(input.Enter)

vhs.Page.MustElement("textarea").
MustInput(vhs.Options.Shell.Clear).
MustType(input.Enter)

// Apply options to the terminal
// By this point the setting commands have been executed, so the `opts` struct is up to date.
vhs.Page.MustEval(fmt.Sprintf("() => { term.options = { fontSize: %d, fontFamily: '%s', letterSpacing: %f, lineHeight: %f, theme: %s } }",
Expand Down

0 comments on commit 7cb57d1

Please sign in to comment.