Download src-tauri/src/modules/pty/scripts/bashrc.bash from lekmikdok/termix: direct link, hf CLI and curl.
- Browser
- Download file 2.79 kB
-
https://huggingface.co/spaces/lekmikdok/termix/resolve/main/src-tauri/src/modules/pty/scripts/bashrc.bash
- Command line
-
hf download hf://spaces/lekmikdok/termix/src-tauri/src/modules/pty/scripts/bashrc.bash
-
curl -L -o bashrc.bash https://huggingface.co/spaces/lekmikdok/termix/resolve/main/src-tauri/src/modules/pty/scripts/bashrc.bash
2.79 kB
| # terax-shell-integration (bashrc) | |
| # | |
| # Differences vs zsh integration: | |
| # - We emulate login-shell init manually (/etc/profile, profile files) because | |
| # bash ignores --rcfile when started with -l. | |
| # - Pre-exec marker uses PS0 (bash 4.4+). On older bash (macOS default 3.2) we | |
| # skip it — a fragile DEBUG-trap alternative would clobber the user's own | |
| # traps and interact badly with debuggers. | |
| if [ -z "$__TERAX_HOOKS_LOADED" ]; then | |
| __TERAX_HOOKS_LOADED=1 | |
| [ -f /etc/profile ] && source /etc/profile | |
| [ -f /etc/bashrc ] && source /etc/bashrc | |
| if [ -f "$HOME/.bash_profile" ]; then | |
| source "$HOME/.bash_profile" | |
| elif [ -f "$HOME/.bash_login" ]; then | |
| source "$HOME/.bash_login" | |
| elif [ -f "$HOME/.profile" ]; then | |
| source "$HOME/.profile" | |
| fi | |
| # .bashrc may have been sourced already by .bash_profile; sourcing again is | |
| # safe for idempotent rc files (the common case). If yours has side effects | |
| # on reload, guard with a flag. | |
| [ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc" | |
| _terax_urlencode() { | |
| local LC_ALL=C s="$1" i c | |
| for (( i=0; i<${#s}; i++ )); do | |
| c="${s:i:1}" | |
| case "$c" in | |
| [a-zA-Z0-9/._~-]) printf '%s' "$c" ;; | |
| *) printf '%%%02X' "'$c" ;; | |
| esac | |
| done | |
| } | |
| _terax_precmd() { | |
| local _terax_ret=$? | |
| printf '\e]133;D;%s\e\\' "$_terax_ret" | |
| printf '\e]7;file://%s%s\e\\' "${HOSTNAME:-$(uname -n 2>/dev/null)}" "$(_terax_urlencode "$PWD")" | |
| if [ -z "$__TERAX_PS1_INJECTED" ]; then | |
| PS1='\[\e]133;B\e\\\]'"$PS1" | |
| __TERAX_PS1_INJECTED=1 | |
| fi | |
| printf '\e]133;A\e\\' | |
| } | |
| case ":${PROMPT_COMMAND:-}:" in | |
| *":_terax_precmd:"*) ;; | |
| *) PROMPT_COMMAND="_terax_precmd${PROMPT_COMMAND:+;$PROMPT_COMMAND}" ;; | |
| esac | |
| # Pre-exec marker via PS0 (bash 4.4+). PS0 is expanded just before a command | |
| # runs — cleaner than a DEBUG trap, which would clobber user traps and fire | |
| # on every command including inside PROMPT_COMMAND. | |
| if [ "${BASH_VERSINFO[0]:-0}" -gt 4 ] \ | |
| || { [ "${BASH_VERSINFO[0]:-0}" -eq 4 ] && [ "${BASH_VERSINFO[1]:-0}" -ge 4 ]; }; then | |
| PS0='\[\e]133;C\e\\\]'"${PS0:-}" | |
| fi | |
| # terax_open: open file in editor tab via OSC 8888. | |
| # Usage: terax_open <file> | |
| terax_open() { | |
| local file="$1" | |
| if [ -z "$file" ]; then | |
| printf "usage: terax_open <file>\n" >&2 | |
| return 1 | |
| fi | |
| # Resolve relative paths relative to PWD. | |
| if [[ "$file" != /* ]]; then | |
| file="$PWD/$file" | |
| fi | |
| # Check that the path exists and is a regular file. | |
| if [ ! -f "$file" ]; then | |
| printf "terax_open: not a file: %s\n" "$file" >&2 | |
| return 1 | |
| fi | |
| # Emit OSC 8888 with URL-encoded file path. | |
| printf '\e]8888;file=%s\e\\' "$(_terax_urlencode "$file")" | |
| } | |
| # Shorthand alias. | |
| alias tp='terax_open' | |
| _terax_precmd | |
| fi | |
| : | |