Overhaul of zsh config
This commit is contained in:
@@ -23,16 +23,16 @@ for option in "$@"; do
|
|||||||
link "$PWD/alacritty/alacritty.toml" "$HOME/.config/alacritty/alacritty.toml"
|
link "$PWD/alacritty/alacritty.toml" "$HOME/.config/alacritty/alacritty.toml"
|
||||||
;;
|
;;
|
||||||
zsh)
|
zsh)
|
||||||
[ ! -d "$HOME/.config/zsh" ] && mkdir -p "$HOME/.config/zsh"
|
mkdir -p "$HOME/.config/zsh"
|
||||||
link "$PWD/zsh/.zshrc" "$HOME/.config/zsh/.zshrc"
|
mkdir -p "/etc/zsh"
|
||||||
link "$PWD/zsh/aliases" "$HOME/.config/zsh/aliases"
|
echo "export ZDOTDIR=\"\$HOME\"/.config/zsh" | sudo tee /etc/zsh/zshenv
|
||||||
[ -e "/etc/zsh/zshenv" ] && sudo mv /etc/zsh/zshenv /etc/zsh/zshenv.bak && sudo ln -s "$PWD/zsh/zshenv" /etc/zsh/zshenv || sudo ln -s "$PWD/zsh/zshenv" /etc/zsh/zshenv
|
|
||||||
curl -fLo $HOME/.config/zsh/zsh-autosuggestions.zsh --create-dirs \
|
ZSH="$HOME/.config/zsh/ohmyzsh" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||||
https://raw.githubusercontent.com/zsh-users/zsh-autosuggestions/master/zsh-autosuggestions.zsh
|
|
||||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $HOME/.config/zsh/zsh-syntax-highlighting
|
mkdir -p ~/.config/zsh/ohmyzsh/custom/plugins
|
||||||
git clone https://github.com/romkatv/gitstatus.git $HOME/.config/zsh/gitstatus
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.config/zsh/ohmyzsh/custom/plugins/zsh-syntax-highlighting
|
||||||
mv "$HOME/.config/zsh/gitstatus/gitstatus.prompt.zsh" "$HOME/.config/zsh/gitstatus/gitstatus.prompt.zsh.bak"
|
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.config/zsh/ohmyzsh/custom/plugins/zsh-autosuggestions
|
||||||
link "$PWD/zsh/gitstatus.prompt.zsh" "$HOME/.config/zsh/gitstatus/gitstatus.prompt.zsh"
|
link "$PWD/zsh/zshrc" "$HOME/.config/zsh/.zshrc"
|
||||||
;;
|
;;
|
||||||
git)
|
git)
|
||||||
[ ! -d "$HOME/.config/git" ] && mkdir -p "$HOME/.config/git"
|
[ ! -d "$HOME/.config/git" ] && mkdir -p "$HOME/.config/git"
|
||||||
|
|||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
autoload -Uz promptinit
|
|
||||||
promptinit
|
|
||||||
|
|
||||||
bindkey -e
|
|
||||||
|
|
||||||
bindkey "^[[1;5C" forward-word
|
|
||||||
bindkey "^[[1;5D" backward-word
|
|
||||||
bindkey "^[[3;5~" backward-kill-word
|
|
||||||
|
|
||||||
setopt histignorealldups sharehistory
|
|
||||||
|
|
||||||
HISTSIZE=5000
|
|
||||||
SAVEHIST=5000
|
|
||||||
HISTFILE=$HOME/.config/zsh/zsh_history
|
|
||||||
|
|
||||||
# Modern completion system
|
|
||||||
autoload -Uz compinit
|
|
||||||
compinit -d ~/.cache/zsh/ > /dev/null 2>&1
|
|
||||||
_comp_options+=(globdots) # include hidden files
|
|
||||||
|
|
||||||
autoload -U colors && colors
|
|
||||||
|
|
||||||
source /etc/zsh/zshenv
|
|
||||||
source $HOME/.config/zsh/aliases
|
|
||||||
source $HOME/.config/zsh/zsh-autosuggestions.zsh
|
|
||||||
source $HOME/.config/zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
||||||
source $HOME/.config/zsh/gitstatus/gitstatus.prompt.zsh
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
alias sudo='/usr/bin/doas '
|
|
||||||
alias ls='ls --color=auto'
|
|
||||||
alias ll='ls -lAh --color=auto'
|
|
||||||
alias la='ls -A --color=auto'
|
|
||||||
alias l='ls -A --color=auto'
|
|
||||||
alias cp='rsync -ah --progress'
|
|
||||||
alias grep='grep --color=auto'
|
|
||||||
alias sc='source /home/johannes/.config/zsh/.zshrc' # reload zsh configuration
|
|
||||||
alias cn='clear && neofetch'
|
|
||||||
alias live-server='live-server --port=1111 --host=127.0.0.1 --no-css-inject'
|
|
||||||
alias pac='doas pacman'
|
|
||||||
alias minecraft-launcher='minecraft-launcher --workDir /home/johannes/.local/share/minecraft'
|
|
||||||
alias enablebluetooth='doas modprobe btusb'
|
|
||||||
alias virt-manager='/bin/sudo -i virt-manager'
|
|
||||||
|
|
||||||
# Typos
|
|
||||||
alias al="ls -lAh --color=auto"
|
|
||||||
alias s=""
|
|
||||||
alias vnim="nvim"
|
|
||||||
alias daos="doas "
|
|
||||||
alias celar="clear"
|
|
||||||
alias gti="git"
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
# Simple Zsh prompt with Git status.
|
|
||||||
|
|
||||||
# Source gitstatus.plugin.zsh from $GITSTATUS_DIR or from the same directory
|
|
||||||
# in which the current script resides if the variable isn't set.
|
|
||||||
source "${GITSTATUS_DIR:-${${(%):-%x}:h}}/gitstatus.plugin.zsh" || return
|
|
||||||
|
|
||||||
# Sets GITSTATUS_PROMPT to reflect the state of the current git repository. Empty if not
|
|
||||||
# in a git repository. In addition, sets GITSTATUS_PROMPT_LEN to the number of columns
|
|
||||||
# $GITSTATUS_PROMPT will occupy when printed.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# GITSTATUS_PROMPT='master ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42'
|
|
||||||
# GITSTATUS_PROMPT_LEN=39
|
|
||||||
#
|
|
||||||
# master current branch
|
|
||||||
# ⇣42 local branch is 42 commits behind the remote
|
|
||||||
# ⇡42 local branch is 42 commits ahead of the remote
|
|
||||||
# ⇠42 local branch is 42 commits behind the push remote
|
|
||||||
# ⇢42 local branch is 42 commits ahead of the push remote
|
|
||||||
# *42 42 stashes
|
|
||||||
# merge merge in progress
|
|
||||||
# ~42 42 merge conflicts
|
|
||||||
# +42 42 staged changes
|
|
||||||
# !42 42 unstaged changes
|
|
||||||
# ?42 42 untracked files
|
|
||||||
function gitstatus_prompt_update() {
|
|
||||||
emulate -L zsh
|
|
||||||
typeset -g GITSTATUS_PROMPT=''
|
|
||||||
typeset -gi GITSTATUS_PROMPT_LEN=0
|
|
||||||
|
|
||||||
# Call gitstatus_query synchronously. Note that gitstatus_query can also be called
|
|
||||||
# asynchronously; see documentation in gitstatus.plugin.zsh.
|
|
||||||
gitstatus_query 'MY' || return 1 # error
|
|
||||||
[[ $VCS_STATUS_RESULT == 'ok-sync' ]] || return 0 # not a git repo
|
|
||||||
|
|
||||||
local clean='%76F' # green foreground
|
|
||||||
local modified='%178F' # yellow foreground
|
|
||||||
local untracked='%39F' # blue foreground
|
|
||||||
local conflicted='%196F' # red foreground
|
|
||||||
|
|
||||||
local p
|
|
||||||
|
|
||||||
local where # branch name, tag or commit
|
|
||||||
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
|
|
||||||
where=$VCS_STATUS_LOCAL_BRANCH
|
|
||||||
elif [[ -n $VCS_STATUS_TAG ]]; then
|
|
||||||
p+='%f#'
|
|
||||||
where=$VCS_STATUS_TAG
|
|
||||||
else
|
|
||||||
p+='%f@'
|
|
||||||
where=${VCS_STATUS_COMMIT[1,8]}
|
|
||||||
fi
|
|
||||||
|
|
||||||
(( $#where > 32 )) && where[13,-13]="…" # truncate long branch names and tags
|
|
||||||
p+="${clean}${where//\%/%%}" # escape %
|
|
||||||
|
|
||||||
# ⇣42 if behind the remote.
|
|
||||||
(( VCS_STATUS_COMMITS_BEHIND )) && p+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}"
|
|
||||||
# ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
|
|
||||||
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && p+=" "
|
|
||||||
(( VCS_STATUS_COMMITS_AHEAD )) && p+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}"
|
|
||||||
# ⇠42 if behind the push remote.
|
|
||||||
(( VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}"
|
|
||||||
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" "
|
|
||||||
# ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
|
|
||||||
(( VCS_STATUS_PUSH_COMMITS_AHEAD )) && p+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}"
|
|
||||||
# *42 if have stashes.
|
|
||||||
(( VCS_STATUS_STASHES )) && p+=" ${clean}*${VCS_STATUS_STASHES}"
|
|
||||||
# 'merge' if the repo is in an unusual state.
|
|
||||||
[[ -n $VCS_STATUS_ACTION ]] && p+=" ${conflicted}${VCS_STATUS_ACTION}"
|
|
||||||
# ~42 if have merge conflicts.
|
|
||||||
(( VCS_STATUS_NUM_CONFLICTED )) && p+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
|
|
||||||
# +42 if have staged changes.
|
|
||||||
(( VCS_STATUS_NUM_STAGED )) && p+=" ${modified}+${VCS_STATUS_NUM_STAGED}"
|
|
||||||
# !42 if have unstaged changes.
|
|
||||||
(( VCS_STATUS_NUM_UNSTAGED )) && p+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}"
|
|
||||||
# ?42 if have untracked files. It's really a question mark, your font isn't broken.
|
|
||||||
(( VCS_STATUS_NUM_UNTRACKED )) && p+=" ${untracked}?${VCS_STATUS_NUM_UNTRACKED}"
|
|
||||||
|
|
||||||
GITSTATUS_PROMPT="${p}%f"
|
|
||||||
|
|
||||||
# The length of GITSTATUS_PROMPT after removing %f and %F.
|
|
||||||
GITSTATUS_PROMPT_LEN="${(m)#${${GITSTATUS_PROMPT//\%\%/x}//\%(f|<->F)}}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Start gitstatusd instance with name "MY". The same name is passed to
|
|
||||||
# gitstatus_query in gitstatus_prompt_update. The flags with -1 as values
|
|
||||||
# enable staged, unstaged, conflicted and untracked counters.
|
|
||||||
gitstatus_stop 'MY' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'MY'
|
|
||||||
|
|
||||||
# On every prompt, fetch git status and set GITSTATUS_PROMPT.
|
|
||||||
autoload -Uz add-zsh-hook
|
|
||||||
add-zsh-hook precmd gitstatus_prompt_update
|
|
||||||
|
|
||||||
# Enable/disable the right prompt options.
|
|
||||||
setopt no_prompt_bang prompt_percent prompt_subst
|
|
||||||
|
|
||||||
# Customize prompt. Put $GITSTATUS_PROMPT in it to reflect git status.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# user@host ~/projects/skynet master ⇡42
|
|
||||||
# % █
|
|
||||||
#
|
|
||||||
# The current directory gets truncated from the left if the whole prompt doesn't fit on the line.
|
|
||||||
PROMPT='%F{cyan}%n@%m%f ' # green user@host
|
|
||||||
PROMPT+='%F{blue}%$((-GITSTATUS_PROMPT_LEN-1))<…<%~%<<%f' # blue current working directory
|
|
||||||
PROMPT+='${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT}' # git status
|
|
||||||
PROMPT+=$'\n' # new line
|
|
||||||
PROMPT+='%F{%(?.green.red)}%#%f ' # %/# (normal/root); green/red (ok/error)
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
# XDG Base Directories
|
|
||||||
export XDG_CONFIG_HOME="$HOME/.config"
|
|
||||||
export XDG_DATA_HOME="$HOME/.local/share"
|
|
||||||
export XDG_STATE_HOME="$HOME/.local/state"
|
|
||||||
export XDG_DATA_DIRS="/usr/local/share:/usr/share:/var/lib/flatpak/exports/share:$HOME/.local/share/flatpak/exports/share"
|
|
||||||
export XDG_CONFIG_DIRS="/etc/xdg"
|
|
||||||
# ~/ Cleanup
|
|
||||||
export CARGO_HOME="$XDG_DATA_HOME"/cargo
|
|
||||||
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
|
|
||||||
export ZDOTDIR="$HOME"/.config/zsh
|
|
||||||
export HISTFILE="${XDG_STATE_HOME}"/bash/history
|
|
||||||
export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java
|
|
||||||
export GTK2_RC_FILES="$XDG_CONFIG_HOME"/gtk-2.0/gtkrc
|
|
||||||
export TEXMFVAR="$XDG_CACHE_HOME"/texlive/texmf-var
|
|
||||||
|
|
||||||
export PATH="$PATH:$HOME/.local/bin:/sbin"
|
|
||||||
export GPG_TTY=$(tty)
|
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
export ZSH="$ZDOTDIR/ohmyzsh"
|
||||||
|
|
||||||
|
ZSH_THEME="bira"
|
||||||
|
|
||||||
|
zstyle ':omz:update' mode auto # update automatically without asking
|
||||||
|
|
||||||
|
# command execution time stamp shown in the history command output.
|
||||||
|
HIST_STAMPS="dd.mm.yyyy"
|
||||||
|
|
||||||
|
plugins=(
|
||||||
|
git
|
||||||
|
zsh-syntax-highlighting
|
||||||
|
zsh-autosuggestions
|
||||||
|
)
|
||||||
|
|
||||||
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
#######################################################
|
||||||
|
#
|
||||||
|
# User configuration
|
||||||
|
#
|
||||||
|
#######################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Aliases
|
||||||
|
#
|
||||||
|
alias pac="doas pacman"
|
||||||
|
alias sudo="doas "
|
||||||
|
alias mv="mv -i"
|
||||||
|
alias ls="ls --color=auto"
|
||||||
|
alias ll="ls -lAh --color=auto"
|
||||||
|
alias la="ls -A --color=auto"
|
||||||
|
alias l="ls -A --color=auto"
|
||||||
|
alias grep="grep --color=auto"
|
||||||
|
|
||||||
|
# Typos
|
||||||
|
alias al="ls -lAh --color=auto"
|
||||||
|
alias s=""
|
||||||
|
alias daos="doas "
|
||||||
|
alias celar="clear"
|
||||||
|
alias gti="git"
|
||||||
|
alias mc="mv -i"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Variables
|
||||||
|
#
|
||||||
|
# XDG Base Directories
|
||||||
|
export XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
export XDG_DATA_HOME="$HOME/.local/share"
|
||||||
|
export XDG_CACHE_HOME="$HOME/.local/cache"
|
||||||
|
export XDG_STATE_HOME="$HOME/.local/state"
|
||||||
|
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
|
||||||
|
export XDG_CONFIG_DIRS="/etc/xdg"
|
||||||
|
|
||||||
|
# ~/ Cleanup
|
||||||
|
export CARGO_HOME="$XDG_DATA_HOME"/cargo
|
||||||
|
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
|
||||||
|
export ZDOTDIR="$HOME"/.config/zsh
|
||||||
|
export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java
|
||||||
|
export GTK2_RC_FILES="$XDG_CONFIG_HOME"/gtk-2.0/gtkrc
|
||||||
|
export TEXMFVAR="$XDG_CACHE_HOME"/texlive/texmf-var
|
||||||
|
|
||||||
|
export PATH="$PATH:$HOME/.local/bin:/sbin"
|
||||||
|
export GPG_TTY=$(tty)
|
||||||
|
export XDG_DATA_DIRS="$XDG_DATA_DIRS:/var/lib/flatpak/exports/share"
|
||||||
|
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Behaviour
|
||||||
|
#
|
||||||
|
|
||||||
|
# Modern completion system
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit -d ~/.cache/zsh/ > /dev/null 2>&1
|
||||||
|
_comp_options+=(globdots) # include hidden files
|
||||||
|
|
||||||
|
# shell history
|
||||||
|
HISTFILE=~/.config/zsh/history
|
||||||
|
HISTSIZE=100000
|
||||||
|
SAVEHIST=100000
|
||||||
|
|
||||||
|
# Search history with Up / Down
|
||||||
|
bindkey "\e[A" history-beginning-search-backward
|
||||||
|
bindkey "\e[B" history-beginning-search-forward
|
||||||
|
|
||||||
|
setopt hist_ignore_all_dups # remove older duplicate entries from history
|
||||||
|
setopt hist_reduce_blanks # remove superfluous blanks from history items
|
||||||
|
setopt inc_append_history # save history entries as soon as they are entered
|
||||||
|
setopt share_history # share history between different instances of the shell
|
||||||
|
setopt auto_cd # cd by typing directory name if it's not a command
|
||||||
|
setopt correct_all # autocorrect commands
|
||||||
|
setopt auto_list # automatically list choices on ambiguous completion
|
||||||
|
setopt auto_menu # automatically use menu completion
|
||||||
|
setopt always_to_end # move cursor to end if word had one match
|
||||||
Reference in New Issue
Block a user