Use cache, async completion, vim keys, gpg authentication, compression for docker builds and some other stuff

This commit is contained in:
caskd 2019-12-18 19:31:56 +01:00
commit 3f5d9cf367
No known key found for this signature in database
GPG Key ID: 79DB21404E300A27
13 changed files with 239 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.zcompdump

9
.gitmodules vendored Normal file
View File

@ -0,0 +1,9 @@
[submodule "fast-syntax-highlighting"]
path = fast-syntax-highlighting
url = https://github.com/zdharma/fast-syntax-highlighting
[submodule "powerlevel10k"]
path = powerlevel10k
url = https://github.com/romkatv/powerlevel10k.git
[submodule "zsh-autosuggestions"]
path = zsh-autosuggestions
url = https://github.com/zsh-users/zsh-autosuggestions

13
.zshrc Normal file
View File

@ -0,0 +1,13 @@
ZSHBASECFG=/home/caskd/.zsh
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
startx
logout
fi
source "${ZSHBASECFG}/completions.zsh"
source "${ZSHBASECFG}/preferences.zsh"
source "${ZSHBASECFG}/bindings.zsh"
source "${ZSHBASECFG}/custom.zsh"

55
bindings.zsh Normal file
View File

@ -0,0 +1,55 @@
# https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/key-bindings.zsh
# https://wiki.archlinux.org/index.php/Zsh
bindkey -v
typeset -g -A key
key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Backspace]="${terminfo[kbs]}"
key[Delete]="${terminfo[kdch1]}"
key[Up]="${terminfo[kcuu1]}"
key[Down]="${terminfo[kcud1]}"
key[Left]="${terminfo[kcub1]}"
key[Right]="${terminfo[kcuf1]}"
key[PageUp]="${terminfo[kpp]}"
key[PageDown]="${terminfo[knp]}"
key[ShiftTab]="${terminfo[kcbt]}"
[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode
[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history
[[ -n "${key[ShiftTab]}" ]] && bindkey -- "${key[ShiftTab]}" reverse-menu-complete
bindkey ' ' magic-space # [Space] - do history expansion
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
autoload -Uz add-zle-hook-widget
function zle_application_mode_start {
echoti smkx
}
function zle_application_mode_stop {
echoti rmkx
}
add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
fi

17
completions.zsh Normal file
View File

@ -0,0 +1,17 @@
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zshcompcache
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' file-sort modification
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' rehash true
zstyle ':completion:*' menu select
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
zstyle :compinstall filename '${ZSHBASECFG}/completions.zsh'
autoload -Uz compinit
compinit

4
custom.zsh Normal file
View File

@ -0,0 +1,4 @@
ZSHCUSTOMDIR="${ZSHBASECFG}/custom"
source "${ZSHCUSTOMDIR}/dirstack.zsh"
source "${ZSHCUSTOMDIR}/prependsudo.zsh"
source "${ZSHCUSTOMDIR}/others.zsh"

1
custom/dirstack.zsh Normal file
View File

@ -0,0 +1 @@

74
custom/others.zsh Normal file
View File

@ -0,0 +1,74 @@
export DOCKER_HOST=ssh://fra-n0
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib:/usr/lib32:$HOME/.steam/bin/:$LD_LIBRARY_PATH
export EDITOR=vim
# GPG SSH
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null
function docker-all {
for ((i=0;i<=4;i++)); do
docker -H ssh://fra-n${i} $@
done
}
function build-n-push {
docker build ${1} --tag=localhost:5000/${2} --force-rm=true --compress=true && docker push localhost:5000/${2}
}
function manpdf {
man -Tpdf $1 | okular - &
disown
}
function gitsubrepo {
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \;
}
function gitcom {
git add -A && git commit -am "$1" && git push
# git diff HEAD^ --compact-summary | while read LINE; do echo "$LINE"; done
}
function osutab {
xinput set-prop 'UGTABLET 6 inch PenTablet Pen (0)' --type=float 153 3.5 0 -0.5 0 2.9 0 0 0 1
}
function ignorekate {
printf ".*~\n*.kate-swp" >> .gitignore
}
function tonullpointer {
if [ -z ${1} ]; then
RANDFN=${RANDOM}
> /tmp/${RANDFN}
curl -F"file=@/tmp/${RANDFN}" http://0x0.st
rm /tmp/${RANDFN}
else
curl -F"file=@${1}" http://0x0.st
fi
}
function convert2gif {
ffmpeg -hwaccel vdpau -i $1 -r 60 -vf "scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 ${1%.*}.gif
}
function youtube2gif {
if [ -z ${1} ] || [ -z ${2} ] || [ -z ${3} ]; then
echo "Usage: youtube2gif <url> <start position> <lenght> [resolution] [framerate] [bitrate]";
else
ffmpeg -ss ${2} -t ${3} -hwaccel vdpau -i $(youtube-dl -gf "bestvideo[height<=${4-360}]" ${1}) -r ${5-60} -vf "scale=${4-360}:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -b:v ${6-1000} -loop 0 -f gif -;
fi
}
alias recordscreen='ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0 -c:v libx264 -crf 0 -preset ultrafast'
alias ytdldown='youtube-dl -xcw --audio-format best --add-metadata --embed-thumbnail -o "/home/caskd/Media/Music/%(artist)s/%(album)s/%(title)s.%(ext)s"'
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias diff='diff --color=auto'
function man {
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
command man "$@"
}

11
custom/prependsudo.zsh Normal file
View File

@ -0,0 +1,11 @@
# 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 }"
else
LBUFFER="sudo $LBUFFER"
fi
}
zle -N sudo-command-line
bindkey '\e\e' sudo-command-line

@ -0,0 +1 @@
Subproject commit 634ab246365ef6b465b4cdf7c6f0727ec04759a9

1
powerlevel10k Submodule

@ -0,0 +1 @@
Subproject commit 826d8adf44caa562dc36d8b12b461e89eb035e78

51
preferences.zsh Normal file
View File

@ -0,0 +1,51 @@
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd extendedglob nomatch notify hist_ignore_all_dups hist_ignore_space nobeep
if [ -z "$SSH_CONNECTION" ] && ! [ -z "$DISPLAY" ]; then
source ${ZSHBASECFG}/powerlevel10k/powerlevel10k.zsh-theme
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
os_icon
time
ram
load
battery
ssh
root_indicator
newline
vi_mode
status
dir
dir_writable
)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
command_execution_time # duration of the last command
background_jobs # presence of background jobs
vcs
direnv # direnv status (https://direnv.net/)
virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html)
anaconda # conda environment (https://conda.io/)
pyenv # python environment (https://github.com/pyenv/pyenv)
nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv)
nvm # node.js version from nvm (https://github.com/nvm-sh/nvm)
nodeenv # node.js environment (https://github.com/ekalinin/nodeenv)
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
public_ip # public IP address
)
POWERLEVEL9K_MODE=nerdfont-complete
else
export TERM="xterm";
autoload -Uz promptinit
promptinit
prompt clint
fi
source ${ZSHBASECFG}/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
source ${ZSHBASECFG}/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_USE_ASYNC=true

1
zsh-autosuggestions Submodule

@ -0,0 +1 @@
Subproject commit d43c309f888153d6c46d8b6a3a0186f4148680fd