.zshrc
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 01 Jan 2024 20:53:49 +0200
changeset 1039 78cdb4a057e3
parent 977 0b4affe58cff
permissions -rw-r--r--
Create symlink from ~/.bash_profile for login shell to activate my ~/.bashrc.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
215
7b1b6872e92e Include system wide /etc/zshrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 214
diff changeset
     1
7b1b6872e92e Include system wide /etc/zshrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 214
diff changeset
     2
if [[ -e /etc/zshrc ]]; then
7b1b6872e92e Include system wide /etc/zshrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 214
diff changeset
     3
. /etc/zshrc
7b1b6872e92e Include system wide /etc/zshrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 214
diff changeset
     4
fi
179
ed15e30ff41a Set editor to VIM. Bind edit command for shells.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 177
diff changeset
     5
977
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
     6
if [[ -f ~/.bash.env ]]; then
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
     7
  . ~/.bash.env
653
a5566b182446 Use .env file as common env var settings for Bash and Zsh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
     8
fi
172
755ff9f067d0 zsh basic settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
826
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    10
PS1=$'%?|%n@%m %~\nzsh# '
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    11
PS2='> '
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    12
case "$TERM" in
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    13
  xterm*|eterm-color|screen|linux)
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    14
    PS1=$'\n%F{cyan}%?|%F{red}%n%F{magenta}@%m %F{cyan}%~\n%F{red}%Bzsh#%b%f '
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    15
    PS2=$'%F{green}> %f'
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    16
  ;;
54d42c57cc4d Improve zsh prompt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 749
diff changeset
    17
esac
180
176106ed8e46 Set prompt for shell.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 179
diff changeset
    18
651
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    19
HISTFILE=~/.zsh_history
214
7d52ae0eda9b Increase HIST size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 181
diff changeset
    20
HISTSIZE=10000
7d52ae0eda9b Increase HIST size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 181
diff changeset
    21
SAVEHIST=10000
172
755ff9f067d0 zsh basic settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
651
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    23
setopt AUTO_CD
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    24
setopt BEEP
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    25
setopt NOMATCH
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    26
setopt NOTIFY
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    27
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    28
setopt APPEND_HISTORY
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    29
setopt EXTENDED_HISTORY
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    30
setopt HIST_EXPIRE_DUPS_FIRST
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    31
setopt HIST_IGNORE_ALL_DUPS
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    32
setopt HIST_IGNORE_SPACE
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    33
setopt HIST_NO_FUNCTIONS
177
95c784cc8cbb History settings for zsh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 172
diff changeset
    34
651
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    35
setopt MENUCOMPLETE
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    36
# Use completion cache
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    37
zstyle ':completion:*' use-cache on
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    38
zstyle ':completion:*' cache-path ~/.zsh/cache
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    39
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    40
# Ignore SCM revision files
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    41
zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)(CVS|.svn|.git)'
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    42
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#(CVS|.svn|.git)'
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    43
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    44
# Fuzzy completion
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    45
zstyle ':completion:*' completer _expand _complete _match _approximate
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    46
zstyle ':completion:*:match:*' original only
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    47
zstyle ':completion:*:approximate:*' max-errors 1 numeric
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    48
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    49
# Do not attempt to complete missing commands
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    50
#zstyle ':completion:*:functions' ignored-patterns '_*'
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    51
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    52
# Complete PIDS with menu
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    53
zstyle ':completion:*:*:kill:*' menu yes select
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    54
zstyle ':completion:*:kill:*' force-list always
172
755ff9f067d0 zsh basic settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    55
179
ed15e30ff41a Set editor to VIM. Bind edit command for shells.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 177
diff changeset
    56
autoload -U edit-command-line
ed15e30ff41a Set editor to VIM. Bind edit command for shells.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 177
diff changeset
    57
zle -N edit-command-line
ed15e30ff41a Set editor to VIM. Bind edit command for shells.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 177
diff changeset
    58
bindkey '\ee' edit-command-line
ed15e30ff41a Set editor to VIM. Bind edit command for shells.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 177
diff changeset
    59
172
755ff9f067d0 zsh basic settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    60
# Emacs like editing.
755ff9f067d0 zsh basic settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    61
bindkey -e
755ff9f067d0 zsh basic settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    62
749
89208f64214c history-beginning-search-backward
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 653
diff changeset
    63
bindkey '^[[A' history-beginning-search-backward
89208f64214c history-beginning-search-backward
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 653
diff changeset
    64
bindkey '^[[B' history-beginning-search-forward
89208f64214c history-beginning-search-backward
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 653
diff changeset
    65
89208f64214c history-beginning-search-backward
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 653
diff changeset
    66
# bindkey "^[[A" history-search-backward
89208f64214c history-beginning-search-backward
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 653
diff changeset
    67
# bindkey "^[[B" history-search-forward
243
843cc9d49dc2 Enable history search.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 215
diff changeset
    68
651
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    69
autoload -U zutil
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    70
245
aefd2167af31 Enable completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 243
diff changeset
    71
autoload -U compinit
aefd2167af31 Enable completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 243
diff changeset
    72
compinit
aefd2167af31 Enable completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 243
diff changeset
    73
aefd2167af31 Enable completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 243
diff changeset
    74
# autoload -U promptinit
aefd2167af31 Enable completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 243
diff changeset
    75
# promptinit
aefd2167af31 Enable completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 243
diff changeset
    76
# prompt walters
651
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    77
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    78
# Renaming with globbing
649cbbab7ded Add new and update old entries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
    79
# autoload zmv
977
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    80
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    81
################################################################
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    82
# Load user defined settings.
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    83
# Placed to the end to allow override skel settings.
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    84
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    85
if [[ -f ~/.env ]]; then
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    86
  . ~/.env
0b4affe58cff Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 826
diff changeset
    87
fi