diff --git a/src/runtime/os.go b/src/runtime/os.go index 78a25be3..b566ed9b 100644 --- a/src/runtime/os.go +++ b/src/runtime/os.go @@ -244,8 +244,10 @@ func (term *Terminal) Init() { func (term *Terminal) resolveConfigPath() { defer term.Trace(time.Now()) - if len(term.CmdFlags.Config) == 0 { - term.CmdFlags.Config = term.Getenv("POSH_THEME") + if poshTheme := term.Getenv("POSH_THEME"); len(poshTheme) > 0 { + term.DebugF("Config set using POSH_THEME: %s", poshTheme) + term.CmdFlags.Config = poshTheme + return } if len(term.CmdFlags.Config) == 0 { diff --git a/src/shell/scripts/omp.bash b/src/shell/scripts/omp.bash index 13dcee5d..77933592 100644 --- a/src/shell/scripts/omp.bash +++ b/src/shell/scripts/omp.bash @@ -20,7 +20,7 @@ _omp_ftcs_marks=0 # start timer on command start PS0='${_omp_start_time:0:$((_omp_start_time="$(_omp_start_timer)",0))}$(_omp_ftcs_command_start)' # set secondary prompt -PS2="$(${_omp_executable} print secondary --config="$POSH_THEME" --shell=bash --shell-version="$BASH_VERSION")" +PS2="$(${_omp_executable} print secondary --shell=bash --shell-version="$BASH_VERSION")" function _omp_set_cursor_position() { # not supported in Midnight Commander @@ -81,7 +81,7 @@ function _omp_hook() { set_poshcontext _omp_set_cursor_position - PS1="$(${_omp_executable} print primary --config="$POSH_THEME" --shell=bash --shell-version="$BASH_VERSION" --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --no-status="$_omp_no_exit_code" --terminal-width="${COLUMNS-0}" | tr -d '\0')" + PS1="$(${_omp_executable} print primary --shell=bash --shell-version="$BASH_VERSION" --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --no-status="$_omp_no_exit_code" --terminal-width="${COLUMNS-0}" | tr -d '\0')" return $_omp_status_cache } diff --git a/src/shell/scripts/omp.elv b/src/shell/scripts/omp.elv index a9bfbe4b..f6b94bfa 100644 --- a/src/shell/scripts/omp.elv +++ b/src/shell/scripts/omp.elv @@ -24,10 +24,10 @@ set edit:after-command = [ $@edit:after-command $posh-after-command-hook~ ] set edit:prompt = { var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000)) - $_omp_executable print primary --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --status=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION + $_omp_executable print primary --shell=elvish --execution-time=$cmd-duration --status=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION } set edit:rprompt = { var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000)) - $_omp_executable print right --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --status=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION + $_omp_executable print right --shell=elvish --execution-time=$cmd-duration --status=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION } diff --git a/src/shell/scripts/omp.fish b/src/shell/scripts/omp.fish index 409e0a2b..27fdcb53 100644 --- a/src/shell/scripts/omp.fish +++ b/src/shell/scripts/omp.fish @@ -30,7 +30,7 @@ function fish_prompt # see https://github.com/fish-shell/fish-shell/issues/8418 printf \e\[0J if test "$_omp_transient" = true - $_omp_executable print transient --config $POSH_THEME --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --no-status=$_omp_no_exit_code + $_omp_executable print transient --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --no-status=$_omp_no_exit_code return end if test "$_omp_new_prompt" = false @@ -77,7 +77,7 @@ function fish_prompt end # The prompt is saved for possible reuse, typically a repaint after clearing the screen buffer. - set --global _omp_current_prompt ($_omp_executable print primary --config $POSH_THEME --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --cleared=$omp_cleared --no-status=$_omp_no_exit_code | string collect) + set --global _omp_current_prompt ($_omp_executable print primary --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --cleared=$omp_cleared --no-status=$_omp_no_exit_code | string collect) echo -n "$_omp_current_prompt" end @@ -94,7 +94,7 @@ function fish_right_prompt end set _omp_new_prompt false - set --global _omp_current_rprompt ($_omp_executable print right --config $POSH_THEME --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --no-status=$_omp_no_exit_code | string join '') + set --global _omp_current_rprompt ($_omp_executable print right --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --no-status=$_omp_no_exit_code | string join '') echo -n "$_omp_current_rprompt" end @@ -150,7 +150,7 @@ function _omp_space_key_handler end set _omp_tooltip_command $tooltip_command - set --local tooltip_prompt ($_omp_executable print tooltip --config $POSH_THEME --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --command $_omp_tooltip_command --no-status=$_omp_no_exit_code | string join '') + set --local tooltip_prompt ($_omp_executable print tooltip --shell fish --status $_omp_status_cache --pipestatus="$_omp_pipestatus_cache" --execution-time $_omp_duration --stack-count $_omp_stack_count --shell-version $FISH_VERSION --command $_omp_tooltip_command --no-status=$_omp_no_exit_code | string join '') if test -z "$tooltip_prompt" return diff --git a/src/shell/scripts/omp.lua b/src/shell/scripts/omp.lua index 12d09613..3cbea2f3 100644 --- a/src/shell/scripts/omp.lua +++ b/src/shell/scripts/omp.lua @@ -74,10 +74,6 @@ local function omp_exe() return '"'..::OMP::..'"' end -local function omp_config() - return '"'..::CONFIG::..'"' -end - os.setenv("POSH_THEME", ::CONFIG::) os.setenv("POSH_SHELL_VERSION", string.format('clink v%s.%s.%s.%s', clink.version_major, clink.version_minor, clink.version_patch, clink.version_commit)) @@ -162,7 +158,7 @@ local function get_posh_prompt(rprompt) if rprompt then prompt = "right" end - local prompt_exe = string.format('%s print %s --shell=cmd --config=%s %s %s %s', omp_exe(), prompt, omp_config(), execution_time_option(), error_level_option(), no_exit_code_option()) + local prompt_exe = string.format('%s print %s --shell=cmd %s %s %s', omp_exe(), prompt, execution_time_option(), error_level_option(), no_exit_code_option()) return run_posh_command(prompt_exe) end @@ -171,7 +167,7 @@ local function set_posh_tooltip(tip_command) -- Escape special characters properly, if any. local escaped_tip_command = string.gsub(tip_command, '(\\+)"', '%1%1"'):gsub('(\\+)$', '%1%1'):gsub('"', '\\"'):gsub('([&<>%(%)@%^|])', '^%1') - local prompt_exe = string.format('%s print tooltip --shell=cmd %s --config=%s --command="%s"', omp_exe(), error_level_option(), omp_config(), escaped_tip_command) + local prompt_exe = string.format('%s print tooltip --shell=cmd %s --command="%s"', omp_exe(), error_level_option(), escaped_tip_command) local tooltip = run_posh_command(prompt_exe) -- Do not cache an empty tooltip. if tooltip == "" then @@ -273,7 +269,7 @@ function p:transientfilter(prompt) return nil end - local prompt_exe = string.format('%s print transient --shell=cmd --config=%s %s %s', omp_exe(), omp_config(), error_level_option(), no_exit_code_option()) + local prompt_exe = string.format('%s print transient --shell=cmd %s %s', omp_exe(), error_level_option(), no_exit_code_option()) prompt = run_posh_command(prompt_exe) if prompt == "" then diff --git a/src/shell/scripts/omp.nu b/src/shell/scripts/omp.nu index 86327ad9..963ce897 100644 --- a/src/shell/scripts/omp.nu +++ b/src/shell/scripts/omp.nu @@ -23,7 +23,7 @@ def posh_width [] { } # PROMPTS -$env.PROMPT_MULTILINE_INDICATOR = (^$_omp_executable print secondary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)") +$env.PROMPT_MULTILINE_INDICATOR = (^$_omp_executable print secondary --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)") $env.PROMPT_COMMAND = { || # hack to set the cursor line to 1 when the user clears the screen @@ -37,9 +37,9 @@ $env.PROMPT_COMMAND = { || do --env $env.SET_POSHCONTEXT } - ^$_omp_executable print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)" $"--execution-time=(posh_cmd_duration)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=(posh_width)" $"--cleared=($clear)" + ^$_omp_executable print primary --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)" $"--execution-time=(posh_cmd_duration)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=(posh_width)" $"--cleared=($clear)" } $env.PROMPT_COMMAND_RIGHT = { || - ^$_omp_executable print right $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)" $"--execution-time=(posh_cmd_duration)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=(posh_width)" + ^$_omp_executable print right --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)" $"--execution-time=(posh_cmd_duration)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=(posh_width)" } diff --git a/src/shell/scripts/omp.ps1 b/src/shell/scripts/omp.ps1 index 6554d77a..05c5be45 100644 --- a/src/shell/scripts/omp.ps1 +++ b/src/shell/scripts/omp.ps1 @@ -157,7 +157,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock { $cleanPSWD = Get-CleanPSWD $stackCount = global:Get-PoshStackCount - $standardOut = (Start-Utf8Process $global:_ompExecutable @("print", "tooltip", "--status=$script:ErrorCode", "--shell=$script:ShellName", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--config=$env:POSH_THEME", "--command=$command", "--shell-version=$script:PSVersion", "--column=$column", "--terminal-width=$terminalWidth", "--no-status=$script:NoExitCode", "--job-count=$script:JobCount")) -join '' + $standardOut = (Start-Utf8Process $global:_ompExecutable @("print", "tooltip", "--status=$script:ErrorCode", "--shell=$script:ShellName", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--command=$command", "--shell-version=$script:PSVersion", "--column=$column", "--terminal-width=$terminalWidth", "--no-status=$script:NoExitCode", "--job-count=$script:JobCount")) -join '' if (!$standardOut) { return } @@ -227,8 +227,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock { } function Enable-PoshLineError { - $validLine = (Start-Utf8Process $global:_ompExecutable @("print", "valid", "--config=$env:POSH_THEME", "--shell=$script:ShellName")) -join "`n" - $errorLine = (Start-Utf8Process $global:_ompExecutable @("print", "error", "--config=$env:POSH_THEME", "--shell=$script:ShellName")) -join "`n" + $validLine = (Start-Utf8Process $global:_ompExecutable @("print", "valid", "--shell=$script:ShellName")) -join "`n" + $errorLine = (Start-Utf8Process $global:_ompExecutable @("print", "error", "--shell=$script:ShellName")) -join "`n" Set-PSReadLineOption -PromptText $validLine, $errorLine } @@ -267,7 +267,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock { $Format = 'json' ) - $configString = Start-Utf8Process $global:_ompExecutable @("config", "export", "--config=$env:POSH_THEME", "--format=$Format") + $configString = Start-Utf8Process $global:_ompExecutable @("config", "export", "--format=$Format") # if no path, copy to clipboard by default if ($FilePath) { # https://stackoverflow.com/questions/3038337/powershell-resolve-path-that-might-not-exist @@ -450,7 +450,7 @@ Example: $env:POSH_CURSOR_LINE = $Host.UI.RawUI.CursorPosition.Y + 1 $env:POSH_CURSOR_COLUMN = $Host.UI.RawUI.CursorPosition.X + 1 - $standardOut = Start-Utf8Process $global:_ompExecutable @("print", $script:PromptType, "--status=$script:ErrorCode", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--config=$env:POSH_THEME", "--shell-version=$script:PSVersion", "--terminal-width=$terminalWidth", "--shell=$script:ShellName", "--no-status=$script:NoExitCode", "--job-count=$script:JobCount") + $standardOut = Start-Utf8Process $global:_ompExecutable @("print", $script:PromptType, "--status=$script:ErrorCode", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--shell-version=$script:PSVersion", "--terminal-width=$terminalWidth", "--shell=$script:ShellName", "--no-status=$script:NoExitCode", "--job-count=$script:JobCount") # make sure PSReadLine knows if we have a multiline prompt Set-PSReadLineOption -ExtraPromptLineCount (($standardOut | Measure-Object -Line).Lines - 1) @@ -467,7 +467,7 @@ Example: $Function:prompt = $promptFunction # set secondary prompt - Set-PSReadLineOption -ContinuationPrompt ((Start-Utf8Process $global:_ompExecutable @("print", "secondary", "--config=$env:POSH_THEME", "--shell=$script:ShellName")) -join "`n") + Set-PSReadLineOption -ContinuationPrompt ((Start-Utf8Process $global:_ompExecutable @("print", "secondary", "--shell=$script:ShellName")) -join "`n") # perform cleanup on removal so a new initialization in current session works if (!$script:ConstrainedLanguageMode) { diff --git a/src/shell/scripts/omp.py b/src/shell/scripts/omp.py index 1801aa74..3cc52837 100644 --- a/src/shell/scripts/omp.py +++ b/src/shell/scripts/omp.py @@ -14,11 +14,11 @@ def get_command_context(): def posh_primary(): status, duration = get_command_context() - return $(@($POSH_EXECUTABLE) print primary --config=@($POSH_THEME) --shell=xonsh --status=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION)) + return $(@($POSH_EXECUTABLE) print primary --shell=xonsh --status=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION)) def posh_right(): status, duration = get_command_context() - return $(@($POSH_EXECUTABLE) print right --config=@($POSH_THEME) --shell=xonsh --status=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION)) + return $(@($POSH_EXECUTABLE) print right --shell=xonsh --status=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION)) $PROMPT = posh_primary diff --git a/src/shell/scripts/omp.tcsh b/src/shell/scripts/omp.tcsh index 531bda43..c3b30257 100644 --- a/src/shell/scripts/omp.tcsh +++ b/src/shell/scripts/omp.tcsh @@ -5,7 +5,7 @@ setenv POSH_SHELL_VERSION ""; set POSH_COMMAND = ::OMP::; set USER_PRECMD = "`alias precmd`"; set USER_POSTCMD = "`alias postcmd`"; -set POSH_PRECMD = 'set POSH_CMD_STATUS = $status;set POSH_END_TIME = `$POSH_COMMAND get millis`;set POSH_DURATION = 0;if ( $POSH_START_TIME != -1 ) @ POSH_DURATION = $POSH_END_TIME - $POSH_START_TIME;set prompt = "`$POSH_COMMAND print primary --shell=tcsh --config=$POSH_THEME --status=$POSH_CMD_STATUS --execution-time=$POSH_DURATION`";set POSH_START_TIME = -1'; +set POSH_PRECMD = 'set POSH_CMD_STATUS = $status;set POSH_END_TIME = `$POSH_COMMAND get millis`;set POSH_DURATION = 0;if ( $POSH_START_TIME != -1 ) @ POSH_DURATION = $POSH_END_TIME - $POSH_START_TIME;set prompt = "`$POSH_COMMAND print primary --shell=tcsh --status=$POSH_CMD_STATUS --execution-time=$POSH_DURATION`";set POSH_START_TIME = -1'; set POSH_POSTCMD = 'set POSH_START_TIME = `$POSH_COMMAND get millis`'; alias precmd "$POSH_PRECMD;$USER_PRECMD"; diff --git a/src/shell/scripts/omp.zsh b/src/shell/scripts/omp.zsh index 41bdb765..cd720465 100644 --- a/src/shell/scripts/omp.zsh +++ b/src/shell/scripts/omp.zsh @@ -13,7 +13,7 @@ _omp_cursor_positioning=0 _omp_ftcs_marks=0 # set secondary prompt -PS2="$(${_omp_executable} print secondary --config="$POSH_THEME" --shell=zsh)" +PS2="$(${_omp_executable} print secondary --shell=zsh)" function _omp_set_cursor_position() { # not supported in Midnight Commander @@ -73,7 +73,7 @@ function _omp_precmd() { set_poshcontext _omp_set_cursor_position - eval "$(${_omp_executable} print primary --config="$POSH_THEME" --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$_omp_no_exit_code")" + eval "$(${_omp_executable} print primary --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$_omp_no_exit_code")" unset _omp_start_time } @@ -116,7 +116,7 @@ function _omp_render_tooltip() { fi _omp_tooltip_command="$tooltip_command" - local tooltip=$(${_omp_executable} print tooltip --config="$POSH_THEME" --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --command="$tooltip_command" --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$_omp_no_exit_code") + local tooltip=$(${_omp_executable} print tooltip --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --command="$tooltip_command" --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$_omp_no_exit_code") if [[ -z "$tooltip" ]]; then return fi @@ -135,7 +135,7 @@ function _omp_zle-line-init() { (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2] _omp_tooltip_command='' - eval "$(${_omp_executable} print transient --config="$POSH_THEME" --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$_omp_no_exit_code")" + eval "$(${_omp_executable} print transient --status="$_omp_status_cache" --pipestatus="${_omp_pipestatus_cache[*]}" --execution-time="$_omp_elapsed" --stack-count="$_omp_stack_count" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$_omp_no_exit_code")" zle .reset-prompt # Exit the shell if we receive EOT.