zsh
This commit is contained in:
parent
da36fbfc3a
commit
712367eb98
4 changed files with 47 additions and 10 deletions
7
.env
7
.env
|
|
@ -3,10 +3,15 @@
|
||||||
# Example: can be shell compatible stuff like export, alias etc. or just
|
# Example: can be shell compatible stuff like export, alias etc. or just
|
||||||
# define variables like FOO=BAR
|
# 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.
|
# file but will be ignored by .gitignore.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# History settings
|
||||||
|
HISTSIZE=100000
|
||||||
|
SAVEHIST=100000
|
||||||
|
HISTFILE=~/.zsh_history
|
||||||
|
|
||||||
# Extend the $PATH to $HOME/bin and more.
|
# 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
|
#export PATH=$HOME/bin:$HOME/.local/bin/:$HOME/.gem/ruby/3.4.0/bin:$HOME/.android/sdk/platform-tools:$HOME/.cargo/bin:$PATH
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
# Original Source: https://github.com/jonasjacek/
|
|
||||||
|
|
||||||
# Set prefix key
|
# Set prefix key
|
||||||
unbind-key C-b
|
unbind-key C-b
|
||||||
bind y send-prefix
|
bind y send-prefix
|
||||||
set -g prefix ^y
|
set -g prefix ^y
|
||||||
|
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
|
set -g automatic-rename on
|
||||||
|
set -g set-titles on
|
||||||
set-option -g history-limit 10000
|
set-option -g history-limit 10000
|
||||||
|
|
||||||
# DESIGN: 256 COLOR SUPPORT
|
# DESIGN: 256 COLOR SUPPORT
|
||||||
|
|
|
||||||
25
.zsh/functions.d/us.sh
Normal file
25
.zsh/functions.d/us.sh
Normal 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
21
.zshrc
|
|
@ -1,8 +1,3 @@
|
||||||
# History settings
|
|
||||||
HISTSIZE=100000
|
|
||||||
SAVEHIST=100000
|
|
||||||
HISTFILE=~/.zsh_history
|
|
||||||
|
|
||||||
# Source some global/public stuff
|
# Source some global/public stuff
|
||||||
source ~/.env
|
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.
|
# I use xterm and this sets a nice title with hostname and cwd in it.
|
||||||
case $TERM in
|
case $TERM in
|
||||||
linux)
|
linux*)
|
||||||
export TERM=linux
|
export TERM=linux
|
||||||
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
|
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
|
||||||
;;
|
;;
|
||||||
|
|
@ -25,7 +20,7 @@ case $TERM in
|
||||||
export TERM=xterm-256color
|
export TERM=xterm-256color
|
||||||
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
|
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
|
||||||
;;
|
;;
|
||||||
screen)
|
screen*)
|
||||||
export TERM=screen-256color
|
export TERM=screen-256color
|
||||||
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
|
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
|
||||||
;;
|
;;
|
||||||
|
|
@ -48,3 +43,15 @@ for function in ~/.zsh/functions.d/*.sh; do
|
||||||
source $function
|
source $function
|
||||||
done
|
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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue