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

View File

@ -302,6 +302,12 @@ func (bc *BlockController) DoRunShellCommand(rc *RunShellOpts, blockMeta waveobj
if blockMeta.GetString(waveobj.MetaKey_TermLocalShellPath, "") != "" { if blockMeta.GetString(waveobj.MetaKey_TermLocalShellPath, "") != "" {
cmdOpts.ShellPath = 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) shellProc, err = shellexec.StartShellProc(rc.TermSize, cmdStr, cmdOpts)
if err != nil { if err != nil {
return err return err

View File

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

View File

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

View File

@ -14,6 +14,24 @@ func (m MetaMapType) GetString(key string, def string) string {
return def 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 { func (m MetaMapType) GetBool(key string, def bool) bool {
if v, ok := m[key]; ok { if v, ok := m[key]; ok {
if b, ok := v.(bool); ok { if b, ok := v.(bool); ok {

View File

@ -54,12 +54,13 @@ type MetaTSType struct {
BgOpacity float64 `json:"bg:opacity,omitempty"` BgOpacity float64 `json:"bg:opacity,omitempty"`
BgBlendMode string `json:"bg:blendmode,omitempty"` BgBlendMode string `json:"bg:blendmode,omitempty"`
TermClear bool `json:"term:*,omitempty"` TermClear bool `json:"term:*,omitempty"`
TermFontSize int `json:"term:fontsize,omitempty"` TermFontSize int `json:"term:fontsize,omitempty"`
TermFontFamily string `json:"term:fontfamily,omitempty"` TermFontFamily string `json:"term:fontfamily,omitempty"`
TermMode string `json:"term:mode,omitempty"` TermMode string `json:"term:mode,omitempty"`
TermTheme string `json:"term:theme,omitempty"` TermTheme string `json:"term:theme,omitempty"`
TermLocalShellPath string `json:"term:localshellpath,omitempty"` // matches settings 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 Count int `json:"count,omitempty"` // temp for cpu plot. will remove later
} }

View File

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

View File

@ -48,11 +48,12 @@ type SettingsType struct {
AiMaxTokens float64 `json:"ai:maxtokens,omitempty"` AiMaxTokens float64 `json:"ai:maxtokens,omitempty"`
AiTimeoutMs float64 `json:"ai:timeoutms,omitempty"` AiTimeoutMs float64 `json:"ai:timeoutms,omitempty"`
TermClear bool `json:"term:*,omitempty"` TermClear bool `json:"term:*,omitempty"`
TermFontSize float64 `json:"term:fontsize,omitempty"` TermFontSize float64 `json:"term:fontsize,omitempty"`
TermFontFamily string `json:"term:fontfamily,omitempty"` TermFontFamily string `json:"term:fontfamily,omitempty"`
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"` TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
TermLocalShellPath string `json:"term:localshellpath,omitempty"` TermLocalShellPath string `json:"term:localshellpath,omitempty"`
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"`
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"` EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"` EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`