├── README.md ├── bashrc_root ├── bashrc_user └── zshrc /README.md: -------------------------------------------------------------------------------- 1 | # Useful .bashrc 2 | 3 | When I'm doing my job I'm trying to set my working place as efficient and useful as it's possible. 4 | 5 | Bash terminal is my main everyday program I'm using that's why I decided to improve it a little. 6 | 7 | Time displaying, inter- and intranet ip-addresses, working directory, listing files due changing dirs, splitting the outputs and other stuff which can make your work easier and faster. 8 | 9 | Usage example: 10 | 1. For users 11 | ------------ 12 | ``` 13 | $ mv /home//.bashrc /home//.bashrc_old 14 | $ cp ./bashrc_user /home//.bashrc 15 | $ bash 16 | ``` 17 | 2. For root 18 | ``` 19 | # mv /root/.bashrc /root/.bashrc_old 20 | # cp ./bashrc_root /root/.bashrc 21 | # bash 22 | ``` 23 | 24 | 25 | An original article: 26 | -------------------- 27 | [https://www.ivanglinkin.com/useful-bashrc-configuration-file/](https://www.ivanglinkin.com/useful-bashrc-configuration-file/) 28 | 29 | Screenshots: 30 | ------------ 31 | ![](https://github.com/IvanGlinkin/media_support/blob/main/Useful-bash-1.png?raw=true) 32 | ![](https://github.com/IvanGlinkin/media_support/blob/main/Useful-bash-2.png?raw=true) 33 | -------------------------------------------------------------------------------- /bashrc_root: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | case $- in 7 | *i*) ;; 8 | *) return;; 9 | esac 10 | 11 | # don't put duplicate lines or lines starting with space in the history. 12 | # See bash(1) for more options 13 | HISTCONTROL=ignoreboth 14 | 15 | # append to the history file, don't overwrite it 16 | shopt -s histappend 17 | 18 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 19 | HISTSIZE=1000 20 | HISTFILESIZE=2000 21 | 22 | # check the window size after each command and, if necessary, 23 | # update the values of LINES and COLUMNS. 24 | shopt -s checkwinsize 25 | 26 | # If set, the pattern "**" used in a pathname expansion context will 27 | # match all files and zero or more directories and subdirectories. 28 | #shopt -s globstar 29 | 30 | # make less more friendly for non-text input files, see lesspipe(1) 31 | #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 32 | 33 | # set variable identifying the chroot you work in (used in the prompt below) 34 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 35 | debian_chroot=$(cat /etc/debian_chroot) 36 | fi 37 | 38 | # set a fancy prompt (non-color, unless we know we "want" color) 39 | case "$TERM" in 40 | xterm-color|*-256color) color_prompt=yes;; 41 | esac 42 | 43 | # uncomment for a colored prompt, if the terminal has the capability; turned 44 | # off by default to not distract the user: the focus in a terminal window 45 | # should be on the output of commands, not on the prompt 46 | #force_color_prompt=yes 47 | 48 | if [ -n "$force_color_prompt" ]; then 49 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 50 | # We have color support; assume it's compliant with Ecma-48 51 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 52 | # a case would tend to support setf rather than setaf.) 53 | color_prompt=yes 54 | else 55 | color_prompt= 56 | fi 57 | fi 58 | 59 | IP=$( ip a | grep 'inet' | grep -v '127.0.0.1\|:' | cut -d " " -f6 | tr "\n\r" " " ) 60 | IP_chk=$( curl -s ifconfig.io ) 61 | if [ ! -z $IP_chk ] 62 | then 63 | IP_ext="$IP_chk 🮵🮶"; 64 | else 65 | IP_ext="No internet 🯀🮶"; 66 | fi 67 | 68 | if [ "$color_prompt" = yes ]; then 69 | PS1='\n${debian_chroot:+($debian_chroot)}\[\033[01;31m\]┌──────────────────────────────────────────────────────┐\n│ ATTENTION!!! YOU ARE UNDER THE ROOT!!! BE CAREFUL!!! │\n└──────────────────────────────────────────────────────┘\n┌─╼ [ \t ] - [ $IP_ext $IP] - [ \u@\h ]\n├─╼ \[\033[00m\]\[\033[01;34m\][ \w ]\[\033[00m\]\n\[\033[01;31m\]│\n└─╼\[\033[00m\] \$ ' 70 | else 71 | PS1='\n┌── [ $(date +"%d-%b-%Y") \t ] - [ \u@\h ]\n├── [ \w ]\n└── # ' 72 | fi 73 | unset color_prompt force_color_prompt 74 | 75 | # If this is an xterm set the title to user@host:dir 76 | case "$TERM" in 77 | xterm*|rxvt*) 78 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 79 | ;; 80 | *) 81 | ;; 82 | esac 83 | 84 | # enable color support of ls and also add handy aliases 85 | if [ -x /usr/bin/dircolors ]; then 86 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 87 | alias ls='ls -lh --color=auto' 88 | #alias cdls='cd "$@" && ls' 89 | cd() { builtin cd "$@" && ls -lh --color=auto; } 90 | fi 91 | 92 | # colored GCC warnings and errors 93 | #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 94 | 95 | # Alias definitions. 96 | # You may want to put all your additions into a separate file like 97 | # ~/.bash_aliases, instead of adding them here directly. 98 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 99 | 100 | if [ -f ~/.bash_aliases ]; then 101 | . ~/.bash_aliases 102 | fi 103 | 104 | # enable programmable completion features (you don't need to enable 105 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 106 | # sources /etc/bash.bashrc). 107 | if ! shopt -oq posix; then 108 | if [ -f /usr/share/bash-completion/bash_completion ]; then 109 | . /usr/share/bash-completion/bash_completion 110 | elif [ -f /etc/bash_completion ]; then 111 | . /etc/bash_completion 112 | fi 113 | fi 114 | -------------------------------------------------------------------------------- /bashrc_user: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | case $- in 7 | *i*) ;; 8 | *) return;; 9 | esac 10 | 11 | # don't put duplicate lines or lines starting with space in the history. 12 | # See bash(1) for more options 13 | HISTCONTROL=ignoreboth 14 | 15 | # append to the history file, don't overwrite it 16 | shopt -s histappend 17 | 18 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 19 | HISTSIZE=1000 20 | HISTFILESIZE=2000 21 | 22 | # check the window size after each command and, if necessary, 23 | # update the values of LINES and COLUMNS. 24 | shopt -s checkwinsize 25 | 26 | # If set, the pattern "**" used in a pathname expansion context will 27 | # match all files and zero or more directories and subdirectories. 28 | #shopt -s globstar 29 | 30 | # make less more friendly for non-text input files, see lesspipe(1) 31 | #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 32 | 33 | # set variable identifying the chroot you work in (used in the prompt below) 34 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 35 | debian_chroot=$(cat /etc/debian_chroot) 36 | fi 37 | 38 | # set a fancy prompt (non-color, unless we know we "want" color) 39 | case "$TERM" in 40 | xterm-color|*-256color) color_prompt=yes;; 41 | esac 42 | 43 | # uncomment for a colored prompt, if the terminal has the capability; turned 44 | # off by default to not distract the user: the focus in a terminal window 45 | # should be on the output of commands, not on the prompt 46 | #force_color_prompt=yes 47 | 48 | if [ -n "$force_color_prompt" ]; then 49 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 50 | # We have color support; assume it's compliant with Ecma-48 51 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 52 | # a case would tend to support setf rather than setaf.) 53 | color_prompt=yes 54 | else 55 | color_prompt= 56 | fi 57 | fi 58 | 59 | IP=$( ip a | grep 'inet' | grep -v '127.0.0.1\|:' | cut -d " " -f6 | tr "\n\r" " " ) 60 | IP_chk=$( curl -s ifconfig.io ) 61 | if [ ! -z $IP_chk ] 62 | then 63 | IP_ext="$IP_chk 🮵🮶"; 64 | else 65 | IP_ext="No internet 🯀🮶"; 66 | fi 67 | 68 | if [ "$color_prompt" = yes ]; then 69 | PS1='\n${debian_chroot:+($debian_chroot)}\[\033[01;32m\]┌─╼ [ \t ] - [ $IP_ext $IP] - [ \u@\h ]\n├─╼ \[\033[00m\]\[\033[01;34m\][ \w ]\[\033[00m\]\n\[\033[01;32m\]│\n└─╼\[\033[00m\] \$ ' 70 | else 71 | PS1='\n${debian_chroot:+($debian_chroot)}[ \t ] - [ \u@\h ] - [ \w ] \$ ' 72 | fi 73 | unset color_prompt force_color_prompt 74 | 75 | # If this is an xterm set the title to user@host:dir 76 | case "$TERM" in 77 | xterm*|rxvt*) 78 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 79 | ;; 80 | *) 81 | ;; 82 | esac 83 | 84 | # enable color support of ls and also add handy aliases 85 | if [ -x /usr/bin/dircolors ]; then 86 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 87 | alias ls='ls -lh --color=auto' 88 | #alias cdls='cd "$@" && ls' 89 | cd() { builtin cd "$@" && ls -lh --color=auto; } 90 | fi 91 | 92 | # colored GCC warnings and errors 93 | #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 94 | 95 | # Alias definitions. 96 | # You may want to put all your additions into a separate file like 97 | # ~/.bash_aliases, instead of adding them here directly. 98 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 99 | 100 | if [ -f ~/.bash_aliases ]; then 101 | . ~/.bash_aliases 102 | fi 103 | 104 | # enable programmable completion features (you don't need to enable 105 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 106 | # sources /etc/bash.bashrc). 107 | if ! shopt -oq posix; then 108 | if [ -f /usr/share/bash-completion/bash_completion ]; then 109 | . /usr/share/bash-completion/bash_completion 110 | elif [ -f /etc/bash_completion ]; then 111 | . /etc/bash_completion 112 | fi 113 | fi 114 | -------------------------------------------------------------------------------- /zshrc: -------------------------------------------------------------------------------- 1 | # ~/.zshrc file for zsh interactive shells. 2 | # see /usr/share/doc/zsh/examples/zshrc for examples 3 | 4 | setopt autocd # change directory just by typing its name 5 | #setopt correct # auto correct mistakes 6 | setopt interactivecomments # allow comments in interactive mode 7 | setopt magicequalsubst # enable filename expansion for arguments of the form ‘anything=expression’ 8 | setopt nonomatch # hide error message if there is no match for the pattern 9 | setopt notify # report the status of background jobs immediately 10 | setopt numericglobsort # sort filenames numerically when it makes sense 11 | setopt promptsubst # enable command substitution in prompt 12 | 13 | WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word 14 | 15 | # hide EOL sign ('%') 16 | PROMPT_EOL_MARK="" 17 | 18 | # configure key keybindings 19 | bindkey -e # emacs key bindings 20 | bindkey ' ' magic-space # do history expansion on space 21 | bindkey '^[[3;5~' kill-word # ctrl + Supr 22 | bindkey '^[[3~' delete-char # delete 23 | bindkey '^[[1;5C' forward-word # ctrl + -> 24 | bindkey '^[[1;5D' backward-word # ctrl + <- 25 | bindkey '^[[5~' beginning-of-buffer-or-history # page up 26 | bindkey '^[[6~' end-of-buffer-or-history # page down 27 | bindkey '^[[H' beginning-of-line # home 28 | bindkey '^[[F' end-of-line # end 29 | bindkey '^[[Z' undo # shift + tab undo last action 30 | 31 | # enable completion features 32 | autoload -Uz compinit 33 | compinit -d ~/.cache/zcompdump 34 | zstyle ':completion:*:*:*:*:*' menu select 35 | zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case insensitive tab completion 36 | 37 | # History configurations 38 | HISTFILE=~/.zsh_history 39 | HISTSIZE=2000 40 | SAVEHIST=2000 41 | setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE 42 | setopt hist_ignore_dups # ignore duplicated commands history list 43 | setopt hist_ignore_space # ignore commands that start with space 44 | setopt hist_verify # show command with history expansion to user before running it 45 | #setopt share_history # share command history data 46 | 47 | # force zsh to show the complete history 48 | alias history="history 0" 49 | 50 | # make less more friendly for non-text input files, see lesspipe(1) 51 | #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 52 | 53 | # set variable identifying the chroot you work in (used in the prompt below) 54 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 55 | debian_chroot=$(cat /etc/debian_chroot) 56 | fi 57 | 58 | # override default virtualenv indicator in prompt 59 | VIRTUAL_ENV_DISABLE_PROMPT=1 60 | venv_info() { 61 | [ $VIRTUAL_ENV ] && echo "(%B%F{reset}$(basename $VIRTUAL_ENV)%b%F{%(#.blue.green)})" 62 | } 63 | 64 | # set a fancy prompt (non-color, unless we know we "want" color) 65 | case "$TERM" in 66 | xterm-color|*-256color) color_prompt=yes;; 67 | esac 68 | 69 | # uncomment for a colored prompt, if the terminal has the capability; turned 70 | # off by default to not distract the user: the focus in a terminal window 71 | # should be on the output of commands, not on the prompt 72 | force_color_prompt=yes 73 | 74 | if [ -n "$force_color_prompt" ]; then 75 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 76 | # We have color support; assume it's compliant with Ecma-48 77 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 78 | # a case would tend to support setf rather than setaf.) 79 | color_prompt=yes 80 | else 81 | color_prompt= 82 | fi 83 | fi 84 | 85 | IP=$( ip -4 a | grep inet | grep -v '127.0.0.1\|:\|bridge' | cut -d " " -f6 | tr "\n\r" " " ) 86 | IP_chk=$( curl -s ifconfig.io ) 87 | if [ ! -z $IP_chk ] 88 | then 89 | IP_ext="$IP_chk <>"; 90 | else 91 | IP_ext="No internet x>"; 92 | fi 93 | 94 | if [ "$color_prompt" = yes ]; then 95 | PROMPT=$'%F{%(#.green.green)}┌── [ $(date +"%d-%b-%Y") %* ] - [ $IP_ext $IP] - ${debian_chroot:+($debian_chroot)──}$(venv_info)[ %B%F{%(#.red.red)}%n%(#.💀.@)%m%b%F{%(#.green.green)} ]\n├── [ %B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.green.green)} ]\n└── %B%(#.%F{red}#.%F{red}$)%b%F{reset} ' 96 | RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)' 97 | 98 | # enable syntax-highlighting 99 | if [ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && [ "$color_prompt" = yes ]; then 100 | . /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 101 | ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern) 102 | ZSH_HIGHLIGHT_STYLES[default]=fg=white 103 | ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold 104 | ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold 105 | ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=white,underline 106 | ZSH_HIGHLIGHT_STYLES[global-alias]=fg=magenta 107 | ZSH_HIGHLIGHT_STYLES[precommand]=fg=white,underline 108 | ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold 109 | ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline 110 | ZSH_HIGHLIGHT_STYLES[path]=underline 111 | ZSH_HIGHLIGHT_STYLES[path_pathseparator]= 112 | ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]= 113 | ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold 114 | ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold 115 | ZSH_HIGHLIGHT_STYLES[command-substitution]=fg=white 116 | ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta 117 | ZSH_HIGHLIGHT_STYLES[process-substitution]=none 118 | ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta 119 | ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=magenta 120 | ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=magenta 121 | ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none 122 | ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold 123 | ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow 124 | ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow 125 | ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow 126 | ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta 127 | ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta 128 | ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta 129 | ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta 130 | ZSH_HIGHLIGHT_STYLES[assign]=none 131 | ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold 132 | ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold 133 | ZSH_HIGHLIGHT_STYLES[named-fd]=none 134 | ZSH_HIGHLIGHT_STYLES[numeric-fd]=none 135 | ZSH_HIGHLIGHT_STYLES[arg0]=fg=green 136 | ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold 137 | ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold 138 | ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold 139 | ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold 140 | ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold 141 | ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold 142 | ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout 143 | ZSH_HIGHLIGHT_STYLES[alias]=fg=green 144 | fi 145 | else 146 | PROMPT='${debian_chroot:+($debian_chroot)}%n@%m:%~%# ' 147 | fi 148 | unset color_prompt force_color_prompt 149 | 150 | # If this is an xterm set the title to user@host:dir 151 | case "$TERM" in 152 | xterm*|rxvt*) 153 | TERM_TITLE=$'\e]0;${debian_chroot:+($debian_chroot)}%n@%m: %~\a' 154 | ;; 155 | *) 156 | ;; 157 | esac 158 | 159 | new_line_before_prompt=yes 160 | precmd() { 161 | # Print the previously configured title 162 | print -Pnr -- "$TERM_TITLE" 163 | 164 | # Print a new line before the prompt, but only if it is not the first line 165 | if [ "$new_line_before_prompt" = yes ]; then 166 | if [ -z "$_NEW_LINE_BEFORE_PROMPT" ]; then 167 | _NEW_LINE_BEFORE_PROMPT=1 168 | else 169 | print "" 170 | fi 171 | fi 172 | } 173 | 174 | # enable color support of ls, less and man, and also add handy aliases 175 | if [ -x /usr/bin/dircolors ]; then 176 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 177 | #alias ls='ls -lh --color=auto' 178 | #alias dir='dir --color=auto' 179 | #alias vdir='vdir --color=auto' 180 | 181 | alias grep='grep --color=auto' 182 | alias fgrep='fgrep --color=auto' 183 | alias egrep='egrep --color=auto' 184 | alias diff='diff --color=auto' 185 | alias ip='ip --color=auto' 186 | 187 | export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink 188 | export LESS_TERMCAP_md=$'\E[1;36m' # begin bold 189 | export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink 190 | export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video 191 | export LESS_TERMCAP_se=$'\E[0m' # reset reverse video 192 | export LESS_TERMCAP_us=$'\E[1;32m' # begin underline 193 | export LESS_TERMCAP_ue=$'\E[0m' # reset underline 194 | 195 | # Take advantage of $LS_COLORS for completion as well 196 | zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" 197 | fi 198 | 199 | # some more ls aliases 200 | alias ls='ls -lhG --color' 201 | alias la='ls -A' 202 | alias l='ls -CF' 203 | 204 | # enable auto-suggestions based on the history 205 | if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then 206 | . /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh 207 | # change suggestion color 208 | ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=white' 209 | fi 210 | 211 | # enable command-not-found if installed 212 | if [ -f /etc/zsh_command_not_found ]; then 213 | . /etc/zsh_command_not_found 214 | fi 215 | 216 | function list_all() { 217 | emulate -L zsh 218 | ls 219 | } 220 | chpwd_functions=(${chpwd_functions[@]} "list_all") 221 | --------------------------------------------------------------------------------