From a029d2f348c28f833a84a0f1b35d7956a2ac54f3 Mon Sep 17 00:00:00 2001 From: Robert Morrison Date: Mon, 5 Dec 2022 21:03:45 +0000 Subject: [PATCH] Mega Commit This commit is a sin. But necessary --- .gitignore | 1 + ZshPlug | 2 +- aliases | 6 +++++ chpwd | 6 +++++ completion | 67 +++++++++++++++++++++++++++++++++++++++++++++++ dir_aliases | 1 + functions/_dotnet | 15 +++++++++++ greet | 2 +- history | 26 ++++++++++++++++++ keyboard | 2 +- prompt | 13 ++++----- zshrc | 43 +++++++++++------------------- 12 files changed, 147 insertions(+), 37 deletions(-) create mode 100644 chpwd create mode 100644 completion create mode 100644 functions/_dotnet create mode 100644 history diff --git a/.gitignore b/.gitignore index aa2855a..2e6104c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .zkbd/ .zcompdump +.zcalc_history diff --git a/ZshPlug b/ZshPlug index 89c2d21..a60119f 160000 --- a/ZshPlug +++ b/ZshPlug @@ -1 +1 @@ -Subproject commit 89c2d21b8d75048d29ea1528d33d3ee1ddbd86a1 +Subproject commit a60119faff4083cf633930fd2afb20c3f5d9b894 diff --git a/aliases b/aliases index 6912de8..246c31e 100755 --- a/aliases +++ b/aliases @@ -64,6 +64,12 @@ alias ip='ip --color=auto' ## Open Vimwiki alias vw='nvim -c VimwikiIndex' +## Change Wineprefix quick and EZ +alias ws='source wineselect' + +## zero a terminal session +alias zero='dirs -c && clear' + ######################### # FileType Associations # # extension=program # diff --git a/chpwd b/chpwd new file mode 100644 index 0000000..e27203b --- /dev/null +++ b/chpwd @@ -0,0 +1,6 @@ +HAS_GLOW="$(command -v glow)" + +chpwd() { + [ -z $HAS_GLOW ] && return 0 + find $PWD -maxdepth 1 -iname 'readme.md' -exec glow {} \; +} diff --git a/completion b/completion new file mode 100644 index 0000000..94f506f --- /dev/null +++ b/completion @@ -0,0 +1,67 @@ + +echo $fpath +############ +# Completion Config +############ + +## Disable beeping on completions. +setopt NO_BEEP + +## Automatically list ambiguous completions. +setopt AUTO_LIST + +## Automatically use menu completion after the second request for completion. +setopt AUTO_MENU + +## Always fully insert completions. +setopt MENU_COMPLETE + +## Automatically put subscripts directly after parameter expressions. +setopt AUTO_PARAM_KEYS + +## Allow completion within words (i.e. always complete at the cursor position). +setopt COMPLETE_IN_WORD + +## Always move the cursor to the end of a completion after inserting it. +setopt ALWAYS_TO_END + +## Automatically list compleptions when given an unambigous prefix. +setopt LIST_AMBIGUOUS + +## Display markers to indicate what type of file a completion item is. +setopt LIST_TYPES + +## Print an error when provided patterns that are badly formed. +setopt BAD_PATTERN + + +zstyle ':completion:*' verbose yes + +zstyle ':completion:*' group-name '' ## Simply makes the group-name appear with the group + +zstyle ':completion:*' menu select ## use menu to select where possible + +zstyle ':completion:*' completer _complete _match _approximate ## fuzzy match + +zstyle ':completion:*' squeeze-slashes true ## remove trailing slashes + +zstyle ':completion:*:descriptions' format '%B%F{green}┨%d┣%f%b' ## better descriptions format + +zstyle ':completion:*:warnings' format '%BSorry, no matches for: %F{yellow}%d%b%f' ## show when no matches + +zstyle ':completion:*:corrections' format '%B%F{yellow}┨%d┤├ errors %e┣%f%b' + +zstyle ':completion:*:match:*' original only + +zstyle -e ':completion:*:approximate:*' \ + max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' ## more errors in longer lines + +zstyle ':completion:*:functions' ignored-patterns '_*' ## ignore completions for commands I dont have + +zstyle ':completion:*:cd:*' ignore-parents parent pwd ## don't complete parent dir + +autoload -Uz +X compinit +zmodload zsh/complist +compinit + +# vim: ft=zsh diff --git a/dir_aliases b/dir_aliases index f8cf9c9..f5f8aed 100755 --- a/dir_aliases +++ b/dir_aliases @@ -7,3 +7,4 @@ hash -d dl="$HOME/Downloads" hash -d cn="${XDG_CONFIG_HOME:-$HOME/.config}" hash -d px="$HOME/Pictures" hash -d pr="$HOME/Projects" +# vim: ft=zsh diff --git a/functions/_dotnet b/functions/_dotnet new file mode 100644 index 0000000..d81ff87 --- /dev/null +++ b/functions/_dotnet @@ -0,0 +1,15 @@ +#compdef dotnet +_dotnet() +{ + local completions=("$(dotnet complete "$words")") + + # If the completion list is empty, just continue with filename selection + if [ -z "$completions" ] + then + _arguments '*::arguments: _normal' + return + fi + + # This is not a variable assigment, don't remove spaces! + _values = "${(ps:\n:)completions}" +} diff --git a/greet b/greet index 57680f6..2fc546d 100755 --- a/greet +++ b/greet @@ -7,7 +7,7 @@ echo '╰───────────╯' date if [ -d "$HOME/tmp" ]; then if [ -f "$HOME/tmp/KEEPTMP" ] || [ -f "$HOME/.cleanupResult" ]; then - printf "\033[31m\e[1m\e[5mYou have files in your tmp directory\e[0m" + printf "\033[31m\e[1m\e[5mYou have files in your tmp directory\e[0m\n" exa -alhT ~/tmp || tree ~/tmp if [ -f "$HOME/.cleanupResult" ]; then echo "ISSUE WAS:" diff --git a/history b/history new file mode 100644 index 0000000..39286e9 --- /dev/null +++ b/history @@ -0,0 +1,26 @@ +## History Configuration + +## Options relating to saving history +export HISTSIZE=10000 +export SAVEHIST=6000 +export HISTFILE=$XDG_STATE_HOME/zsh/history + +set hist_ignore_dups ## Don't log the same thing twice +set hist_ignore_space ## Don't log things that start with space +set hist_reduce_blanks ## Compact unnecessary white-space +set hist_expire_dups_first ## Remove duplicates first (if any exist) when compacting history +set hist_save_no_dups ## Remove duplicates from history when writing + +## Options relating to history use +set hist_find_no_dups ## Don't show duplicates when searching history +set hist_verify ## Dont' immediately execute expanded history `eg: sudo !!` + +## This stops certain commands saving into the history file +export HISTORY_IGNORE='(cd(| *)|ls(| *)|pushd(| *)|popd(| *))' + +## This hook goes even further and stops anything in the $HISTORY_IGNORE list from being +## added to the session local history (it still stays around in the up buffer until you run a new command afterwards) +zshaddhistory() { + emulate -L zsh + [[ ${1%%$'\n'} != ${~HISTORY_IGNORE} ]] +} diff --git a/keyboard b/keyboard index 152f8e2..bdde2f1 100755 --- a/keyboard +++ b/keyboard @@ -25,4 +25,4 @@ zle -N history-beginning-search-forward-end \ [[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-search [[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char [[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char -# vim: set ft=zsh ts=8 sw=4 tw=0 noet : +## vim: ft=zsh diff --git a/prompt b/prompt index 2cb4bcd..e910a2f 100755 --- a/prompt +++ b/prompt @@ -11,15 +11,16 @@ autoload -Uz vcs_info zstyle ':vcs_info:*' enable git ## Set icons for Staged and Unstaged Changes -zstyle ':vcs_info:git*' stagedstr "✅" -zstyle ':vcs_info:git*' unstagedstr "⛔" +zstyle ':vcs_info:git*' stagedstr "%{%F{green%}%} %{%f%}" +zstyle ':vcs_info:git*' unstagedstr "%{%F{red%}%} %{%f%}" ## Enable check for changes (CPU-intensive) ## DISABLE THIS ON LOW POWER SYSTEMS zstyle ':vcs_info:git*' check-for-changes true ## Set format for Repo Information -zstyle ':vcs_info:git*' formats "-(%s:שׂ %b %u%c)" +zstyle ':vcs_info:git*' formats "-(%{%F{203}%} %{%f%}%s:%{%F{2}%}שׂ %{%f%}%b %u%c)" +zstyle ':vcs_info:git*' actionformats "-(%{%F{203}%} %{%f%}%s:%{%F{2}%}שׂ %{%f%}%b %u%c)(%a)" ## set precmd to get vcs_info ## precmd runs before every prompt @@ -27,7 +28,7 @@ precmd() { vcs_info } -PROMPT="$(setTermTitle "(%n@%m %~)")╭╼(%{%F{81}%}%n%{%F{245}%}@%{%F{206}%}%m %{%F{245}%}%~%{%F{259}%})─(%(?.😎.😞 %?))"$'\n'"╰┤" -RPROMPT='${vcs_info_msg_0_}' +PROMPT="$(setTermTitle "(%n@%m %2~)")╭╼(%{%F{81}%}%n%{%F{245}%}@%{%F{206}%}%m %{%F{245}%}%2~%{%F{259}%})─(%(?.😎.😞 %?))"$'\n'"╰┤" +export RPROMPT='${vcs_info_msg_0_}' -# vim: set ft=zsh ts=2 sw=2 tw=0 noet : +# vim: set ft=zsh: diff --git a/zshrc b/zshrc index 4f66d7d..9b2f2c3 100755 --- a/zshrc +++ b/zshrc @@ -10,54 +10,36 @@ unalias run-help ## autoload Modules autoload -U +X colors && colors autoload -U calendar -autoload -U run-help +autoload -U run-help autoload -U +X compinit autoload -U edit-command-line ## zmodload Modules zmodload zsh/complist -## Loca my function +## Load my functions fpath=( $ZDOTDIR/functions $fpath ) autoload CleanTmp autoload setTermTitle autoload tempPersist ## Source Other files -source $HOME/.profile source ${ZDOTDIR}/aliases source ${ZDOTDIR}/dir_aliases source ${ZDOTDIR}/prompt source ${ZDOTDIR}/keyboard +source ${ZDOTDIR}/history +source ${ZDOTDIR}/chpwd ## Set option -setopt emacs ## Emacs style keybinds +#setopt emacs ## Emacs style keybinds +setopt vi setopt autocd ## Change to directory if given as command setopt autopushd ## Automatically use pushd and stack setopt correct ## Pick up on Spelling errors -setopt SHARE_HISTORY ## Share history across sessions -setopt hist_verify ## Edit Commands after expansion -## Configure History File -export HISTSIZE=10000 -export SAVEHIST=$HISTSIZE -export HISTFILE=$HOME/.zhistory - -## Configure Completions -zstyle ':completion:*' menu select ## use menu to select where possible -zstyle ':completion:*:descriptions' format '%U%B%d%b%u' ## better descriptions format -zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' ## show when no matches -zstyle ':completion:*' completer _complete _match _approximate ## fuzzy match -zstyle ':completion:*:match:*' original only -zstyle -e ':completion:*:approximate:*' \ - max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' ## more errors in longer lines -zstyle ':completion:*:functions' ignored-patterns '_*' ## ignore completions for commands I dont have -zstyle ':completion:*' squeeze-slashes true ## remove trailing slashes -zstyle ':completion:*:cd:*' ignore-parents parent pwd ## don't complete parent dir - -compinit -_comp_options+=(globdots) +source ${ZDOTDIR}/completion ## Configure command line editor zle -N edit-command-line @@ -71,17 +53,22 @@ export GPG_TTY=$(tty) ## Load external stuff -## support for opam -test -r $HOME/.opam/opam-init/init.zsh && . $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || +##Configure for homebrew +eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" ## Configure Plugins export ZSH_AUTOSUGGEST_STRATEGY=(completion history) # suggest from completion then history export ZSH_AUTOSUGGEST_USE_ASYNC=1 # make async for SPEED export ZSH_AUTOSUGGEST_HISTORY_IGNORE='(cd|cp|tar|mv|ls|nvim|rm|rmdir|git) *' + ## Load Plugins with ZshPlug -export ZSH_PLUG_plugins=( "zsh-users/zsh-autosuggestions" "zdharma-continuum/fast-syntax-highlighting" "MichaelAquilina/zsh-you-should-use" ) +export ZSH_PLUG_plugins=( "zsh-users/zsh-autosuggestions" \ + "zdharma-continuum/fast-syntax-highlighting" \ + "jeffreytse/zsh-vi-mode" \ + "MichaelAquilina/zsh-you-should-use"\ +) source $ZDOTDIR/ZshPlug/ZshPlug.zsh [[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line