Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion pkg/util/shellutil/shellintegration/fish_wavefish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,27 @@ wsh token "$WAVETERM_SWAPTOKEN" fish 2>/dev/null | source
set -e WAVETERM_SWAPTOKEN

# Load Wave completions
wsh completion fish | source
wsh completion fish | source

# shell integration
function _waveterm_si_blocked
# Check if we're in tmux or screen (using fish-native checks)
set -q TMUX; or set -q STY; or string match -q 'tmux*' -- $TERM; or string match -q 'screen*' -- $TERM
end

function _waveterm_si_osc7
_waveterm_si_blocked; and return
# Use fish-native URL encoding
set -l encoded_pwd (string escape --style=url -- $PWD)
printf '\033]7;file://%s%s\007' $hostname $encoded_pwd
end

# Hook OSC 7 to prompt and directory changes
function _waveterm_si_prompt --on-event fish_prompt
_waveterm_si_osc7
end

# Also update on directory change
function _waveterm_si_chpwd --on-variable PWD
_waveterm_si_osc7
end
43 changes: 42 additions & 1 deletion pkg/util/shellutil/shellintegration/pwsh_wavepwsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,45 @@ Remove-Variable -Name waveterm_swaptoken_output
Remove-Item Env:WAVETERM_SWAPTOKEN

# Load Wave completions
wsh completion powershell | Out-String | Invoke-Expression
wsh completion powershell | Out-String | Invoke-Expression

# shell integration
function Global:_waveterm_si_blocked {
# Check if we're in tmux or screen
return ($env:TMUX -or $env:STY -or $env:TERM -like "tmux*" -or $env:TERM -like "screen*")
}

function Global:_waveterm_si_osc7 {
if (_waveterm_si_blocked) { return }

# Get hostname (allow empty for file:/// format)
$hostname = $env:COMPUTERNAME
if (-not $hostname) {
$hostname = $env:HOSTNAME
}

# Percent-encode the raw path as-is (handles UNC, drive letters, etc.)
$encoded_pwd = [System.Uri]::EscapeDataString($PWD.Path)

# OSC 7 - current directory
Write-Host -NoNewline "`e]7;file://$hostname/$encoded_pwd`a"
}

# Hook OSC 7 to prompt
function Global:_waveterm_si_prompt {
_waveterm_si_osc7
}

# Add the OSC 7 call to the prompt function
if (Test-Path Function:\prompt) {
$global:_waveterm_original_prompt = $function:prompt
function Global:prompt {
_waveterm_si_prompt
& $global:_waveterm_original_prompt
}
} else {
function Global:prompt {
_waveterm_si_prompt
"PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
}
}