Repository navigation
fix(shell): add Fish shell integration for listening port detection #1749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
BillionClaw
wants to merge
2
commits into
manaflow-ai:main
from
BillionClaw:clawoss/fix/listening-port-sidebar-1773831039
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # cmux shell integration for fish | ||
| # Injected automatically — do not source manually | ||
|
|
||
| function _cmux_send | ||
| set -l payload "$argv[1]" | ||
| if command -q ncat | ||
| printf '%s\n' "$payload" | ncat -w 1 -U "$CMUX_SOCKET_PATH" --send-only 2>/dev/null | ||
| else if command -q socat | ||
| printf '%s\n' "$payload" | socat -T 1 - "UNIX-CONNECT:$CMUX_SOCKET_PATH" 2>/dev/null | ||
| else if command -q nc | ||
| # Prefer flags that guarantee we exit after sending | ||
| if printf '%s\n' "$payload" | nc -N -U "$CMUX_SOCKET_PATH" 2>/dev/null | ||
| return 0 | ||
| else | ||
| printf '%s\n' "$payload" | nc -w 1 -U "$CMUX_SOCKET_PATH" 2>/dev/null | ||
| end | ||
| end | ||
| end | ||
|
|
||
| function _cmux_restore_scrollback_once | ||
| set -l path "$CMUX_RESTORE_SCROLLBACK_FILE" | ||
| test -n "$path" || return 0 | ||
| set -e CMUX_RESTORE_SCROLLBACK_FILE | ||
|
|
||
| if test -r "$path" | ||
| /bin/cat -- "$path" 2>/dev/null || true | ||
| /bin/rm -f -- "$path" 2>/dev/null || true | ||
| end | ||
| end | ||
| _cmux_restore_scrollback_once | ||
|
|
||
| # State variables | ||
| set -g _cmux_pwd_last_pwd "" | ||
| set -g _cmux_ports_last_run 0 | ||
| set -g _cmux_tty_name "" | ||
| set -g _cmux_tty_reported 0 | ||
| set -g _cmux_shell_activity_last "" | ||
| set -g _cmux_cmd_start 0 | ||
|
|
||
| function _cmux_report_tty_once | ||
| test "$_cmux_tty_reported" = 1 && return 0 | ||
| test -S "$CMUX_SOCKET_PATH" || return 0 | ||
| test -n "$CMUX_TAB_ID" || return 0 | ||
| test -n "$CMUX_PANEL_ID" || return 0 | ||
| test -n "$_cmux_tty_name" || return 0 | ||
|
|
||
| set -g _cmux_tty_reported 1 | ||
| _cmux_send "report_tty $_cmux_tty_name --tab=$CMUX_TAB_ID --panel=$CMUX_PANEL_ID" & | ||
| end | ||
|
|
||
| function _cmux_report_shell_activity_state | ||
| set -l state "$argv[1]" | ||
| test -n "$state" || return 0 | ||
| test -S "$CMUX_SOCKET_PATH" || return 0 | ||
| test -n "$CMUX_TAB_ID" || return 0 | ||
| test -n "$CMUX_PANEL_ID" || return 0 | ||
| test "$_cmux_shell_activity_last" = "$state" && return 0 | ||
|
|
||
| set -g _cmux_shell_activity_last "$state" | ||
| _cmux_send "report_shell_state $state --tab=$CMUX_TAB_ID --panel=$CMUX_PANEL_ID" & | ||
| end | ||
|
|
||
| function _cmux_ports_kick | ||
| test -S "$CMUX_SOCKET_PATH" || return 0 | ||
| test -n "$CMUX_TAB_ID" || return 0 | ||
| test -n "$CMUX_PANEL_ID" || return 0 | ||
|
|
||
| set -g _cmux_ports_last_run (date +%s) | ||
| _cmux_send "ports_kick --tab=$CMUX_TAB_ID --panel=$CMUX_PANEL_ID" & | ||
| end | ||
|
|
||
| function _cmux_preexec --on-event fish_preexec | ||
| # Resolve TTY name once | ||
| if test -z "$_cmux_tty_name" | ||
| set -g _cmux_tty_name (tty 2>/dev/null | string replace -r '^.*/' '') | ||
| end | ||
|
|
||
| set -g _cmux_cmd_start (date +%s) | ||
| _cmux_report_shell_activity_state running | ||
| _cmux_report_tty_once | ||
| _cmux_ports_kick | ||
| end | ||
|
|
||
| function _cmux_precmd --on-event fish_prompt | ||
| test -S "$CMUX_SOCKET_PATH" || return 0 | ||
| test -n "$CMUX_TAB_ID" || return 0 | ||
| test -n "$CMUX_PANEL_ID" || return 0 | ||
|
|
||
| _cmux_report_shell_activity_state prompt | ||
|
|
||
| # Resolve TTY name once | ||
| if test -z "$_cmux_tty_name" | ||
| set -g _cmux_tty_name (tty 2>/dev/null | string replace -r '^.*/' '') | ||
| end | ||
|
|
||
| _cmux_report_tty_once | ||
|
|
||
| set -l now (date +%s) | ||
| set -l pwd "$PWD" | ||
| set -l cmd_start "$_cmux_cmd_start" | ||
| set -g _cmux_cmd_start 0 | ||
|
|
||
| # CWD: keep the app in sync | ||
| if test "$pwd" != "$_cmux_pwd_last_pwd" | ||
| set -g _cmux_pwd_last_pwd "$pwd" | ||
| set -l qpwd (string replace -a '"' '\\"' "$pwd") | ||
| _cmux_send "report_pwd \"$qpwd\" --tab=$CMUX_TAB_ID --panel=$CMUX_PANEL_ID" & | ||
| end | ||
|
|
||
| # Ports: lightweight kick to the app's batched scanner | ||
| # - Periodic scan to avoid stale values | ||
| # - Forced scan when a long-running command returns | ||
| set -l cmd_dur 0 | ||
| if test -n "$cmd_start" && test "$cmd_start" != 0 | ||
| set cmd_dur (math "$now - $cmd_start") | ||
| end | ||
|
|
||
| if test "$cmd_dur" -ge 2 2>/dev/null || test (math "$now - $_cmux_ports_last_run") -ge 10 2>/dev/null | ||
| _cmux_ports_kick | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # cmux fish integration - auto-generated, do not modify | ||
| if test "$CMUX_SHELL_INTEGRATION" != "0" -a -n "$CMUX_SHELL_INTEGRATION_DIR" | ||
| set -l _cmux_fish "$CMUX_SHELL_INTEGRATION_DIR/cmux-fish-integration.fish" | ||
| test -r "$_cmux_fish"; and source "$_cmux_fish" | ||
| set -e _cmux_fish | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Fish
XDG_DATA_DIRSis set to.../fish/vendor_conf.dinstead of a base data dir, breaking vendor snippet discovery and potentially overriding default vendor paths when unset.Prompt for AI agents