mirror of https://github.com/sgoudham/dotfiles.git
refactor(wezterm): ignore wezterm shell files
These only work on zsh and bash anywaysmain
parent
ea4de175b3
commit
1b5b23b72f
@ -1 +1,3 @@
|
|||||||
wezterm-bar
|
wezterm-bar
|
||||||
|
wezterm_terminfo
|
||||||
|
wezterm.sh
|
@ -1,463 +0,0 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
# This file hooks up shell integration for wezterm.
|
|
||||||
# It is suitable for zsh and bash.
|
|
||||||
#
|
|
||||||
# Although wezterm is mentioned here, the sequences used are not wezterm
|
|
||||||
# specific and may provide the same functionality for other terminals. Most
|
|
||||||
# terminals are good at ignoring OSC sequences that they don't understand, but
|
|
||||||
# if not there are some bypasses:
|
|
||||||
#
|
|
||||||
# WEZTERM_SHELL_SKIP_ALL - disables all
|
|
||||||
# WEZTERM_SHELL_SKIP_SEMANTIC_ZONES - disables zones
|
|
||||||
# WEZTERM_SHELL_SKIP_CWD - disables OSC 7 cwd setting
|
|
||||||
|
|
||||||
# shellcheck disable=SC2166
|
|
||||||
if [ -z "${BASH_VERSION}" -a -z "${ZSH_NAME}" ] ; then
|
|
||||||
# Only for bash or zsh
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${WEZTERM_SHELL_SKIP_ALL}" = "1" ] ; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $- != *i* ]] ; then
|
|
||||||
# Shell integration is only useful in interactive sessions
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$TERM" in
|
|
||||||
linux | dumb )
|
|
||||||
# Avoid terminals that don't like OSC sequences
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# This function wraps bash-preexec.sh so that it can be included verbatim
|
|
||||||
# in this file, even though it uses `return` to short-circuit in some cases.
|
|
||||||
__wezterm_install_bash_prexec() {
|
|
||||||
|
|
||||||
# bash-preexec.sh -- Bash support for ZSH-like 'preexec' and 'precmd' functions.
|
|
||||||
# https://github.com/rcaloras/bash-preexec
|
|
||||||
#
|
|
||||||
# 'preexec' functions are executed before each interactive command is
|
|
||||||
# executed, with the interactive command as its argument. The 'precmd'
|
|
||||||
# function is executed before each prompt is displayed.
|
|
||||||
#
|
|
||||||
# Author: Ryan Caloras (ryan@bashhub.com)
|
|
||||||
# Forked from Original Author: Glyph Lefkowitz
|
|
||||||
#
|
|
||||||
# V0.4.1
|
|
||||||
#
|
|
||||||
|
|
||||||
# General Usage:
|
|
||||||
#
|
|
||||||
# 1. Source this file at the end of your bash profile so as not to interfere
|
|
||||||
# with anything else that's using PROMPT_COMMAND.
|
|
||||||
#
|
|
||||||
# 2. Add any precmd or preexec functions by appending them to their arrays:
|
|
||||||
# e.g.
|
|
||||||
# precmd_functions+=(my_precmd_function)
|
|
||||||
# precmd_functions+=(some_other_precmd_function)
|
|
||||||
#
|
|
||||||
# preexec_functions+=(my_preexec_function)
|
|
||||||
#
|
|
||||||
# 3. Consider changing anything using the DEBUG trap or PROMPT_COMMAND
|
|
||||||
# to use preexec and precmd instead. Preexisting usages will be
|
|
||||||
# preserved, but doing so manually may be less surprising.
|
|
||||||
#
|
|
||||||
# Note: This module requires two Bash features which you must not otherwise be
|
|
||||||
# using: the "DEBUG" trap, and the "PROMPT_COMMAND" variable. If you override
|
|
||||||
# either of these after bash-preexec has been installed it will most likely break.
|
|
||||||
|
|
||||||
# Make sure this is bash that's running and return otherwise.
|
|
||||||
if [[ -z "${BASH_VERSION:-}" ]]; then
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Avoid duplicate inclusion
|
|
||||||
if [[ "${__bp_imported:-}" == "defined" ]]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
__bp_imported="defined"
|
|
||||||
|
|
||||||
# Should be available to each precmd and preexec
|
|
||||||
# functions, should they want it. $? and $_ are available as $? and $_, but
|
|
||||||
# $PIPESTATUS is available only in a copy, $BP_PIPESTATUS.
|
|
||||||
# TODO: Figure out how to restore PIPESTATUS before each precmd or preexec
|
|
||||||
# function.
|
|
||||||
__bp_last_ret_value="$?"
|
|
||||||
BP_PIPESTATUS=("${PIPESTATUS[@]}")
|
|
||||||
__bp_last_argument_prev_command="$_"
|
|
||||||
|
|
||||||
__bp_inside_precmd=0
|
|
||||||
__bp_inside_preexec=0
|
|
||||||
|
|
||||||
# Initial PROMPT_COMMAND string that is removed from PROMPT_COMMAND post __bp_install
|
|
||||||
__bp_install_string=$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install'
|
|
||||||
|
|
||||||
# Fails if any of the given variables are readonly
|
|
||||||
# Reference https://stackoverflow.com/a/4441178
|
|
||||||
__bp_require_not_readonly() {
|
|
||||||
local var
|
|
||||||
for var; do
|
|
||||||
if ! ( unset "$var" 2> /dev/null ); then
|
|
||||||
echo "bash-preexec requires write access to ${var}" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
|
|
||||||
# so we can accurately invoke preexec with a command from our
|
|
||||||
# history even if it starts with a space.
|
|
||||||
__bp_adjust_histcontrol() {
|
|
||||||
local histcontrol
|
|
||||||
histcontrol="${HISTCONTROL//ignorespace}"
|
|
||||||
# Replace ignoreboth with ignoredups
|
|
||||||
if [[ "$histcontrol" == *"ignoreboth"* ]]; then
|
|
||||||
histcontrol="ignoredups:${histcontrol//ignoreboth}"
|
|
||||||
fi;
|
|
||||||
export HISTCONTROL="$histcontrol"
|
|
||||||
}
|
|
||||||
|
|
||||||
# This variable describes whether we are currently in "interactive mode";
|
|
||||||
# i.e. whether this shell has just executed a prompt and is waiting for user
|
|
||||||
# input. It documents whether the current command invoked by the trace hook is
|
|
||||||
# run interactively by the user; it's set immediately after the prompt hook,
|
|
||||||
# and unset as soon as the trace hook is run.
|
|
||||||
__bp_preexec_interactive_mode=""
|
|
||||||
|
|
||||||
# Trims leading and trailing whitespace from $2 and writes it to the variable
|
|
||||||
# name passed as $1
|
|
||||||
__bp_trim_whitespace() {
|
|
||||||
local var=${1:?} text=${2:-}
|
|
||||||
text="${text#"${text%%[![:space:]]*}"}" # remove leading whitespace characters
|
|
||||||
text="${text%"${text##*[![:space:]]}"}" # remove trailing whitespace characters
|
|
||||||
printf -v "$var" '%s' "$text"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Trims whitespace and removes any leading or trailing semicolons from $2 and
|
|
||||||
# writes the resulting string to the variable name passed as $1. Used for
|
|
||||||
# manipulating substrings in PROMPT_COMMAND
|
|
||||||
__bp_sanitize_string() {
|
|
||||||
local var=${1:?} text=${2:-} sanitized
|
|
||||||
__bp_trim_whitespace sanitized "$text"
|
|
||||||
sanitized=${sanitized%;}
|
|
||||||
sanitized=${sanitized#;}
|
|
||||||
__bp_trim_whitespace sanitized "$sanitized"
|
|
||||||
printf -v "$var" '%s' "$sanitized"
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function is installed as part of the PROMPT_COMMAND;
|
|
||||||
# It sets a variable to indicate that the prompt was just displayed,
|
|
||||||
# to allow the DEBUG trap to know that the next command is likely interactive.
|
|
||||||
__bp_interactive_mode() {
|
|
||||||
__bp_preexec_interactive_mode="on";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# This function is installed as part of the PROMPT_COMMAND.
|
|
||||||
# It will invoke any functions defined in the precmd_functions array.
|
|
||||||
__bp_precmd_invoke_cmd() {
|
|
||||||
# Save the returned value from our last command, and from each process in
|
|
||||||
# its pipeline. Note: this MUST be the first thing done in this function.
|
|
||||||
__bp_last_ret_value="$?" BP_PIPESTATUS=("${PIPESTATUS[@]}")
|
|
||||||
|
|
||||||
# Don't invoke precmds if we are inside an execution of an "original
|
|
||||||
# prompt command" by another precmd execution loop. This avoids infinite
|
|
||||||
# recursion.
|
|
||||||
if (( __bp_inside_precmd > 0 )); then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
local __bp_inside_precmd=1
|
|
||||||
|
|
||||||
# Invoke every function defined in our function array.
|
|
||||||
local precmd_function
|
|
||||||
for precmd_function in "${precmd_functions[@]}"; do
|
|
||||||
|
|
||||||
# Only execute this function if it actually exists.
|
|
||||||
# Test existence of functions with: declare -[Ff]
|
|
||||||
if type -t "$precmd_function" 1>/dev/null; then
|
|
||||||
__bp_set_ret_value "$__bp_last_ret_value" "$__bp_last_argument_prev_command"
|
|
||||||
# Quote our function invocation to prevent issues with IFS
|
|
||||||
"$precmd_function"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return $__bp_last_ret_value
|
|
||||||
}
|
|
||||||
|
|
||||||
# Sets a return value in $?. We may want to get access to the $? variable in our
|
|
||||||
# precmd functions. This is available for instance in zsh. We can simulate it in bash
|
|
||||||
# by setting the value here.
|
|
||||||
__bp_set_ret_value() {
|
|
||||||
return ${1:-}
|
|
||||||
}
|
|
||||||
|
|
||||||
__bp_in_prompt_command() {
|
|
||||||
|
|
||||||
local prompt_command_array
|
|
||||||
IFS=$'\n;' read -rd '' -a prompt_command_array <<< "$PROMPT_COMMAND"
|
|
||||||
|
|
||||||
local trimmed_arg
|
|
||||||
__bp_trim_whitespace trimmed_arg "${1:-}"
|
|
||||||
|
|
||||||
local command trimmed_command
|
|
||||||
for command in "${prompt_command_array[@]:-}"; do
|
|
||||||
__bp_trim_whitespace trimmed_command "$command"
|
|
||||||
if [[ "$trimmed_command" == "$trimmed_arg" ]]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function is installed as the DEBUG trap. It is invoked before each
|
|
||||||
# interactive prompt display. Its purpose is to inspect the current
|
|
||||||
# environment to attempt to detect if the current command is being invoked
|
|
||||||
# interactively, and invoke 'preexec' if so.
|
|
||||||
__bp_preexec_invoke_exec() {
|
|
||||||
|
|
||||||
# Save the contents of $_ so that it can be restored later on.
|
|
||||||
# https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
|
|
||||||
__bp_last_argument_prev_command="${1:-}"
|
|
||||||
# Don't invoke preexecs if we are inside of another preexec.
|
|
||||||
if (( __bp_inside_preexec > 0 )); then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
local __bp_inside_preexec=1
|
|
||||||
|
|
||||||
# Checks if the file descriptor is not standard out (i.e. '1')
|
|
||||||
# __bp_delay_install checks if we're in test. Needed for bats to run.
|
|
||||||
# Prevents preexec from being invoked for functions in PS1
|
|
||||||
if [[ ! -t 1 && -z "${__bp_delay_install:-}" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "${COMP_LINE:-}" ]]; then
|
|
||||||
# We're in the middle of a completer. This obviously can't be
|
|
||||||
# an interactively issued command.
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [[ -z "${__bp_preexec_interactive_mode:-}" ]]; then
|
|
||||||
# We're doing something related to displaying the prompt. Let the
|
|
||||||
# prompt set the title instead of me.
|
|
||||||
return
|
|
||||||
else
|
|
||||||
# If we're in a subshell, then the prompt won't be re-displayed to put
|
|
||||||
# us back into interactive mode, so let's not set the variable back.
|
|
||||||
# In other words, if you have a subshell like
|
|
||||||
# (sleep 1; sleep 2)
|
|
||||||
# You want to see the 'sleep 2' as a set_command_title as well.
|
|
||||||
if [[ 0 -eq "${BASH_SUBSHELL:-}" ]]; then
|
|
||||||
__bp_preexec_interactive_mode=""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if __bp_in_prompt_command "${BASH_COMMAND:-}"; then
|
|
||||||
# If we're executing something inside our prompt_command then we don't
|
|
||||||
# want to call preexec. Bash prior to 3.1 can't detect this at all :/
|
|
||||||
__bp_preexec_interactive_mode=""
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
local this_command
|
|
||||||
this_command=$(
|
|
||||||
export LC_ALL=C
|
|
||||||
HISTTIMEFORMAT= builtin history 1 | sed '1 s/^ *[0-9][0-9]*[* ] //'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Sanity check to make sure we have something to invoke our function with.
|
|
||||||
if [[ -z "$this_command" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Invoke every function defined in our function array.
|
|
||||||
local preexec_function
|
|
||||||
local preexec_function_ret_value
|
|
||||||
local preexec_ret_value=0
|
|
||||||
for preexec_function in "${preexec_functions[@]:-}"; do
|
|
||||||
|
|
||||||
# Only execute each function if it actually exists.
|
|
||||||
# Test existence of function with: declare -[fF]
|
|
||||||
if type -t "$preexec_function" 1>/dev/null; then
|
|
||||||
__bp_set_ret_value ${__bp_last_ret_value:-}
|
|
||||||
# Quote our function invocation to prevent issues with IFS
|
|
||||||
"$preexec_function" "$this_command"
|
|
||||||
preexec_function_ret_value="$?"
|
|
||||||
if [[ "$preexec_function_ret_value" != 0 ]]; then
|
|
||||||
preexec_ret_value="$preexec_function_ret_value"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Restore the last argument of the last executed command, and set the return
|
|
||||||
# value of the DEBUG trap to be the return code of the last preexec function
|
|
||||||
# to return an error.
|
|
||||||
# If `extdebug` is enabled a non-zero return value from any preexec function
|
|
||||||
# will cause the user's command not to execute.
|
|
||||||
# Run `shopt -s extdebug` to enable
|
|
||||||
__bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"
|
|
||||||
}
|
|
||||||
|
|
||||||
__bp_install() {
|
|
||||||
# Exit if we already have this installed.
|
|
||||||
if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
trap '__bp_preexec_invoke_exec "$_"' DEBUG
|
|
||||||
|
|
||||||
# Preserve any prior DEBUG trap as a preexec function
|
|
||||||
local prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}")
|
|
||||||
unset __bp_trap_string
|
|
||||||
if [[ -n "$prior_trap" ]]; then
|
|
||||||
eval '__bp_original_debug_trap() {
|
|
||||||
'"$prior_trap"'
|
|
||||||
}'
|
|
||||||
preexec_functions+=(__bp_original_debug_trap)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Adjust our HISTCONTROL Variable if needed.
|
|
||||||
__bp_adjust_histcontrol
|
|
||||||
|
|
||||||
# Issue #25. Setting debug trap for subshells causes sessions to exit for
|
|
||||||
# backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash.
|
|
||||||
#
|
|
||||||
# Disabling this by default. It can be enabled by setting this variable.
|
|
||||||
if [[ -n "${__bp_enable_subshells:-}" ]]; then
|
|
||||||
|
|
||||||
# Set so debug trap will work be invoked in subshells.
|
|
||||||
set -o functrace > /dev/null 2>&1
|
|
||||||
shopt -s extdebug > /dev/null 2>&1
|
|
||||||
fi;
|
|
||||||
|
|
||||||
local existing_prompt_command
|
|
||||||
# Remove setting our trap install string and sanitize the existing prompt command string
|
|
||||||
existing_prompt_command="${PROMPT_COMMAND//$__bp_install_string[;$'\n']}" # Edge case of appending to PROMPT_COMMAND
|
|
||||||
existing_prompt_command="${existing_prompt_command//$__bp_install_string}"
|
|
||||||
__bp_sanitize_string existing_prompt_command "$existing_prompt_command"
|
|
||||||
|
|
||||||
# Install our hooks in PROMPT_COMMAND to allow our trap to know when we've
|
|
||||||
# actually entered something.
|
|
||||||
PROMPT_COMMAND=$'__bp_precmd_invoke_cmd\n'
|
|
||||||
if [[ -n "$existing_prompt_command" ]]; then
|
|
||||||
PROMPT_COMMAND+=${existing_prompt_command}$'\n'
|
|
||||||
fi;
|
|
||||||
PROMPT_COMMAND+='__bp_interactive_mode'
|
|
||||||
|
|
||||||
# Add two functions to our arrays for convenience
|
|
||||||
# of definition.
|
|
||||||
precmd_functions+=(precmd)
|
|
||||||
preexec_functions+=(preexec)
|
|
||||||
|
|
||||||
# Invoke our two functions manually that were added to $PROMPT_COMMAND
|
|
||||||
__bp_precmd_invoke_cmd
|
|
||||||
__bp_interactive_mode
|
|
||||||
}
|
|
||||||
|
|
||||||
# Sets an installation string as part of our PROMPT_COMMAND to install
|
|
||||||
# after our session has started. This allows bash-preexec to be included
|
|
||||||
# at any point in our bash profile.
|
|
||||||
__bp_install_after_session_init() {
|
|
||||||
# bash-preexec needs to modify these variables in order to work correctly
|
|
||||||
# if it can't, just stop the installation
|
|
||||||
__bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return
|
|
||||||
|
|
||||||
local sanitized_prompt_command
|
|
||||||
__bp_sanitize_string sanitized_prompt_command "$PROMPT_COMMAND"
|
|
||||||
if [[ -n "$sanitized_prompt_command" ]]; then
|
|
||||||
PROMPT_COMMAND=${sanitized_prompt_command}$'\n'
|
|
||||||
fi;
|
|
||||||
PROMPT_COMMAND+=${__bp_install_string}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run our install so long as we're not delaying it.
|
|
||||||
if [[ -z "${__bp_delay_install:-}" ]]; then
|
|
||||||
__bp_install_after_session_init
|
|
||||||
fi;
|
|
||||||
|
|
||||||
} # end of __wezterm_install_bash_prexec
|
|
||||||
|
|
||||||
# blesh provides it's own preexec mechanism which is recommended over bash-preexec
|
|
||||||
# See https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A71-Introduction#user-content-fn-blehook for more details
|
|
||||||
if [[ ! -n "$BLE_VERSION" ]]; then
|
|
||||||
__wezterm_install_bash_prexec
|
|
||||||
fi
|
|
||||||
|
|
||||||
# This function emits an OSC 7 sequence to inform the terminal
|
|
||||||
# of the current working directory. It prefers to use a helper
|
|
||||||
# command provided by wezterm if wezterm is installed, but falls
|
|
||||||
# back to a simple printf command otherwise.
|
|
||||||
__wezterm_osc7() {
|
|
||||||
if hash wezterm 2>/dev/null ; then
|
|
||||||
wezterm set-working-directory 2>/dev/null && return 0
|
|
||||||
# If the command failed (perhaps the installed wezterm
|
|
||||||
# is too old?) then fall back to the simple version below.
|
|
||||||
fi
|
|
||||||
printf "\033]7;file://%s%s\033\\" "${HOSTNAME}" "${PWD}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# The semantic precmd and prexec functions generate semantic
|
|
||||||
# zones, marking up the prompt, the user input and the command
|
|
||||||
# output so that the terminal can better reason about the display.
|
|
||||||
__wezterm_semantic_precmd_executing=""
|
|
||||||
__wezterm_semantic_precmd() {
|
|
||||||
local ret="$?"
|
|
||||||
if [[ "$__wezterm_semantic_precmd_executing" != "0" ]] ; then
|
|
||||||
__wezterm_save_ps1="$PS1"
|
|
||||||
__wezterm_save_ps2="$PS2"
|
|
||||||
# Markup the left and right prompts so that the terminal
|
|
||||||
# knows that they are semantically prompt output.
|
|
||||||
if [[ -n "$ZSH_NAME" ]] ; then
|
|
||||||
PS1=$'%{\e]133;P;k=i\a%}'$PS1$'%{\e]133;B\a%}'
|
|
||||||
PS2=$'%{\e]133;P;k=s\a%}'$PS2$'%{\e]133;B\a%}'
|
|
||||||
else
|
|
||||||
PS1='\[\e]133;P;k=i\a\]'$PS1'\[\e]133;B\a\]'
|
|
||||||
PS2='\[\e]133;P;k=s\a\]'$PS2'\[\e]133;B\a\]'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ "$__wezterm_semantic_precmd_executing" != "" ]] ; then
|
|
||||||
# Report last command status
|
|
||||||
printf "\033]133;D;%s;aid=%s\007" "$ret" "$$"
|
|
||||||
fi
|
|
||||||
# Fresh line and start the prompt
|
|
||||||
printf "\033]133;A;cl=m;aid=%s\007" "$$"
|
|
||||||
__wezterm_semantic_precmd_executing=0
|
|
||||||
}
|
|
||||||
|
|
||||||
function __wezterm_semantic_preexec() {
|
|
||||||
# Restore the original PS1/PS2
|
|
||||||
PS1="$__wezterm_save_ps1"
|
|
||||||
PS2="$__wezterm_save_ps2"
|
|
||||||
# Indicate that the command output begins here
|
|
||||||
printf "\033]133;C;\007"
|
|
||||||
__wezterm_semantic_precmd_executing=1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register the various functions; take care to perform osc7 after
|
|
||||||
# the semantic zones as we don't want to perturb the last command
|
|
||||||
# status before we've had a chance to report it to the terminal
|
|
||||||
if [[ -z "${WEZTERM_SHELL_SKIP_SEMANTIC_ZONES}" ]]; then
|
|
||||||
if [[ -n "$BLE_VERSION" ]]; then
|
|
||||||
blehook PRECMD+=__wezterm_semantic_precmd
|
|
||||||
blehook PREEXEC+=__wezterm_semantic_preexec
|
|
||||||
else
|
|
||||||
precmd_functions+=(__wezterm_semantic_precmd)
|
|
||||||
preexec_functions+=(__wezterm_semantic_preexec)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${WEZTERM_SHELL_SKIP_CWD}" ]] ; then
|
|
||||||
if [[ -n "$BLE_VERSION" ]]; then
|
|
||||||
blehook PRECMD+=__wezterm_osc7
|
|
||||||
else
|
|
||||||
precmd_functions+=(__wezterm_osc7)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
true
|
|
@ -1,89 +0,0 @@
|
|||||||
# This is Wez's term definition for wezterm.
|
|
||||||
# It was reconstructed via infocmp from file: /lib/terminfo/x/xterm-256color
|
|
||||||
# and then has some additions in the top few lines (until the line starting
|
|
||||||
# with am).
|
|
||||||
# Tc: true color boolean for tmux
|
|
||||||
# sitm/ritm: italics
|
|
||||||
# Ms modifies the selection/clipboard. Its parameters are
|
|
||||||
# p1 = the storage unit (clipboard, selection or cut buffer)
|
|
||||||
# p2 = the base64-encoded clipboard content.
|
|
||||||
#
|
|
||||||
# Ss is used to set the cursor style as described by the DECSCUSR
|
|
||||||
# function to a block or underline.
|
|
||||||
# Se resets the cursor style to the terminal power-on default.
|
|
||||||
# Smulx defines kitty style underline escape sequence support
|
|
||||||
#
|
|
||||||
# hs, dsl, fsl, tsl are used by nvim to amend the "status line".
|
|
||||||
# These are not normally present for xterm and have assumed values
|
|
||||||
# when TERM==xterm. When using this terminfo file that assumption is not
|
|
||||||
# true and that functionality is broken.
|
|
||||||
# We follow the foot's terminfo settings for these, based on
|
|
||||||
# https://codeberg.org/dnkl/foot/pulls/243/files
|
|
||||||
# although we use OSC 0 for the title rather than OSC 2.
|
|
||||||
# https://github.com/neovim/neovim/issues/20706
|
|
||||||
# https://github.com/wez/wezterm/issues/2635
|
|
||||||
wezterm|Wez's terminal emulator,
|
|
||||||
Tc,
|
|
||||||
hs,
|
|
||||||
sitm=\E[3m, ritm=\E[23m,
|
|
||||||
Cr=\E]112\007, Cs=\E]12;%p1%s\007, Ms=\E]52;%p1%s;%p2%s\007, Se=\E[2\sq,
|
|
||||||
Ss=\E[%p1%d\sq,
|
|
||||||
Smulx=\E[4:%p1%dm,
|
|
||||||
Sync=\E[?2026%?%p1%{1}%-%tl%eh,
|
|
||||||
Setulc=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%d%;m,
|
|
||||||
Smol=\E[53m,
|
|
||||||
am, bce, ccc, km, mc5i, mir, msgr, npc, xenl,
|
|
||||||
colors#0x100, cols#80, it#8, lines#24, pairs#0x7fff,
|
|
||||||
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
|
||||||
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
|
|
||||||
clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r,
|
|
||||||
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
|
|
||||||
cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
|
|
||||||
cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
|
|
||||||
cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
|
|
||||||
dl=\E[%p1%dM, dl1=\E[M, dsl=\E]2;\E\\,
|
|
||||||
ech=\E[%p1%dX, ed=\E[J, el=\E[K,
|
|
||||||
el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, fsl=\E\\, home=\E[H,
|
|
||||||
hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
|
|
||||||
il=\E[%p1%dL, il1=\E[L, ind=\n, indn=\E[%p1%dS,
|
|
||||||
initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
|
|
||||||
invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kDC=\E[3;2~,
|
|
||||||
kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D,
|
|
||||||
kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kb2=\EOE, kbs=^?,
|
|
||||||
kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
|
|
||||||
kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~,
|
|
||||||
kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q,
|
|
||||||
kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~,
|
|
||||||
kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~,
|
|
||||||
kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~,
|
|
||||||
kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S,
|
|
||||||
kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~,
|
|
||||||
kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~,
|
|
||||||
kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q,
|
|
||||||
kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~,
|
|
||||||
kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~,
|
|
||||||
kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~,
|
|
||||||
kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q,
|
|
||||||
kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
|
|
||||||
kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~,
|
|
||||||
kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~,
|
|
||||||
kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~,
|
|
||||||
kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~,
|
|
||||||
kind=\E[1;2B, knp=\E[6~, kpp=\E[5~,
|
|
||||||
kri=\E[1;2A, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El,
|
|
||||||
memu=\Em, oc=\E]104\007, op=\E[39;49m, rc=\E8,
|
|
||||||
rep=%p1%c\E[%p2%{1}%-%db, rev=\E[7m, ri=\EM,
|
|
||||||
rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E(B, rmam=\E[?7l,
|
|
||||||
rmcup=\E[?1049l\E[23;0;0t, rmir=\E[4l, rmkx=\E[?1l\E>,
|
|
||||||
rmm=\E[?1034l, rmso=\E[27m, rmul=\E[24m, rmxx=\E[29m,
|
|
||||||
rs1=\Ec\E]104\007, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7,
|
|
||||||
setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
|
|
||||||
setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
|
|
||||||
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
|
|
||||||
sgr0=\E(B\E[m, sitm=\E[3m, smacs=\E(0, smam=\E[?7h,
|
|
||||||
smcup=\E[?1049h\E[22;0;0t, smir=\E[4h, smkx=\E[?1h\E=,
|
|
||||||
smm=\E[?1034h, smso=\E[7m, smul=\E[4m, smxx=\E[9m,
|
|
||||||
tbc=\E[3g, tsl=\E]0;, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?%[;0123456789]c,
|
|
||||||
u9=\E[c, vpa=\E[%i%p1%dd, XM=\E[?1003;1006%?%p1%{1}%=%th%el%;,
|
|
||||||
kmous=\E[<, XM=\E[?1006;1000%?%p1%{1}%=%th%el%;,
|
|
||||||
xm=\E[<%i%p3%d;%p1%d;%p2%d;%?%p4%tM%em%;,
|
|
Loading…
Reference in New Issue