From d917f82fff531d01cb07408c097e74ffd4e26715 Mon Sep 17 00:00:00 2001 From: Joachim Nielandt Date: Tue, 14 Jul 2020 21:47:53 +0200 Subject: [PATCH] Added ohmyzsh to chezmoi --- .../oh-my-zsh/custom/01_variables.zsh | 38 +++ dot_dotfiles/oh-my-zsh/custom/02_zplug.zsh | 232 ++++++++++++++++++ .../oh-my-zsh/custom/08_shell_settings.zsh | 2 + dot_dotfiles/oh-my-zsh/custom/09_alias.zsh | 15 ++ dot_dotfiles/oh-my-zsh/custom/09_settings.zsh | 105 ++++++++ dot_dotfiles/oh-my-zsh/custom/10_finalise.zsh | 6 + .../themes/symlink_powerlevel10k.zsh-theme | 1 + 7 files changed, 399 insertions(+) create mode 100644 dot_dotfiles/oh-my-zsh/custom/01_variables.zsh create mode 100644 dot_dotfiles/oh-my-zsh/custom/02_zplug.zsh create mode 100644 dot_dotfiles/oh-my-zsh/custom/08_shell_settings.zsh create mode 100644 dot_dotfiles/oh-my-zsh/custom/09_alias.zsh create mode 100644 dot_dotfiles/oh-my-zsh/custom/09_settings.zsh create mode 100644 dot_dotfiles/oh-my-zsh/custom/10_finalise.zsh create mode 100644 dot_dotfiles/oh-my-zsh/custom/themes/symlink_powerlevel10k.zsh-theme diff --git a/dot_dotfiles/oh-my-zsh/custom/01_variables.zsh b/dot_dotfiles/oh-my-zsh/custom/01_variables.zsh new file mode 100644 index 0000000..06e7c2e --- /dev/null +++ b/dot_dotfiles/oh-my-zsh/custom/01_variables.zsh @@ -0,0 +1,38 @@ +# make sure LS behaves as we want it to +if [[ $OSTYPE = (linux)* ]]; then + export LS_OPTIONS='--color=auto' +fi + +# terminal definition +export TERM="rxvt-unicode-256color" + +# default programs +export SHELL="/bin/zsh" +export EDITOR="vim" + +# LOCALE settings +export LANG="en_US.UTF-8" +export LC_ALL="en_US.UTF-8" + +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH +# ZSH History +export HISTFILE="$HOME/.zsh_history" +export HISTSIZE=100000 +export SAVEHIST=$HISTSIZE + +#export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' +# MANPAGE settings +export LESS_TERMCAP_mb=$'\e[1;31m' # begin bold +export LESS_TERMCAP_md=$'\e[1;36m' # begin blink +export LESS_TERMCAP_so=$'\e[1;33;44m' # begin reverse video +export LESS_TERMCAP_us=$'\e[1;37m' # begin underline +export LESS_TERMCAP_me=$'\e[0m' # reset bold/blink +export LESS_TERMCAP_se=$'\e[0m' # reset reverse video +export LESS_TERMCAP_ue=$'\e[0m' # reset underline +export GROFF_NO_SGR=1 # for konsole and gnome-terminal +export MANPAGER='less -s -M -R +Gg' +export MANPATH="/usr/local/man:$MANPATH" + +# Add ~/bin to the PATH +[ -d "$HOME/bin" ] && export PATH="$HOME/bin:$PATH" diff --git a/dot_dotfiles/oh-my-zsh/custom/02_zplug.zsh b/dot_dotfiles/oh-my-zsh/custom/02_zplug.zsh new file mode 100644 index 0000000..dfb4cf1 --- /dev/null +++ b/dot_dotfiles/oh-my-zsh/custom/02_zplug.zsh @@ -0,0 +1,232 @@ +# ============================================================================= +# Plugins +# ============================================================================= +export ZPLUG_LOADED=blabla +# Check if zplug is installed +[ ! -d ~/.zplug ] && git clone https://github.com/zplug/zplug ~/.zplug + +# enable zplug +source ~/.zplug/init.zsh +zplug 'zplug/zplug', hook-build:'zplug --self-manage' + +# Because your terminal should be able to perform tasks asynchronously without external tools! +zplug "mafredri/zsh-async", from:github, use:async.zsh + +# introduce 256 colors in terminal +zplug "chrissicool/zsh-256color" + +# not sure what anyframe does... allows other plugins to function? works with fzf +zplug "mollifier/anyframe" +if zplug check "mollifier/anyframe"; then + # expressly specify to use peco + #zstyle ":anyframe:selector:" use peco + # expressly specify to use percol + #zstyle ":anyframe:selector:" use percol + # expressly specify to use fzf-tmux + #zstyle ":anyframe:selector:" use fzf-tmux + # expressly specify to use fzf + zstyle ":anyframe:selector:" use fzf + + # specify path and options for peco, percol, or fzf + #zstyle ":anyframe:selector:peco:" command 'peco --no-ignore-case' + #zstyle ":anyframe:selector:percol:" command 'percol --case-sensitive' + #zstyle ":anyframe:selector:fzf-tmux:" command 'fzf-tmux --extended' + #zstyle ":anyframe:selector:fzf:" command 'fzf --extended' + #zstyle ":anyframe:selector:fzf:" command 'fzf' + + #bindkey '^@' anyframe-widget-cd-ghq-repository + #bindkey '^r' anyframe-widget-put-history +fi + +# print a github style calendar in terminal +zplug "k4rthik/git-cal", as:command + +# Simplistic interactive filtering tool +zplug "peco/peco", as:command, from:gh-r, use:"*${(L)$(uname -s)}*amd64*" + +# fzf is a general-purpose command-line fuzzy finder. +zplug "junegunn/fzf-bin", as:command, from:gh-r, rename-to:fzf, use:"*${(L)$(uname -s)}*amd64*" +if zplug check "junegunn/fzf-bin"; then + export FZF_DEFAULT_OPTS="--height 40% --reverse --border --inline-info --color=dark,bg+:235,hl+:10,pointer:5" +fi +zplug "junegunn/fzf", use:"shell/*.zsh" +# C^x C^x to launch fzf? +zplug "b4b4r07/easy-oneliner", if:"which fzf", on:"junegunn/fzf-bin" + + +# Enhanced cd +zplug "b4b4r07/enhancd", use:init.sh +if zplug check "b4b4r07/enhancd"; then + ENHANCD_FILTER="fzf:peco:percol" + # type 'c' and get a list of likely dirs you want to go to + ENHANCD_COMMAND="c" +fi + +# Bookmarks and jump +zplug "jocelynmallon/zshmarks" + +# Enhanced dir list with git features +zplug "supercrabtree/k" + +# Jump back to parent directory +zplug "tarrasch/zsh-bd" + +# Simple zsh calculator +zplug "arzzen/calc.plugin.zsh" + +# Directory colors +zplug "seebi/dircolors-solarized", ignore:"*", as:plugin +zplug "pinelibg/dircolors-solarized-zsh" + +zplug "plugins/common-aliase", from:oh-my-zsh +zplug "plugins/command-not-found", from:oh-my-zsh +zplug "plugins/copydir", from:oh-my-zsh +zplug "plugins/copyfile", from:oh-my-zsh +zplug "plugins/cp", from:oh-my-zsh +zplug "plugins/dircycle", from:oh-my-zsh +zplug "plugins/encode64", from:oh-my-zsh +zplug "plugins/extract", from:oh-my-zsh +zplug "plugins/history", from:oh-my-zsh +zplug "plugins/tmux", from:oh-my-zsh +zplug "plugins/tmuxinator", from:oh-my-zsh +zplug "plugins/urltools", from:oh-my-zsh +zplug "plugins/web-search", from:oh-my-zsh +zplug "plugins/z", from:oh-my-zsh +zplug "plugins/fancy-ctrl-z", from:oh-my-zsh + +# Supports oh-my-zsh plugins and the like +if [[ $OSTYPE = (linux)* ]]; then + zplug "plugins/archlinux", from:oh-my-zsh, if:"(( $+commands[pacman] ))" + zplug "plugins/dnf", from:oh-my-zsh, if:"(( $+commands[dnf] ))" + zplug "plugins/mock", from:oh-my-zsh, if:"(( $+commands[mock] ))" +fi + +zplug "plugins/git", from:oh-my-zsh, if:"(( $+commands[git] ))" +zplug "plugins/golang", from:oh-my-zsh, if:"(( $+commands[go] ))" +zplug "plugins/svn", from:oh-my-zsh, if:"(( $+commands[svn] ))" +zplug "plugins/node", from:oh-my-zsh, if:"(( $+commands[node] ))" +zplug "plugins/npm", from:oh-my-zsh, if:"(( $+commands[npm] ))" +zplug "plugins/bundler", from:oh-my-zsh, if:"(( $+commands[bundler] ))" +zplug "plugins/gem", from:oh-my-zsh, if:"(( $+commands[gem] ))" +zplug "plugins/rvm", from:oh-my-zsh, if:"(( $+commands[rvm] ))" +zplug "plugins/pip", from:oh-my-zsh, if:"(( $+commands[pip] ))" +zplug "plugins/sudo", from:oh-my-zsh, if:"(( $+commands[sudo] ))" +zplug "plugins/gpg-agent", from:oh-my-zsh, if:"(( $+commands[gpg-agent] ))" +zplug "plugins/systemd", from:oh-my-zsh, if:"(( $+commands[systemctl] ))" +zplug "plugins/docker", from:oh-my-zsh, if:"(( $+commands[docker] ))" +zplug "plugins/docker-compose", from:oh-my-zsh, if:"(( $+commands[docker-compose] ))" +zplug "plugins/terraform", from:oh-my-zsh, if:"(( $+commands[terraform] ))" +zplug "plugins/vagrant", from:oh-my-zsh, if:"(( $+commands[vagrant] ))" + +zplug "djui/alias-tips" +zplug "hlissner/zsh-autopair", defer:2 + +# Additional completion definitions for Zsh. +zplug "zsh-users/zsh-completions" + +# Suggests commands as you type based on history and completions. +zplug "zsh-users/zsh-autosuggestions" +if zplug check "zsh-users/zsh-autosuggestions"; then + #ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10' + ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=075' #color could be adjusted to theme + #ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=162' +fi + +# zsh-syntax-highlighting must be loaded after executing compinit command and sourcing other plugins +zplug "zsh-users/zsh-syntax-highlighting", defer:2 +if zplug check "zsh-users/zsh-syntax-highlighting"; then + typeset -gA ZSH_HIGHLIGHT_STYLES ZSH_HIGHLIGHT_PATTERNS + + ZSH_HIGHLIGHT_STYLES[default]='none' + ZSH_HIGHLIGHT_STYLES[cursor]='fg=yellow' + ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red' + ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=yellow' + ZSH_HIGHLIGHT_STYLES[alias]='fg=cyan' + ZSH_HIGHLIGHT_STYLES[builtin]='fg=cyan' + ZSH_HIGHLIGHT_STYLES[function]='fg=cyan' + ZSH_HIGHLIGHT_STYLES[command]='fg=cyan' + ZSH_HIGHLIGHT_STYLES[precommand]='fg=green' + ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=yellow' + ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=green' + ZSH_HIGHLIGHT_STYLES[path]='fg=white,underline' + ZSH_HIGHLIGHT_STYLES[path_pathseparator]='fg=grey,underline' + ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=white' + ZSH_HIGHLIGHT_STYLES[path_approx]='fg=white' + ZSH_HIGHLIGHT_STYLES[globbing]='none' + ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=green' + ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=blue' + ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=blue' + ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='none' + ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=magenta' + ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=magenta' + ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=cyan' + ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=cyan' + ZSH_HIGHLIGHT_STYLES[redirection]='fg=magenta' + ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=cyan,bold' + ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=green,bold' + ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=magenta,bold' + ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=yellow,bold' + ZSH_HIGHLIGHT_STYLES[assign]='none' + + ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red') + + ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor line) +fi + +# search in zsh history +zplug "zsh-users/zsh-history-substring-search", defer:3 +if zplug check "zsh-users/zsh-history-substring-search"; then + zmodload zsh/terminfo + bindkey "$terminfo[kcuu1]" history-substring-search-up + bindkey "$terminfo[kcud1]" history-substring-search-down + bindkey "^[[1;5A" history-substring-search-up + bindkey "^[[1;5B" history-substring-search-down +fi + +# Finalise the zplug section, install and load +# Install plugins if there are plugins that have not been installed +if ! zplug check; then + printf "Install plugins? [y/N]: " + if read -q; then + echo; zplug install + fi +fi + +# zplug load is called in the last stage (see other ./custom files) + +# Completions +# the internal list (hash) of commands will be updated for each search by issuing the rehash command +zstyle ':completion:*' rehash true +# http://zsh.sourceforge.net/Doc/Release/Completion-System.html +zstyle ':completion:' completer _complete _match _approximate +zstyle ':completion:' group-name '' +#zstyle ':completion:' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:' matcher-list 'm:{a-z}={A-Z}' +zstyle ':completion:' use-cache true +zstyle ':completion:' verbose yes +zstyle ':completion::default' menu select=2 +zstyle ':completion::descriptions' format '%F{yellow}-- %d --%f' +zstyle ':completion:*:options' description 'yes' +# case-insensitive (uppercase from lowercase) completion +#zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' +# process completion +#zstyle ':completion:*:processes' command 'ps -au$USER' +#zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=36=31" +zstyle ':completion:*' completer _expand _complete _ignored _approximate +#zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*' menu select=2 +zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' +zstyle ':completion:*:descriptions' format '%U%F{yellow}%d%f%u' +#zstyle ':completion:*:*:git:*' script ~/.git-completion.sh +zstyle ':completion:*' verbose yes +zstyle ':completion:*:descriptions' format '%B%d%b' +zstyle ':completion:*:messages' format '%d' +zstyle ':completion:*:warnings' format 'No matches for: %d' +zstyle ':completion:*' group-name '' +# case-insensitive (all), partial-word and then substring completion +zstyle ":completion:*" matcher-list \ + "m:{a-zA-Z}={A-Za-z}" \ + "r:|[._-]=* r:|=*" \ + "l:|=* r:|=*" +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" +zstyle ':completion:*:default' list-colors "${(s.:.)LS_COLORS}" diff --git a/dot_dotfiles/oh-my-zsh/custom/08_shell_settings.zsh b/dot_dotfiles/oh-my-zsh/custom/08_shell_settings.zsh new file mode 100644 index 0000000..77ee174 --- /dev/null +++ b/dot_dotfiles/oh-my-zsh/custom/08_shell_settings.zsh @@ -0,0 +1,2 @@ +# this enables vi bindings in zsh +bindkey -v diff --git a/dot_dotfiles/oh-my-zsh/custom/09_alias.zsh b/dot_dotfiles/oh-my-zsh/custom/09_alias.zsh new file mode 100644 index 0000000..6013156 --- /dev/null +++ b/dot_dotfiles/oh-my-zsh/custom/09_alias.zsh @@ -0,0 +1,15 @@ +alias rm="rm -v" +alias vi="vim" +alias cp="cp -v" +alias mv="mv -v" +alias ls="ls $LS_OPTIONS -hFtr" +alias ll="ls $LS_OPTIONS -lAhFtr" +alias ccat="pygmentize -O style=monokai -f 256 -g" +alias dig="dig +nocmd any +multiline +noall +answer" +alias prettyjson='python -m json.tool' +# aliases to quickly switch between two keyboard layouts +alias aoeu="setxkbmap us" +alias asdf="setxkbmap dvorak" + +disable -r time # disable shell reserved word +alias time='time -p ' # -p for POSIX output diff --git a/dot_dotfiles/oh-my-zsh/custom/09_settings.zsh b/dot_dotfiles/oh-my-zsh/custom/09_settings.zsh new file mode 100644 index 0000000..12eec91 --- /dev/null +++ b/dot_dotfiles/oh-my-zsh/custom/09_settings.zsh @@ -0,0 +1,105 @@ +# OPTIONS +setopt autocd # Allow changing directories without `cd` +setopt append_history # Dont overwrite history +setopt auto_list +setopt auto_menu +setopt auto_pushd +setopt extended_history # Also record time and duration of commands. +setopt hist_expire_dups_first # Clear duplicates when trimming internal hist. +setopt hist_find_no_dups # Dont display duplicates during searches. +setopt hist_ignore_dups # Ignore consecutive duplicates. +setopt hist_ignore_all_dups # Remember only one unique copy of the command. +setopt hist_reduce_blanks # Remove superfluous blanks. +setopt hist_save_no_dups # Omit older commands in favor of newer ones. +setopt hist_ignore_space # Ignore commands that start with space. +#setopt hist_ignore_all_dups +#setopt hist_ignore_dups +#setopt hist_reduce_blanks +#setopt hist_save_no_dups +#setopt ignore_eof +setopt inc_append_history +setopt interactive_comments +setopt no_beep +setopt no_hist_beep +setopt no_list_beep +setopt magic_equal_subst +setopt notify +setopt print_eight_bit +setopt print_exit_value +setopt prompt_subst +setopt pushd_ignore_dups +#setopt rm_star_wait +setopt share_history # Share history between multiple shells +setopt transient_rprompt + +# Watching other users +#WATCHFMT="%n %a %l from %m at %t." +watch=(notme) # Report login/logout events for everybody except ourself. +LOGCHECK=60 # Time (seconds) between checks for login/logout activity. +REPORTTIME=5 # Display usage statistics for commands running > 5 sec. + +# Key timeout and character sequences +KEYTIMEOUT=1 +WORDCHARS='*?_-[]~=./&;!#$%^(){}<>' + +zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 } + +# BINDINGS +# -v enables vim bindings +bindkey -v +bindkey -v '^?' backward-delete-char +bindkey '^[[Z' reverse-menu-complete + +# Common CTRL bindings. +bindkey "^a" beginning-of-line +bindkey "^e" end-of-line +bindkey "^f" forward-word +bindkey "^b" backward-word +bindkey "^k" kill-line +bindkey "^d" delete-char +bindkey "^y" accept-and-hold +bindkey "^w" backward-kill-word +bindkey "^u" backward-kill-line +bindkey "^R" history-incremental-pattern-search-backward +bindkey "^F" history-incremental-pattern-search-forward + +# Do not require a space when attempting to tab-complete. +bindkey "^i" expand-or-complete-prefix + +# Fixes for alt-backspace and arrows keys +bindkey '^[^?' backward-kill-word +bindkey "^[[1;5C" forward-word +bindkey "^[[1;5D" backward-word +#bindkey "^[[C" forward-word +#bindkey "^[[D" backward-word + +## Emulate tcsh's backward-delete-word +#tcsh-backward-kill-word () { +# local WORDCHARS="${WORDCHARS:s#/#}" +# zle backward-kill-word +#} +#zle -N tcsh-backward-kill-word + +# https://github.com/sickill/dotfiles/blob/master/.zsh.d/key-bindings.zsh +tcsh-backward-word () { + local WORDCHARS="${WORDCHARS:s#./#}" + zle emacs-backward-word +} +zle -N tcsh-backward-word +bindkey '\e[1;3D' tcsh-backward-word +bindkey '\e^[[D' tcsh-backward-word # tmux + +tcsh-forward-word () { + local WORDCHARS="${WORDCHARS:s#./#}" + zle emacs-forward-word +} +zle -N tcsh-forward-word +bindkey '\e[1;3C' tcsh-forward-word +bindkey '\e^[[C' tcsh-backward-word # tmux + +tcsh-backward-delete-word () { + local WORDCHARS="${WORDCHARS:s#./#}" + zle backward-delete-word +} +zle -N tcsh-backward-delete-word +bindkey "^[^?" tcsh-backward-delete-word # urxvt diff --git a/dot_dotfiles/oh-my-zsh/custom/10_finalise.zsh b/dot_dotfiles/oh-my-zsh/custom/10_finalise.zsh new file mode 100644 index 0000000..50be801 --- /dev/null +++ b/dot_dotfiles/oh-my-zsh/custom/10_finalise.zsh @@ -0,0 +1,6 @@ +# Load the zplug plugins +zplug load + +# Set up SDKMAN +export SDKMAN_DIR="/home/jnieland/.sdkman" +[[ -s "/home/jnieland/.sdkman/bin/sdkman-init.sh" ]] && source "/home/jnieland/.sdkman/bin/sdkman-init.sh" diff --git a/dot_dotfiles/oh-my-zsh/custom/themes/symlink_powerlevel10k.zsh-theme b/dot_dotfiles/oh-my-zsh/custom/themes/symlink_powerlevel10k.zsh-theme new file mode 100644 index 0000000..f50384c --- /dev/null +++ b/dot_dotfiles/oh-my-zsh/custom/themes/symlink_powerlevel10k.zsh-theme @@ -0,0 +1 @@ +/usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme \ No newline at end of file