From 9cb64a66bdcb2768f9d35ccc45478cb648727436 Mon Sep 17 00:00:00 2001 From: airosa Date: Wed, 26 Oct 2022 19:34:04 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D1=84=D0=B0=D0=B9=D0=BB=20.zshrc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .zshrc | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/.zshrc b/.zshrc index cb5b181..eb386a1 100644 --- a/.zshrc +++ b/.zshrc @@ -2,9 +2,11 @@ autoload -U colors select-word-style colors #Colors select-word-style bash #ctrl+w on words +export ASTERISK_PROMPT="[%d %t]%H*> " + export EDITOR="vim" -### Colored MAN +#Colored man view export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' @@ -13,7 +15,6 @@ export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' - ## # Completion ## @@ -53,7 +54,6 @@ setopt hist_reduce_blanks # trim blanks setopt hist_verify # show before executing history commands setopt inc_append_history # add commands as they are typed, don't wait until shell exit setopt share_history # share hist between sessions -setopt hist_no_store ## # VARIOUS @@ -68,18 +68,21 @@ color="green" if [ "$EUID" -eq 0 ]; then color="red" fi -PROMPT="[%T](%{$fg[yellow]%}%m%{$reset_color%})%{$fg[$color]%}%n %{$fg[blue]%}%~ %#%{$reset_color%} " +PROMPT="[%T](%{$fg[yellow]%}%m%{$reset_color%})%{$fg[$color]%}%n %{$fg[cyan]%}%~ %{%(#~$fg[red]~$fg[cyan])%}%#%{$reset_color%} " -alias ls='ls --color=auto --group-directories-first' -alias ll='ls -alF --color' +alias ls='ls -althr --time-style=long-iso --color=auto --group-directories-first' alias tail='multitail' alias df='df -h' -alias du='du -h -max-depth=1 | sort -h' alias start='sudo systemctl start' alias restart='sudo systemctl restart' alias stop='sudo systemctl stop' alias status='sudo systemctl status' alias reload='sudo systemctl reload' +alias lessv='vim -R' +alias ip='ip -c' + +#Color Grep and add yellow color +export GREP_COLORS="mt=33" alias grep='grep --color=auto' # Export java option IPv4 Preference @@ -101,3 +104,30 @@ bindkey "^[[B" history-search-forward # completion in the middle of a line bindkey '^i' expand-or-complete-prefix + +if [ ! "$EUID" -eq 0 ]; then + # This might be too clever. But it allows me to have multiple + # sessions opened and it will use the same windows. This really + # makes TMUX work like SCREEN. + if [ -z "$TMUX" ] && [ -z "$DISPLAY" ] && [ -z "$TERM_PROGRAM" ]; then + base_session="${USER//./}_session" + # Create a new session if it doesn't exist + tmux has-session -t $base_session || tmux new-session -d -s $base_session + + client_cnt=$(tmux list-clients | wc -l) + # Are there any clients connected already? + if [ $client_cnt -ge 1 ]; then + client_id=0 + session_name=$base_session"-"$client_id + while [ $(tmux has-session -t $session_name 2>& /dev/null; echo $?) -ne 1 ]; do + client_id=$((client_id+1)) + session_name=$base_session"-"$client_id + done + tmux new-session -d -t $base_session -s $session_name + tmux -2 attach-session -t $session_name \; set-option destroy-unattached + else + tmux -2 attach-session -t $base_session + fi + fi + +fi