Compare commits

...

7 Commits

Author SHA1 Message Date
Caleb Maclennan
d776f63f90
Merge c3f1794510 into 6e564503f1 2025-01-13 16:35:58 -05:00
Indrajit Raychaudhuri
6e564503f1 general: Apply quote styling consistency
Remove redundant quotes from comparisons and
variable expansions where they are not needed.

Also add style nits to comments and code.
2025-01-10 11:09:08 -06:00
Indrajit Raychaudhuri
427268c64f history-substring-search: Update history-substring-search module to current master 2024-12-26 22:32:57 -06:00
Indrajit Raychaudhuri
61d7dc9a72 completion: Update completion module to current master 2024-12-26 22:30:38 -06:00
Indrajit Raychaudhuri
2388b8f873 autosuggestions: Update autosuggestions module to 0.7.1 2024-12-26 22:27:46 -06:00
msdx321
9626ce2beb Add exception for VSCode env helper
Signed-off-by: msdx321 <msdx321@gmail.com>
2024-12-12 07:47:13 +05:30
Caleb Maclennan
c3f1794510
Allow tmux session name to be passed as env var
For normal usage this change should be a NOOP. However it enables the
use case where the user might want to predefine what session gets
connected to when the shell is launched. Running `zsh` will still net
you a connection to the last used tmux session or a new one named
"zprezto" if none exists. However `env tmux_session=myname zsh` will
connect you specifically to a session called 'myname' including creating
it if it doesn't exist.

This is particularly useful in window managers where a key binding might
open a terminal with a predefined session or even show a list of current
sessions and open a new terminal connected to that session.

The default session name may still be set using zstyle as documented.
2019-06-20 10:30:11 +03:00
11 changed files with 45 additions and 32 deletions

View File

@ -173,7 +173,7 @@ if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then
fi
# Disable color and theme in dumb terminals.
if [[ "$TERM" == 'dumb' ]]; then
if [[ $TERM == dumb ]]; then
zstyle ':prezto:*:*' color 'no'
zstyle ':prezto:module:prompt' theme 'off'
fi

@ -1 +1 @@
Subproject commit c3d4e576c9c86eac62884bd47c01f6faed043fc5
Subproject commit e52ee8ca55bcc56a17c828767a3f98f22a68d4eb

@ -1 +1 @@
Subproject commit 978e79e12c44b5b1d3e1e2920c537002087b82c2
Subproject commit c160d09fddd28ceb3af5cf80e9253af80e450d96

View File

@ -7,7 +7,7 @@
#
# Return if requirements are not found.
if [[ $TERM == 'dumb' ]]; then
if [[ $TERM == dumb ]]; then
return 1
fi

View File

@ -14,7 +14,7 @@
# paste had a regression. Additionally, 5.2 added bracketed-paste-url-magic
# which is generally better than url-quote-magic so we load that when possible.
autoload -Uz is-at-least
if [[ ${ZSH_VERSION} != 5.1.1 && ${TERM} != "dumb" ]]; then
if [[ $ZSH_VERSION != 5.1.1 && $TERM != dumb ]]; then
if is-at-least 5.2; then
autoload -Uz bracketed-paste-url-magic
zle -N bracketed-paste bracketed-paste-url-magic
@ -34,7 +34,8 @@ setopt COMBINING_CHARS # Combine zero-length punctuation characters (accent
# with the base character.
setopt INTERACTIVE_COMMENTS # Enable comments in interactive shell.
setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'.
unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed.
unsetopt MAIL_WARNING # Don't print a warning message if a mail file has
# been accessed.
# Allow mapping Ctrl+S and Ctrl+Q shortcuts
[[ -r ${TTY:-} && -w ${TTY:-} && $+commands[stty] == 1 ]] && stty -ixon <$TTY >$TTY

@ -1 +1 @@
Subproject commit 8dd05bfcc12b0cd1ee9ea64be725b3d9f713cf64
Subproject commit 87ce96b1862928d84b1afe7c173316614b30e301

View File

@ -7,7 +7,7 @@
#
# Return if requirements are not found.
if [[ "$TERM" == 'dumb' ]]; then
if [[ $TERM == dumb ]]; then
return 1
fi

View File

@ -7,7 +7,7 @@
#
# Return if requirements are not found.
if [[ "$TERM" == (dumb|linux|*bsd*|eterm*) ]]; then
if [[ $TERM == (dumb|linux|*bsd*|eterm*) ]]; then
return 1
fi
@ -60,7 +60,7 @@ function _terminal-set-titles-with-command {
local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}"
unset MATCH
if [[ "$TERM" == screen* ]]; then
if [[ $TERM == screen* ]]; then
set-multiplexer-title "$truncated_cmd"
fi
set-tab-title "$truncated_cmd"
@ -78,7 +78,7 @@ function _terminal-set-titles-with-path {
local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}"
unset MATCH
if [[ "$TERM" == screen* ]]; then
if [[ $TERM == screen* ]]; then
set-multiplexer-title "$truncated_path"
fi
set-tab-title "$truncated_path"
@ -89,7 +89,7 @@ function _terminal-set-titles-with-path {
autoload -Uz add-zsh-hook
# Set up the Apple Terminal.
if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \
if [[ $TERM_PROGRAM == Apple_Terminal ]] \
&& ( ! [[ -n "$STY" || -n "$TMUX" || -n "$DVTM" ]] )
then
# Sets the Terminal.app current working directory before the prompt is

View File

@ -31,6 +31,17 @@ You can change the default session name with:
zstyle ':prezto:module:tmux:session' name '<YOUR DEFAULT SESSION NAME>'
```
A session name may also be specified in an environment variable before ZSH runs.
```sh
env tmux_session='<SESSION NAME>' zsh
```
This can be useful for example to connect to a specific remote session
connecting via SSH (note that OpenSSH needs to be configured to pass on that
environment variable). It can also be used with window managers to set keybindings
that launch terminals with specific sessions.
With `auto-start` enabled, you may want to control how multiple sessions are
managed. The `destroy-unattached` option of tmux controls if the unattached
sessions must be kept alive, making sessions available for later use, configured

View File

@ -23,22 +23,23 @@ if ([[ "$TERM_PROGRAM" = 'iTerm.app' ]] && \
_tmux_iterm_integration='-CC'
fi
if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" && "$TERM_PROGRAM" != "vscode" && "$TERMINAL_EMULATOR" != "JetBrains-JediTerm" ]] && ( \
if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" && -z "$VSCODE_RESOLVING_ENVIRONMENT" && "$TERM_PROGRAM" != "vscode" && "$TERMINAL_EMULATOR" != "JetBrains-JediTerm" ]] && ( \
( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) ||
( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \
); then
tmux start-server
# Create a 'prezto' session if no session has been defined in tmux.conf.
if ! tmux has-session 2> /dev/null; then
zstyle -s ':prezto:module:tmux:session' name tmux_session || tmux_session='prezto'
# Make sure we have a session to connect to, either named via an environment
# variable, the default style as documented, or 'prezto' for last resort
[[ -z "${tmux_session:// }" ]] && zstyle -s ':prezto:module:tmux:session' name tmux_session || : ${tmux_session:=prezto}
if ! tmux has-session -t "$tmux_session" 2> /dev/null; then
tmux \
new-session -d -s "$tmux_session" \; \
set-option -t "$tmux_session" destroy-unattached off &> /dev/null
fi
# Attach to the 'prezto' session or to the last session used. (detach first)
exec tmux $_tmux_iterm_integration attach-session -d
# Attach to the session name requested in an environment variable or the default (detaching others)
exec tmux $_tmux_iterm_integration attach-session -t "$tmux_session" -d
fi
#

View File

@ -14,6 +14,6 @@ SAYINGS=(
)
# Print a randomly-chosen message:
echo $SAYINGS[$(($RANDOM % ${#SAYINGS} + 1))]
echo $SAYINGS[$(($RANDOM % $#SAYINGS + 1))]
} >&2