zshrc+zprofile updates

* optimise zplug, completions and ohmyzsh plugin loading resulting in
  faster load time
* introduce shell caching (surely another speed-up)
* clean-up zshrc and move stuff (wayland exports, sway call) to profile
* set cleaner git status indicators via SPACESHIP vars
* delete stuff (yeah, I know...)

as per #2
This commit is contained in:
surtur 2021-05-03 02:32:40 +02:00
parent e958c65101
commit 447e85b88f
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 68 additions and 74 deletions

@ -1,28 +1,38 @@
export PATH="$HOME/.local/bin:$HOME/utils/bin:$HOME/.cargo/bin:$GOPATH/bin:$PATH" export GOPATH=$HOME/utils/go
export CGO_ENABLED="1"
add_to_path() {
local p=$1
if [[ ! "$PATH" == *"$p"* ]]; then
export PATH="$p:$PATH"
fi
}
add_to_path "$HOME/.local/bin"
add_to_path "$HOME/utils/bin"
add_to_path "$HOME/.cargo/bin"
add_to_path "$GOPATH/bin"
export EDITOR='vim'
export TERM='xterm-256color'
export kee="surtur"
export SSH_KEY_PATH="$HOME/.ssh/$kee"
if [ ! -S ~/.ssh/ssh_auth_sock ]; then if [ ! -S ~/.ssh/ssh_auth_sock ]; then
eval `ssh-agent` > /dev/null eval `ssh-agent` > /dev/null
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
if [ ! -S $HOME/.ssh/ssh_auth_sock ]; then
eval `ssh-agent` > /dev/null
ln -sf "$SSH_AUTH_SOCK" $HOME/.ssh/ssh_auth_sock
fi fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
if [ -n "$DESKTOP_SESSION" ];then if [ -n "$DESKTOP_SESSION" ];then
eval $(gnome-keyring-daemon --start) eval $(gnome-keyring-daemon --start)
export SSH_AUTH_SOCK export SSH_AUTH_SOCK
fi fi
if [[ -z "$WAYLAND_DISPLAY" ]]; then
export QT_QPA_PLATFORMTHEME=wayland
export QT_AUTO_SCREEN_SCALE_FACTOR=0
export MOZ_DBUS_REMOTE=1
export MOZ_USE_XINPUT2=1
export _JAVA_AWT_WM_NONREPARENTING=1
export KITTY_ENABLE_WAYLAND=1
export BEMENU_BACKEND=wayland
else
export QT_QPA_PLATFORMTHEME="qt5ct"
fi
export DOTNET_CLI_TELEMETRY_OPTOUT=1 # why do I always have to take care of this myself... export DOTNET_CLI_TELEMETRY_OPTOUT=1 # why do I always have to take care of this myself...
export ANDROID_HOME=$HOME/utils/Android/Sdk export ANDROID_HOME=$HOME/utils/Android/Sdk
@ -34,3 +44,25 @@ export ANDROID_NDK_PATH=$ANDROID_HOME/ndk-bundle
export AndroidSdkPath=$ANDROID_HOME export AndroidSdkPath=$ANDROID_HOME
export AndroidNdkPath=$ANDROID_NDK_PATH export AndroidNdkPath=$ANDROID_NDK_PATH
if [[ -z $DISPLAY ]]; then
export QT_QPA_PLATFORMTHEME=wayland
export QT_QPA_PLATFORM=wayland
export QT_AUTO_SCREEN_SCALE_FACTOR=0
export MOZ_DBUS_REMOTE=1
export MOZ_USE_XINPUT2=1
export _JAVA_AWT_WM_NONREPARENTING=1
export KITTY_ENABLE_WAYLAND=1
export BEMENU_BACKEND=wayland
export SDL_VIDEODRIVER=wayland
export NO_AT_BRIDGE=1
export TDESKTOP_USE_PORTAL=1
if [[ $(tty) == /dev/tty1 ]]; then
export XDG_CURRENT_DESKTOP=sway
exec sway
elif [[ "$(tty)" == "/dev/tty2" ]] && ! ps -e | grep -qw sway
MOZ_ENABLE_WAYLAND=1 QT_QPA_PLATFORM=wayland XDG_SESSION_TYPE=wayland exec dbus-run-session gnome-session
fi
fi

82
zshrc

@ -5,15 +5,14 @@
source ~/.zplug/init.zsh source ~/.zplug/init.zsh
zplug "denysdovhan/spaceship-prompt", use:spaceship.zsh, from:github, as:theme zplug "denysdovhan/spaceship-prompt", use:spaceship.zsh, from:github, as:theme
zplug "zsh-users/zsh-autosuggestions", defer:2 zplug "zsh-users/zsh-autosuggestions", defer:2
#zplug "zsh-users/zsh-syntax-highlighting"
zplug "zdharma/fast-syntax-highlighting", defer:2
zplug "zsh-users/zsh-history-substring-search", defer:2 zplug "zsh-users/zsh-history-substring-search", defer:2
zplug "plugins/git", from:oh-my-zsh, defer:2 zplug "plugins/git", from:oh-my-zsh, defer:2
zplug "plugins/gitignore", from:oh-my-zsh, defer:2 zplug "plugins/gitignore", from:oh-my-zsh, defer:2
zplug "plugins/systemd", from:oh-my-zsh, defer:2 zplug "plugins/systemd", from:oh-my-zsh, defer:2
zplug "plugins/dnf", from:oh-my-zsh, defer:2 zplug "plugins/dnf", from:oh-my-zsh, defer:2
zplug "gradle/gradle-completion", from:github, defer:2 zplug "gradle/gradle-completion", from:github, defer:2
# zplug "arzzen/calc.plugin.zsh", defer:2 zplug "djui/alias-tips", defer:2
zplug "zdharma/fast-syntax-highlighting", defer:2
zplug 'zplug/zplug', hook-build:'zplug --self-manage' zplug 'zplug/zplug', hook-build:'zplug --self-manage'
# Install plugins if there are plugins that have not been installed # Install plugins if there are plugins that have not been installed
@ -23,24 +22,16 @@
echo; zplug install echo; zplug install
fi fi
fi fi
# zplug load zplug load
source ~/.zplug/repos/zsh-users/zsh-autosuggestions/zsh-autosuggestions.zsh
#source ~/.zplug/repos/zsh-users/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.zplug/repos/zdharma/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
source ~/.zplug/repos/zsh-users/zsh-history-substring-search/zsh-history-substring-search.zsh
source ~/.zplug/repos/robbyrussell/oh-my-zsh/plugins/git/git.plugin.zsh
source ~/.zplug/repos/robbyrussell/oh-my-zsh/plugins/gitignore/gitignore.plugin.zsh
source ~/.zplug/repos/robbyrussell/oh-my-zsh/plugins/systemd/systemd.plugin.zsh
source ~/.zplug/repos/robbyrussell/oh-my-zsh/plugins/dnf/dnf.plugin.zsh
source ~/.zplug/repos/gradle/gradle-completion/gradle-completion.plugin.zsh
#source ~/.zplug/repos/arzzen/calc.plugin.zsh/calc.plugin.zsh
ZSH_THEME="spaceship" ZSH_THEME="spaceship"
SPACESHIP_PROMPT_ORDER=(time user dir host git package node ruby golang php rust haskell docker venv pyenv dotnet exec_time line_sep battery jobs exit_code char) SPACESHIP_PROMPT_ORDER=(time user dir host git hg package node ruby golang rust docker pyenv dotnet exec_time line_sep battery jobs exit_code char)
SPACESHIP_PROMPT_ADD_NEWLINE=false SPACESHIP_PROMPT_ADD_NEWLINE=false
SPACESHIP_PROMPT_SEPARATE_LINE=true SPACESHIP_PROMPT_SEPARATE_LINE=true
SPACESHIP_DIR_PREFIX= SPACESHIP_TIME_SHOW=true
SPACESHIP_TIME_COLOR=white
SPACESHIP_DIR_PREFIX="%F{green}▲ "
SPACESHIP_DIR_COLOR=blue SPACESHIP_DIR_COLOR=blue
#SPACESHIP_DIR_TRUNC=3 #SPACESHIP_DIR_TRUNC=3
SPACESHIP_DIR_TRUNC_REPO=false SPACESHIP_DIR_TRUNC_REPO=false
@ -48,17 +39,19 @@
SPACESHIP_HOST_PREFIX="@" SPACESHIP_HOST_PREFIX="@"
SPACESHIP_HOST_COLOR=green SPACESHIP_HOST_COLOR=green
SPACESHIP_GIT_BRANCH_COLOR=red SPACESHIP_GIT_BRANCH_COLOR=red
SPACESHIP_GIT_STATUS_COLOR=yellow SPACESHIP_GIT_STATUS_COLOR=red
SPACESHIP_GIT_STATUS_PREFIX=" "
SPACESHIP_GIT_STATUS_SUFFIX=""
SPACESHIP_GIT_STATUS_ADDED="%F{green}•%F{red}" # +
SPACESHIP_GIT_STATUS_UNTRACKED="%F{blue}•%F{red}" # ?
SPACESHIP_GIT_STATUS_DELETED="%F{red}•%F{red}" # x
SPACESHIP_GIT_STATUS_MODIFIED="%F{yellow}•%F{green}" # !
SPACESHIP_BATTERY_SHOW=true SPACESHIP_BATTERY_SHOW=true
SPACESHIP_BATTERY_THRESHOLD=35 SPACESHIP_BATTERY_THRESHOLD=35
#SPACESHIP_CHAR_SYMBOL=\>
SPACESHIP_CHAR_COLOR_SUCCESS=green SPACESHIP_CHAR_COLOR_SUCCESS=green
#SPACESHIP_CHAR_SUFFIX=""
# Path to your oh-my-zsh installation. # Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh export ZSH=$HOME/.oh-my-zsh
#ZSH_THEME="myowntheme_with_time"
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion. # Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true" # CASE_SENSITIVE="true"
@ -109,11 +102,7 @@
# Would you like to use another custom folder than $ZSH/custom? # Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder # ZSH_CUSTOM=/path/to/new-custom-folder
plugins=(safe-paste docker fzf) plugins=(asdf safe-paste docker dotnet firewalld fzf golang terraform torrent vagrant )
source ~/.asdf/asdf.sh
# append completions to fpath
fpath=(${ASDF_DIR}/completions $fpath)
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor) ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
@ -121,6 +110,8 @@
ZSH_AUTOSUGGEST_STRATEGY=(history completion) ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_USE_ASYNC= ZSH_AUTOSUGGEST_USE_ASYNC=
ZSH_THEME_GIT_PROMPT_CACHE=" "
# map Del escape sequence to actual Del key in all (n,i) modes to resemble vim instead of vi # map Del escape sequence to actual Del key in all (n,i) modes to resemble vim instead of vi
bindkey -a '^[[3~' delete-char bindkey -a '^[[3~' delete-char
# map arrow up/down to control fish-like history substring search and highlighting # map arrow up/down to control fish-like history substring search and highlighting
@ -132,35 +123,28 @@
export FZF_COMPLETION_TRIGGER='~~' export FZF_COMPLETION_TRIGGER='~~'
# Options to fzf command # Options to fzf command
export FZF_COMPLETION_OPTS='+c -x' export FZF_COMPLETION_OPTS='+c -x'
export FZF_DEFAULT_OPTS='--color fg:241,bg:235,hl:65,fg+:15,bg+:239,hl+:108 --color info:108,prompt:109,spinner:108,pointer:168,marker:168'
export FZF_DEFAULT_COMMAND="fzf --preview 'head -100 {}'" export FZF_DEFAULT_COMMAND="fzf --preview 'head -100 {}'"
# User configuration # User configuration
_dotnet_zsh_complete(){
local completions=("$(dotnet complete "$words")")
reply=( "${(ps:\n:)completions}" )
}
compctl -K _dotnet_zsh_complete dotnet
source ~/.zprofile
source ~/.dotenv source ~/.dotenv
export PATH="$HOME/.local/bin:$HOME/utils/bin:$HOME/.cargo/bin:$GOPATH/bin:$PATH"
# You may need to manually set your language environment # You may need to manually set your language environment
export LANG=en_GB.UTF-8 export LANG=en_GB.UTF-8
export http_proxy="http://localhost:8118" export http_proxy="http://localhost:8118"
if [ ! -S ~/.ssh/ssh_auth_sock ]; then if [ ! -S $HOME/.ssh/ssh_auth_sock ]; then
eval `ssh-agent` > /dev/null eval `ssh-agent` > /dev/null
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock ln -sf "$SSH_AUTH_SOCK" $HOME/.ssh/ssh_auth_sock
fi fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
export EDITOR='vim' export EDITOR='vim'
export TERM='xterm-256color' export TERM='xterm-256color'
# export ARCHFLAGS="-arch x86_64" # export ARCHFLAGS="-arch x86_64"
export kee="surtur" export kee="surtur"
export SSH_KEY_PATH="~/.ssh/$kee" export SSH_KEY_PATH="$HOME/.ssh/$kee"
eval $(TERM=xterm-256color dircolors) eval $(TERM=xterm-256color dircolors)
alias ls='exa -al --group-directories-first' alias ls='exa -al --group-directories-first'
@ -196,25 +180,6 @@
alias urlencode='python2 -c "import urllib, sys; print urllib.quote_plus( sys.argv[1] if len(sys.argv) > 1 else sys.stdin.read()[0:-1], \"\")"' alias urlencode='python2 -c "import urllib, sys; print urllib.quote_plus( sys.argv[1] if len(sys.argv) > 1 else sys.stdin.read()[0:-1], \"\")"'
alias urldecode='python2 -c "import urllib, sys; print urllib.unquote_plus(sys.argv[1] if len(sys.argv) > 1 else sys.stdin.read()[0:-1])"' alias urldecode='python2 -c "import urllib, sys; print urllib.unquote_plus(sys.argv[1] if len(sys.argv) > 1 else sys.stdin.read()[0:-1])"'
export ANDROID_HOME=$HOME/utils/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_SDK_PATH=$ANDROID_HOME
export ANDROID_NDK_PATH=$ANDROID_HOME/ndk-bundle
export AndroidSdkPath=$ANDROID_HOME
export AndroidNdkPath=$ANDROID_NDK_PATH
export WORKON_HOME=~/utils/venv
#source utils/venv/bin/activate
export PIP_VIRTUALENV_BASE=~/utils/venv
export DOTNET_CLI_TELEMETRY_OPTOUT=1 # why do I always have to take care of this myself...
export MOZ_USE_XINPUT2=1
export _JAVA_AWT_WM_NONREPARENTING=1
#bindkey -v # enabled ohmyzsh vi-mode - more customizable than the original
transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi;tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; } transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi;tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
@ -239,6 +204,3 @@
echo $FILE_URL echo $FILE_URL
} }
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
exec sway
fi