Overhaul config in general
This commit is contained in:
parent
3fef5f3ad0
commit
b3b4bee062
87
init.zsh
87
init.zsh
@ -1,24 +1,33 @@
|
||||
# Main zsh config file
|
||||
|
||||
# Some utility stuff
|
||||
# Enable completions
|
||||
autoload -U compinit && compinit
|
||||
fpath+=("${ZSH_CONFIG_DIR}/functions")
|
||||
|
||||
# Some utility stuff
|
||||
ZSH_PLUGIN_DIR="${ZSH_CONFIG_DIR}/plugins"
|
||||
# load_plugin <name>
|
||||
function load_plugin {
|
||||
source "${ZSH_PLUGIN_DIR}/${1}/${1}.plugin.zsh"
|
||||
}
|
||||
# cmd_exists <name>
|
||||
function cmd_exists {
|
||||
hash "${1}" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
ZSH_EARLY_LOCAL_FILE="${ZSH_CONFIG_DIR}/local-early.zsh"
|
||||
[ -e "${ZSH_EARLY_LOCAL_FILE}" ] && source "${ZSH_EARLY_LOCAL_FILE}"
|
||||
# User configuration file
|
||||
[[ -v ZSH_USER_DIR ]] || ZSH_USER_DIR="${HOME}/.zsh.d"
|
||||
# source_user_file <name>
|
||||
function source_user_file {
|
||||
[ -e "${ZSH_USER_DIR}/${1}" ] && source "${ZSH_USER_DIR}/${1}"
|
||||
}
|
||||
|
||||
# Load user early init file
|
||||
source_user_file "early-init.zsh"
|
||||
|
||||
# Some options
|
||||
setopt autocd extendedglob rm_star_silent
|
||||
unsetopt beep notify
|
||||
|
||||
# Show which completion we are on
|
||||
zstyle ':completion:*' menu select
|
||||
|
||||
# Some general, random configuration
|
||||
# History stuff
|
||||
[ -v HISTFILE ] || HISTFILE="${HOME}/.cache/zsh/history"
|
||||
@ -26,11 +35,14 @@ zstyle ':completion:*' menu select
|
||||
HISTSIZE=1000
|
||||
SAVEHIST=10000
|
||||
|
||||
# Set some random stuff
|
||||
# Tools for graphical sessions
|
||||
export BROWSER=firefox
|
||||
export READER=zathura
|
||||
alias clip="xclip -selection clipboard"
|
||||
|
||||
# I mess this up a lot
|
||||
alias cd..="cd .."
|
||||
|
||||
# Neovim stuff
|
||||
if [[ -v NVIM ]]; then
|
||||
export EDITOR=nvr
|
||||
@ -43,12 +55,6 @@ fi
|
||||
export VISUAL="${EDITOR}"
|
||||
alias se=sudoedit
|
||||
|
||||
# I mess this up a lot
|
||||
alias cd..="cd .."
|
||||
|
||||
# Enable mouse support in less
|
||||
export LESS="--mouse"
|
||||
|
||||
# Safer file functions
|
||||
local rm_confirm_flag='-i'
|
||||
uname | grep -i linux >/dev/null && rm_confirm_flag='-I'
|
||||
@ -56,19 +62,11 @@ alias rm="rm ${rm_confirm_flag}"
|
||||
alias cp="cp -i"
|
||||
alias mv="mv -i"
|
||||
|
||||
# Use vi mode
|
||||
bindkey -v
|
||||
# Implement a replace mode
|
||||
bindkey -N virep viins
|
||||
bindkey -M vicmd "R" overwrite-mode
|
||||
function overwrite-mode {
|
||||
zle -K virep
|
||||
zle .overwrite-mode
|
||||
}
|
||||
zle -N overwrite-mode
|
||||
# Enable mouse support in less
|
||||
export LESS="--mouse"
|
||||
|
||||
# Bat configuration
|
||||
if which bat >/dev/null 2>&1; then
|
||||
if cmd_exists bat; then
|
||||
# Pager
|
||||
export PAGER="bat --paging=always"
|
||||
|
||||
@ -85,13 +83,15 @@ if which bat >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
# Exa configuration
|
||||
if which exa >/dev/null 2>&1; then
|
||||
if cmd_exists exa; then
|
||||
alias ls="exa --git -F"
|
||||
alias la="ls -a"
|
||||
alias l="ls -l"
|
||||
alias ll="ls -al"
|
||||
fi
|
||||
|
||||
# Delta configuration
|
||||
if which delta >/dev/null 2>&1; then
|
||||
if cmd_exists delta; then
|
||||
export DELTA_FEATURES='unobtrusive-line-numbers decorations side-by-side'
|
||||
export DELTA_PAGER='bat -p'
|
||||
export GIT_PAGER='delta'
|
||||
@ -145,6 +145,19 @@ load_plugin zsh-autosuggestions
|
||||
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
|
||||
bindkey '^ ' autosuggest-accept
|
||||
|
||||
# Use vi mode
|
||||
bindkey -v
|
||||
# Fast switch of modes
|
||||
KEYTIMEOUT=1
|
||||
# Implement a replace mode
|
||||
bindkey -N virep viins
|
||||
bindkey -M vicmd "R" overwrite-mode
|
||||
function overwrite-mode {
|
||||
zle -K virep
|
||||
zle .overwrite-mode
|
||||
}
|
||||
zle -N overwrite-mode
|
||||
|
||||
# Fancy prompt (starship)
|
||||
eval "$(starship init zsh)"
|
||||
# Change cursor shape for different vi modes.
|
||||
@ -175,9 +188,6 @@ function zle-line-init {
|
||||
zle -N zle-keymap-select
|
||||
zle -N zle-line-init
|
||||
|
||||
# Fast switch of modes
|
||||
KEYTIMEOUT=1
|
||||
|
||||
# Clear scrollback on ^l
|
||||
__zsh_clear_screen_and_scrollback() {
|
||||
echoti civis >"$TTY"
|
||||
@ -187,12 +197,11 @@ __zsh_clear_screen_and_scrollback() {
|
||||
printf '%b' '\e[3J' >"$TTY"
|
||||
echoti cnorm >"$TTY"
|
||||
}
|
||||
|
||||
zle -N __zsh_clear_screen_and_scrollback
|
||||
bindkey '^L' __zsh_clear_screen_and_scrollback
|
||||
|
||||
# Direnv
|
||||
if which direnv >/dev/null 2>&1; then
|
||||
if cmd_exists direnv; then
|
||||
eval "$(direnv hook zsh)"
|
||||
fi
|
||||
|
||||
@ -204,11 +213,6 @@ source "${ZSH_CONFIG_DIR}/bookmark.zsh"
|
||||
# Platform specific stuff
|
||||
[ -f /usr/bin/pacman ] && source "${ZSH_CONFIG_DIR}/arch.zsh"
|
||||
|
||||
__ZSH_LOCAL_FILE="${ZSH_CONFIG_DIR}/local.zsh"
|
||||
[ -e "${__ZSH_LOCAL_FILE}" ] && source "${__ZSH_LOCAL_FILE}"
|
||||
|
||||
# THE FOLLOWING PLUGINS MUST COME LAST
|
||||
|
||||
# FZF Integration
|
||||
load_plugin fzf-tab
|
||||
# Disable sort when completing `git checkout`
|
||||
@ -226,6 +230,11 @@ zstyle ':fzf-tab:*' switch-group 'ctrl-h' 'ctrl-l'
|
||||
# Toggle selected for all visible entries
|
||||
zstyle ':fzf-tab:*' fzf-bindings 'ctrl-a:toggle-all'
|
||||
|
||||
# Load user init file
|
||||
source_user_file 'local.zsh'
|
||||
|
||||
# THE FOLLOWING PLUGINS MUST COME LAST
|
||||
|
||||
# More completions
|
||||
load_plugin zsh-completions
|
||||
|
||||
@ -245,13 +254,15 @@ bindkey -M vicmd 'j' history-substring-search-down
|
||||
bindkey -M emacs '^P' history-substring-search-up
|
||||
bindkey -M emacs '^N' history-substring-search-down
|
||||
|
||||
# Only match at the begining of the line
|
||||
# Only match at the beginning of the line
|
||||
HISTORY_SUBSTRING_SEARCH_PREFIXED="true"
|
||||
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND=""
|
||||
setopt histignoredups
|
||||
|
||||
# Clean up internal functions
|
||||
unfunction load_plugin
|
||||
unfunction cmd_exists
|
||||
unfunction source_user_file
|
||||
|
||||
# Run fortune and cowsay if we are not in nvim
|
||||
[[ -v NVIM ]] || fortune | cowsay -felephant-in-snake -n
|
||||
|
@ -1,26 +0,0 @@
|
||||
# Some extra environment variables
|
||||
export PATH="${HOME}/.local/bin:${PATH}"
|
||||
export JDK_JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dsun.java2d.opengl=true -Dsun.java2d.uiScale=3"
|
||||
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||
export DEBUGINFOD_URLS="https://debuginfod.archlinux.org"
|
||||
|
||||
add_ssh_keys() {
|
||||
pass show ssh/personal_gitea | ssh-add ~/.ssh/personal_gitea
|
||||
pass show ssh/personal_server | ssh-add ~/.ssh/personal_server
|
||||
pass show ssh/gandi_vps | ssh-add ~/.ssh/gandi_vps
|
||||
}
|
||||
|
||||
# Because I use zsh to start X11
|
||||
if [[ -o login ]]; then
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
eval "$(gnome-keyring-daemon --start 2>/dev/null)"
|
||||
eval "$(ssh-agent)"
|
||||
SSH_ASKPASS_REQUIRE="force" SSH_ASKPASS="/usr/local/bin/ssh-askpass-cat.sh" add_ssh_keys
|
||||
|
||||
if ! [[ -v DISPLAY ]] && [ "${XDG_VTNR}" -eq 1 ]; then
|
||||
exec startx
|
||||
fi
|
||||
fi
|
||||
|
||||
alias dots="git --git-dir=${HOME}/src/dotfiles --work-tree=/"
|
Loading…
Reference in New Issue
Block a user