This commit is contained in:
Johannes Findeisen 2025-07-23 01:25:04 +02:00
commit 712367eb98
4 changed files with 47 additions and 10 deletions

7
.env
View file

@ -3,10 +3,15 @@
# Example: can be shell compatible stuff like export, alias etc. or just
# define variables like FOO=BAR
#
# You should put private stuff to .penv. It is handled the same way as this
# You should put private stuff to .penv. It is handled the same way as this
# file but will be ignored by .gitignore.
#
# History settings
HISTSIZE=100000
SAVEHIST=100000
HISTFILE=~/.zsh_history
# Extend the $PATH to $HOME/bin and more.
#export PATH=$HOME/bin:$HOME/.local/bin/:$HOME/.gem/ruby/3.4.0/bin:$HOME/.android/sdk/platform-tools:$HOME/.cargo/bin:$PATH

View file

@ -1,11 +1,11 @@
# Original Source: https://github.com/jonasjacek/
# Set prefix key
unbind-key C-b
bind y send-prefix
set -g prefix ^y
# CONFIGURATION
set -g automatic-rename on
set -g set-titles on
set-option -g history-limit 10000
# DESIGN: 256 COLOR SUPPORT

25
.zsh/functions.d/us.sh Normal file
View file

@ -0,0 +1,25 @@
us() {
if [ -n "$TMUX" ]; then
local original_name
original_name=$(tmux display-message -p '#W')
# Determine the target username
local target_user="root"
local arg1="$1"
if [[ "$arg1" != "-" && -n "$arg1" ]]; then
target_user="$arg1"
fi
# Rename the window before running su
tmux rename-window "su-${target_user}"
# Use "command su" to bypass the function if it exists
command su "$@"
# Restore original window name after exit
tmux rename-window "$original_name"
else
command su "$@"
fi
}

21
.zshrc
View file

@ -1,8 +1,3 @@
# History settings
HISTSIZE=100000
SAVEHIST=100000
HISTFILE=~/.zsh_history
# Source some global/public stuff
source ~/.env
@ -17,7 +12,7 @@ source ~/.zsh/oh-my-zsh.sh
# I use xterm and this sets a nice title with hostname and cwd in it.
case $TERM in
linux)
linux*)
export TERM=linux
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
;;
@ -25,7 +20,7 @@ case $TERM in
export TERM=xterm-256color
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
;;
screen)
screen*)
export TERM=screen-256color
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
;;
@ -48,3 +43,15 @@ for function in ~/.zsh/functions.d/*.sh; do
source $function
done
# Update tmux window title to the current running command
# In root's .zshrc (or any su-target user)
if [ -n "$TMUX" ]; then
function preexec() {
local cmd=${1[(wr)^(*=*|sudo|su|command)]}
print -Pn "\e]2;${cmd%% *}\a"
}
function precmd() {
print -Pn "\e]2;zsh\a"
}
fi