add term:localshellopts (#914)

This commit is contained in:
Mike Sawka 2024-09-30 21:19:07 -07:00 committed by GitHub
parent 8cfbd2426b
commit 2fa88c4e50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 44 additions and 11 deletions

View File

@ -302,6 +302,7 @@ declare global {
"term:mode"?: string;
"term:theme"?: string;
"term:localshellpath"?: string;
"term:localshellopts"?: string[];
count?: number;
};
@ -419,6 +420,7 @@ declare global {
"term:fontfamily"?: string;
"term:disablewebgl"?: boolean;
"term:localshellpath"?: string;
"term:localshellopts"?: string[];
"editor:minimapenabled"?: boolean;
"editor:stickyscrollenabled"?: boolean;
"web:*"?: boolean;

View File

@ -302,6 +302,12 @@ func (bc *BlockController) DoRunShellCommand(rc *RunShellOpts, blockMeta waveobj
if blockMeta.GetString(waveobj.MetaKey_TermLocalShellPath, "") != "" {
cmdOpts.ShellPath = blockMeta.GetString(waveobj.MetaKey_TermLocalShellPath, "")
}
if len(settings.TermLocalShellOpts) > 0 {
cmdOpts.ShellOpts = append([]string{}, settings.TermLocalShellOpts...)
}
if len(blockMeta.GetStringList(waveobj.MetaKey_TermLocalShellOpts)) > 0 {
cmdOpts.ShellOpts = append([]string{}, blockMeta.GetStringList(waveobj.MetaKey_TermLocalShellOpts)...)
}
shellProc, err = shellexec.StartShellProc(rc.TermSize, cmdStr, cmdOpts)
if err != nil {
return err

View File

@ -35,6 +35,7 @@ type CommandOptsType struct {
Cwd string `json:"cwd,omitempty"`
Env map[string]string `json:"env,omitempty"`
ShellPath string `json:"shellPath,omitempty"`
ShellOpts []string `json:"shellOpts,omitempty"`
}
type ShellProc struct {
@ -159,6 +160,7 @@ func StartRemoteShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts Comm
log.Printf("error installing rc files: %v", err)
return nil, err
}
shellOpts = append(shellOpts, cmdOpts.ShellOpts...)
homeDir := remote.GetHomeDir(client)
@ -280,6 +282,7 @@ func StartShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOpt
if shellPath == "" {
shellPath = shellutil.DetectLocalShellPath()
}
shellOpts = append(shellOpts, cmdOpts.ShellOpts...)
if cmdStr == "" {
if isBashShell(shellPath) {
// add --rcfile

View File

@ -60,6 +60,7 @@ const (
MetaKey_TermMode = "term:mode"
MetaKey_TermTheme = "term:theme"
MetaKey_TermLocalShellPath = "term:localshellpath"
MetaKey_TermLocalShellOpts = "term:localshellopts"
MetaKey_Count = "count"
)

View File

@ -14,6 +14,24 @@ func (m MetaMapType) GetString(key string, def string) string {
return def
}
func (m MetaMapType) GetStringList(key string) []string {
v, ok := m[key]
if !ok {
return nil
}
varr, ok := v.([]any)
if !ok {
return nil
}
rtn := make([]string, 0)
for _, varrVal := range varr {
if s, ok := varrVal.(string); ok {
rtn = append(rtn, s)
}
}
return rtn
}
func (m MetaMapType) GetBool(key string, def bool) bool {
if v, ok := m[key]; ok {
if b, ok := v.(bool); ok {

View File

@ -60,6 +60,7 @@ type MetaTSType struct {
TermMode string `json:"term:mode,omitempty"`
TermTheme string `json:"term:theme,omitempty"`
TermLocalShellPath string `json:"term:localshellpath,omitempty"` // matches settings
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"` // matches settings
Count int `json:"count,omitempty"` // temp for cpu plot. will remove later
}

View File

@ -19,6 +19,7 @@ const (
ConfigKey_TermFontFamily = "term:fontfamily"
ConfigKey_TermDisableWebGl = "term:disablewebgl"
ConfigKey_TermLocalShellPath = "term:localshellpath"
ConfigKey_TermLocalShellOpts = "term:localshellopts"
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"

View File

@ -53,6 +53,7 @@ type SettingsType struct {
TermFontFamily string `json:"term:fontfamily,omitempty"`
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
TermLocalShellPath string `json:"term:localshellpath,omitempty"`
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"`
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`