From cb7428f4cda1a56e0b1f849ddb259f89dd6ebc9e Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 29 Oct 2021 12:19:18 +0200 Subject: [PATCH] allow tmux in terminals that don't use pseudo-ttys --- home/zshrc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/home/zshrc b/home/zshrc index 518eb30..6cd9328 100644 --- a/home/zshrc +++ b/home/zshrc @@ -34,13 +34,20 @@ setopt path_dirs # Perform path search even on command names with setopt rc_quotes # 'it''s okay' becomes "it's okay" unsetopt flow_control # Disable start/stop characters in shell editor. -if [ "$SHLVL" -le 1 ] && [ "$TERM" = "${TERM#screen}" ] && [ "$TERM" = "${TERM#tmux}" ]; then - if (( $+commands[tmux] )); then +function { + if [ "$SHLVL" -le 1 ] \ + && [ "${TERM#screen}" = "$TERM" ] \ + && [ "${TERM#tmux}" = "$TERM" ] \ + && (( $+commands[tmux] )) + then # create a new session called "what" or attach if it already exists - LANG="en_US.UTF-8" TZ=":/etc/localtime" tmux new -A -s what && exit + local env=(LANG="en_US.UTF-8" TZ=":/etc/localtime") + local cmd=(tmux new -A -s what) + [ "${TTY#/dev/cons}" = "$TTY" ] || cmd=(script -qfec "$cmd" /dev/null) + env $env $cmd && exit printf '\e[91m\ntmux died (%i), continuing...\n\e[0m\n' $? fi -fi +} autoload -U zmv autoload -U zrecompile