mirror of
https://github.com/frebib/dotfiles.git
synced 2024-06-14 12:57:23 +00:00
dotfiles: move .config/* to root
This seems to make more sense. Almost all files were within .config anyway. Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
4
zsh/.gitignore
vendored
Normal file
4
zsh/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/antigen/
|
||||
/log/
|
||||
/histfile
|
||||
/.zcompdump*
|
1
zsh/.zprofile
Symbolic link
1
zsh/.zprofile
Symbolic link
@ -0,0 +1 @@
|
||||
../profile
|
176
zsh/.zshrc
Normal file
176
zsh/.zshrc
Normal file
@ -0,0 +1,176 @@
|
||||
# Config and cache directory paths
|
||||
ZSH_DIR="$XDG_CONFIG_HOME/zsh"
|
||||
LOG_DIR="$XDG_DATA_HOME/logs"
|
||||
HISTFILE="$XDG_DATA_HOME/zsh/history"
|
||||
HISTSIZE=999999
|
||||
SAVEHIST=999999
|
||||
|
||||
mkdir -p "$LOG_DIR" "$(dirname "$HISTFILE")"
|
||||
|
||||
exists() { which $@ 0<&- 1>/dev/null 2>/dev/null; }
|
||||
|
||||
# Only set tty if running interactively
|
||||
if exists tty && tty -s; then
|
||||
# Resolve at shell runtime
|
||||
export GPG_TTY="$(tty)"
|
||||
fi
|
||||
|
||||
# Configure less and add colours
|
||||
export LESS="-RI --mouse --wheel-lines=3"
|
||||
export PAGER="less"
|
||||
export MANPAGER="less -+N"
|
||||
export SYSTEMD_PAGER="less $LESS"
|
||||
# Disable histfile
|
||||
export LESSHISTFILE=-
|
||||
# Use .local/share for z instead of ~/.z
|
||||
export _Z_DATA="$XDG_DATA_HOME/z"
|
||||
|
||||
if exists tput; then
|
||||
export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green
|
||||
export LESS_TERMCAP_md=$(tput bold; tput setaf 6) # cyan
|
||||
export LESS_TERMCAP_me=$(tput sgr0)
|
||||
export LESS_TERMCAP_so=$(tput bold; tput setaf 4) # blue
|
||||
export LESS_TERMCAP_se=$(tput rmso; tput sgr0)
|
||||
export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7) # white
|
||||
export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
|
||||
export LESS_TERMCAP_mr=$(tput rev)
|
||||
export LESS_TERMCAP_mh=$(tput dim)
|
||||
export LESS_TERMCAP_ZN=$(tput ssubm)
|
||||
export LESS_TERMCAP_ZV=$(tput rsubm)
|
||||
export LESS_TERMCAP_ZO=$(tput ssupm)
|
||||
export LESS_TERMCAP_ZW=$(tput rsupm)
|
||||
fi
|
||||
|
||||
# Set some useful ZSH/Bash options
|
||||
setopt sharehistory histignorealldups histignorespace histreduceblanks
|
||||
setopt pathdirs autocd autopushd extendedglob nullglob alwaystoend interactivecomments dvorak
|
||||
|
||||
zstyle ':completion:*:sudo|_::' environ PATH="/sbin:/usr/sbin:$PATH" HOME="/root"
|
||||
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*'
|
||||
zstyle ':completion:*' rehash true
|
||||
zstyle ':completion:*' menu select
|
||||
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
|
||||
zstyle ':compinstall' filename "${ZDOTDIR:-~}/.zshrc"
|
||||
|
||||
# Pre-load vi-mode edit-command-line before antigen plugins are loaded
|
||||
autoload -z edit-command-line
|
||||
zle -N edit-command-line
|
||||
|
||||
export WORDCHARS='*?_[]~=&;!#$%^(){}'
|
||||
x-bash-backward-kill-word(){ WORDCHARS='' zle kill-word; }
|
||||
zle -N x-bash-backward-kill-word
|
||||
|
||||
# Load antigen & plugins
|
||||
ANTIGEN_LOG="$LOG_DIR/antigen-$(date -u --iso-8601=seconds | cut -d+ -f1).log"
|
||||
antigen_src="$ADOTDIR/antigen.zsh"
|
||||
if [ ! -f "$antigen_src" ]; then
|
||||
git clone https://github.com/zsh-users/antigen.git "$ADOTDIR"
|
||||
fi
|
||||
source "$antigen_src"
|
||||
|
||||
antigen bundle zsh-users/zsh-completions
|
||||
antigen bundle zsh-users/zsh-autosuggestions
|
||||
antigen bundle zsh-users/zsh-syntax-highlighting@feature/redrawhook
|
||||
antigen bundle mafredri/zsh-async
|
||||
antigen bundle agkozak/zsh-z
|
||||
|
||||
antigen apply
|
||||
|
||||
# Vim mode!
|
||||
bindkey -v
|
||||
export KEYTIMEOUT=25
|
||||
|
||||
# Set some key-binds
|
||||
bindkey "^[[1;3C" forward-word
|
||||
bindkey "^[[1;5C" forward-word
|
||||
bindkey "^[[1;3D" backward-word
|
||||
bindkey "^[[1;5D" backward-word
|
||||
bindkey "^[[7~" beginning-of-line
|
||||
bindkey "^[[8~" end-of-line
|
||||
bindkey "^[[3~" delete-char
|
||||
bindkey "^[[3;3~" delete-word
|
||||
bindkey '^[^[[3~' x-bash-backward-kill-word
|
||||
bindkey '^[^[[3^' x-bash-backward-kill-word
|
||||
bindkey '^[[A' fzf-history-widget # Up (fzf)
|
||||
bindkey '^[[B' fzf-history-widget # Down (fzf)
|
||||
bindkey '^F' fzf-file-widget # Ctrl+F file search (fzf)
|
||||
|
||||
bindkey "^F" fzf-file-widget
|
||||
bindkey -M vicmd "^W" backward-delete-word
|
||||
|
||||
bindkey -M vicmd d vi-backward-char
|
||||
bindkey -M vicmd h vi-down-line-or-history
|
||||
bindkey -M vicmd t vi-up-line-or-history
|
||||
bindkey -M vicmd n vi-forward-char
|
||||
bindkey -M vicmd k vi-delete
|
||||
bindkey -M vicmd K vi-kill-eol
|
||||
bindkey -M vicmd j vi-find-next-char-skip
|
||||
bindkey -M vicmd l vi-repeat-search
|
||||
|
||||
# Backspace across newlines when in vi-mode
|
||||
bindkey -v '^?' backward-delete-char
|
||||
|
||||
ZSH_AUTOSUGGEST_USE_ASYNC=true
|
||||
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=128
|
||||
ZSH_AUTOSUGGEST_CLEAR_WIDGETS=("${(@)ZSH_AUTOSUGGEST_CLEAR_WIDGETS:#(up|down)-line-or-history}")
|
||||
|
||||
default='fg=12'
|
||||
prog='fg=blue'
|
||||
ZSH_HIGHLIGHT_STYLES=()
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets root line)
|
||||
ZSH_HIGHLIGHT_STYLES[root]='bg=red'
|
||||
ZSH_HIGHLIGHT_STYLES[default]=$default
|
||||
ZSH_HIGHLIGHT_STYLES[arg0]=$prog
|
||||
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red,bold'
|
||||
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=yellow'
|
||||
ZSH_HIGHLIGHT_STYLES[alias]=$prog
|
||||
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=green'
|
||||
ZSH_HIGHLIGHT_STYLES[builtin]='fg=4'
|
||||
ZSH_HIGHLIGHT_STYLES[function]=$prog
|
||||
ZSH_HIGHLIGHT_STYLES[command]=$prog
|
||||
ZSH_HIGHLIGHT_STYLES[precommand]='fg=4'
|
||||
ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=cyan'
|
||||
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=green'
|
||||
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
|
||||
ZSH_HIGHLIGHT_STYLES[path_separator]='fg=cyan'
|
||||
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=208'
|
||||
ZSH_HIGHLIGHT_STYLES[globbing]='fg=red'
|
||||
ZSH_HIGHLIGHT_STYLES[comment]='fg=7'
|
||||
ZSH_HIGHLIGHT_STYLES[history-expansion]=$default
|
||||
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=$default
|
||||
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=$default
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='fg=magenta'
|
||||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=yellow'
|
||||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow'
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]='fg=yellow'
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=cyan'
|
||||
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=cyan'
|
||||
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]='fg=cyan'
|
||||
ZSH_HIGHLIGHT_STYLES[assign]='fg=green'
|
||||
ZSH_HIGHLIGHT_STYLES[redirection]='fg=cyan,bold'
|
||||
|
||||
source "$DOTFILES/aliases"
|
||||
|
||||
# Source secret keys and values into environment
|
||||
if [ -f "$XDG_CONFIG_HOME/secrets" ]; then
|
||||
set -o allexport
|
||||
source $XDG_CONFIG_HOME/secrets
|
||||
set +o allexport
|
||||
fi
|
||||
|
||||
# Load some manual plugins
|
||||
source "$ZSH_DIR/plugins/sudo.zsh"
|
||||
source "$ZSH_DIR/plugins/fish-theme.zsh"
|
||||
source "$ZSH_DIR/plugins/git-rprompt.zsh"
|
||||
[ -f '/usr/share/fzf/key-bindings.zsh' ] && source /usr/share/fzf/key-bindings.zsh
|
||||
[ -f '/usr/share/doc/pkgfile/command-not-found.zsh' ] && source /usr/share/doc/pkgfile/command-not-found.zsh
|
||||
|
||||
# Completion initialisation
|
||||
autoload -U compinit bashcompinit
|
||||
compinit
|
||||
bashcompinit
|
||||
|
||||
# gopass completion
|
||||
if exists gopass; then
|
||||
source <(gopass completion bash)
|
||||
fi
|
14
zsh/plugins/fish-theme.zsh
Normal file
14
zsh/plugins/fish-theme.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
# ZSH Theme emulating the Fish shell's default prompt.
|
||||
|
||||
_fishy_collapsed_wd() {
|
||||
pwd | sed -E 's|^'$HOME'|~|;s|(.*)/|\1%|;s|((^\|/)\.?[^/%]{1})[^/%]*|\1|g;s|(.*)%|\1/|'
|
||||
}
|
||||
|
||||
# Required for dynamic prompt
|
||||
setopt prompt_subst
|
||||
|
||||
local user_color='green'; [ $UID -eq 0 ] && user_color='red'
|
||||
PROMPT="%n@%m %F{$user_color}\$(_fishy_collapsed_wd)%f%(!.#.>) "
|
||||
PROMPT2='%F{red}\ %f'
|
||||
|
||||
RPROMPT='%F{red}%(?.. %?)%f'
|
74
zsh/plugins/git-rprompt.zsh
Normal file
74
zsh/plugins/git-rprompt.zsh
Normal file
@ -0,0 +1,74 @@
|
||||
# ZSH RPROMPT containing simple Git status
|
||||
|
||||
git_prompt_info() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
}
|
||||
git_prompt_status() {
|
||||
# Get the status of the working tree
|
||||
INDEX=$(command git status --porcelain -b 2> /dev/null)
|
||||
RESET='%f'
|
||||
STATUS=""
|
||||
if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$RESET$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$RESET$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$RESET$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$RESET$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$RESET$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$RESET$STATUS"
|
||||
fi
|
||||
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then
|
||||
AHEAD=$(echo "$INDEX" | sed -nE 's/.*ahead\s([0-9]*).*/\1/p')
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$AHEAD$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then
|
||||
BEHIND=$(echo "$INDEX" | sed -nE 's/.*behind\s([0-9]*).*/\1/p')
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$BEHIND$RESET$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$RESET$STATUS"
|
||||
fi
|
||||
echo $STATUS
|
||||
}
|
||||
|
||||
# Required for dynamic prompt
|
||||
setopt prompt_subst
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" "
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=""
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
ZSH_THEME_GIT_PROMPT_AHEAD="%F{green}↑"
|
||||
ZSH_THEME_GIT_PROMPT_BEHIND="%F{red}↓"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%F{green}+"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%F{blue}~"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%F{red}-"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%F{magenta}>"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="%F{yellow}#"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%F{cyan}?"
|
||||
|
||||
RPROMPT="\$(git_prompt_info)\$(git_prompt_status)%{\$reset_color%}$RPROMPT"
|
20
zsh/plugins/sudo.zsh
Normal file
20
zsh/plugins/sudo.zsh
Normal file
@ -0,0 +1,20 @@
|
||||
# Source: https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/sudo/sudo.plugin.zsh
|
||||
|
||||
sudo-command-line() {
|
||||
[[ -z $BUFFER ]] && zle up-history
|
||||
if [[ $BUFFER == sudo\ * ]]; then
|
||||
LBUFFER="${LBUFFER#sudo }"
|
||||
elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]] || [[ $BUFFER == vim\ * ]]; then
|
||||
LBUFFER="s$LBUFFER"
|
||||
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]|| [[ $BUFFER == svim\ * ]]; then
|
||||
LBUFFER="${LBUFFER#sudoedit }"
|
||||
LBUFFER="${LBUFFER#s}"
|
||||
else
|
||||
LBUFFER="sudo $LBUFFER"
|
||||
fi
|
||||
|
||||
_zsh_highlight
|
||||
}
|
||||
zle -N sudo-command-line
|
||||
# Defined shortcut keys: [Esc] [Esc]
|
||||
bindkey "\e\e" sudo-command-line
|
Reference in New Issue
Block a user