From 932ac88be8474a174b373f3876536adb977a19de Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 26 Jul 2021 09:59:32 -0400 Subject: [PATCH 01/28] Add empty .zsh_local file by default --- .zsh_local | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .zsh_local diff --git a/.zsh_local b/.zsh_local new file mode 100644 index 0000000..e69de29 From b0b0f5f965d6594adbfca9d819e014c9bbfcc22f Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 26 Jul 2021 10:00:23 -0400 Subject: [PATCH 02/28] Replace tabs with spaces in .bashrc --- .bashrc | 102 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/.bashrc b/.bashrc index f06afed..ff8b11e 100644 --- a/.bashrc +++ b/.bashrc @@ -5,42 +5,42 @@ [[ $- != *i* ]] && return colors() { - local fgc bgc vals seq0 + local fgc bgc vals seq0 - printf "Color escapes are %s\n" '\e[${value};...;${value}m' - printf "Values 30..37 are \e[33mforeground colors\e[m\n" - printf "Values 40..47 are \e[43mbackground colors\e[m\n" - printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" + printf "Color escapes are %s\n" '\e[${value};...;${value}m' + printf "Values 30..37 are \e[33mforeground colors\e[m\n" + printf "Values 40..47 are \e[43mbackground colors\e[m\n" + printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" - # foreground colors - for fgc in {30..37}; do - # background colors - for bgc in {40..47}; do - fgc=${fgc#37} # white - bgc=${bgc#40} # black + # foreground colors + for fgc in {30..37}; do + # background colors + for bgc in {40..47}; do + fgc=${fgc#37} # white + bgc=${bgc#40} # black - vals="${fgc:+$fgc;}${bgc}" - vals=${vals%%;} + vals="${fgc:+$fgc;}${bgc}" + vals=${vals%%;} - seq0="${vals:+\e[${vals}m}" - printf " %-9s" "${seq0:-(default)}" - printf " ${seq0}TEXT\e[m" - printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" - done - echo; echo - done + seq0="${vals:+\e[${vals}m}" + printf " %-9s" "${seq0:-(default)}" + printf " ${seq0}TEXT\e[m" + printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" + done + echo; echo + done } [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion # Change the window title of X terminals case ${TERM} in - xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*) - PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"' - ;; - screen*) - PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"' - ;; + xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*) + PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"' + ;; + screen*) + PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"' + ;; esac use_color=true @@ -55,37 +55,37 @@ match_lhs="" [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(/dev/null \ - && match_lhs=$(dircolors --print-database) + && type -P dircolors >/dev/null \ + && match_lhs=$(dircolors --print-database) [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true if ${use_color} ; then - # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 - if type -P dircolors >/dev/null ; then - if [[ -f ~/.dir_colors ]] ; then - eval $(dircolors -b ~/.dir_colors) - elif [[ -f /etc/DIR_COLORS ]] ; then - eval $(dircolors -b /etc/DIR_COLORS) - fi - fi + # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 + if type -P dircolors >/dev/null ; then + if [[ -f ~/.dir_colors ]] ; then + eval $(dircolors -b ~/.dir_colors) + elif [[ -f /etc/DIR_COLORS ]] ; then + eval $(dircolors -b /etc/DIR_COLORS) + fi + fi - if [[ ${EUID} == 0 ]] ; then - PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] ' - else - PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] ' - fi + if [[ ${EUID} == 0 ]] ; then + PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] ' + else + PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] ' + fi - alias ls='ls --color=auto' - alias grep='grep --colour=auto' - alias egrep='egrep --colour=auto' - alias fgrep='fgrep --colour=auto' + alias ls='ls --color=auto' + alias grep='grep --colour=auto' + alias egrep='egrep --colour=auto' + alias fgrep='fgrep --colour=auto' else - if [[ ${EUID} == 0 ]] ; then - # show root@ when we don't have colors - PS1='\u@\h \W \$ ' - else - PS1='\u@\h \w \$ ' - fi + if [[ ${EUID} == 0 ]] ; then + # show root@ when we don't have colors + PS1='\u@\h \W \$ ' + else + PS1='\u@\h \w \$ ' + fi fi unset use_color safe_term match_lhs sh From 48819efb2e4b3cd7c321a3ef666f8ae483f5fa5d Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 26 Jul 2021 10:00:37 -0400 Subject: [PATCH 03/28] Add ~/.bin to PATH in .zshrc --- .zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index f265785..7a85d96 100644 --- a/.zshrc +++ b/.zshrc @@ -48,7 +48,7 @@ if [ -x /usr/bin/dircolors ]; then alias egrep='egrep --color=auto' fi -export PATH=./:$PATH +export PATH=./:~/.bin:$PATH fignore=(o) From 547e49d2a30cb6a2df77945d46de1c043a5e33bc Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 09:40:58 -0400 Subject: [PATCH 04/28] More consistent copying behavior --- copy.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/copy.sh b/copy.sh index 2276884..1ca869d 100755 --- a/copy.sh +++ b/copy.sh @@ -1,3 +1,6 @@ #!/bin/bash -ln -sf ~/.dotfiles/.* ~/ -yes | rm -r ~/.git +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +for f in $(find $SCRIPT_DIR -mindepth 1 -name ".*" -not -name ".git"); do + ln -sf $f ~/ +done From a4229111e766987ef05fd9ffc70ef19ece606d3a Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 09:41:15 -0400 Subject: [PATCH 05/28] Add tmux configuration. --- .tmux.conf | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .tmux.conf diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..fe1e46a --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,36 @@ +# set -g default-terminal "screen-255color" + +# remap prefix from 'C-b' to 'C-a' +unbind C-b +set-option -g prefix C-a +bind-key C-a send-prefix +set -g default-shell /usr/bin/zsh +set-option -g default-terminal "screen-256color" +set -g status-right "# %A, %d %b %Y - %I:%M %p " + +set -g status-bg blue +set -g status-fg black + +# Smart pane switching with awareness of Vim splits. +# See: https://github.com/christoomey/vim-tmux-navigator +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' +bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' +bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' +bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' +tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' +if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" +if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" + +bind-key -T copy-mode-vi 'C-h' select-pane -L +bind-key -T copy-mode-vi 'C-j' select-pane -D +bind-key -T copy-mode-vi 'C-k' select-pane -U +bind-key -T copy-mode-vi 'C-l' select-pane -R +bind-key -T copy-mode-vi 'C-\' select-pane -l + +setw -g window-status-current-style fg=blue,bg=black +setw -g window-status-current-format ' #I #{s|/home/sagevaillancourt|~|:pane_current_path} #W#F ' +setw -g window-status-format ' #I #{s|/home/sagevaillancourt|~|:pane_current_path} #W#F ' From 20afc8550575db75412c74adffddc3fee7d1459f Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 09:44:55 -0400 Subject: [PATCH 06/28] Add shell_aliases to bashrc --- .bashrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bashrc b/.bashrc index ff8b11e..4ac8e0f 100644 --- a/.bashrc +++ b/.bashrc @@ -137,3 +137,5 @@ ex () echo "'$1' is not a valid file" fi } + +source ~/.shell_aliases From 85b7162872f3c4fc5906ae3c2661ecbc9a6340e8 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 12:47:19 -0400 Subject: [PATCH 07/28] Add jellybeans colorscheme. Better copying. --- .vim/colors/jellybeans.vim | 763 +++++++++++++++++++++++++++++++++++++ copy.sh | 28 +- 2 files changed, 790 insertions(+), 1 deletion(-) create mode 100644 .vim/colors/jellybeans.vim diff --git a/.vim/colors/jellybeans.vim b/.vim/colors/jellybeans.vim new file mode 100644 index 0000000..51fd0a8 --- /dev/null +++ b/.vim/colors/jellybeans.vim @@ -0,0 +1,763 @@ +" Vim color file +" +" " __ _ _ _ " +" " \ \ ___| | |_ _| |__ ___ __ _ _ __ ___ " +" " \ \/ _ \ | | | | | _ \ / _ \/ _ | _ \/ __| " +" " /\_/ / __/ | | |_| | |_| | __/ |_| | | | \__ \ " +" " \___/ \___|_|_|\__ |____/ \___|\____|_| |_|___/ " +" " \___/ " +" +" "A colorful, dark color scheme for Vim." +" +" File: jellybeans.vim +" URL: github.com/nanotech/jellybeans.vim +" Scripts URL: vim.org/scripts/script.php?script_id=2555 +" Maintainer: NanoTech (nanotech.nanotechcorp.net) +" Version: 1.7 +" Last Change: June 21st, 2019 +" License: MIT +" Contributors: Andrew Wong (w0ng) +" Benjamin R. Haskell (benizi) +" Brian Marshall (bmars) +" Daniel Herbert (pocketninja) +" David Liang +" Filipe Silva (ninrod) +" Henry So, Jr. +" Ihor Kalnytskyi (ikalnytskyi) +" Joe Doherty (docapotamus) +" Karl Litterfeldt (Litterfeldt) +" Keith Pitt (keithpitt) +" Mike Schreifels (schreifels) +" Philipp Rustemeier (12foo) +" Rafael Bicalho (rbika) +" Rich Healey (richo) +" Siwen Yu (yusiwen) +" Tim Willis (willist) +" Tom McLaughlin (tmcoma) +" +" Copyright (c) 2009-2019 NanoTech +" +" Permission is hereby granted, free of charge, to any per‐ +" son obtaining a copy of this software and associated doc‐ +" umentation files (the “Software”), to deal in the Soft‐ +" ware without restriction, including without limitation +" the rights to use, copy, modify, merge, publish, distrib‐ +" ute, sublicense, and/or sell copies of the Software, and +" to permit persons to whom the Software is furnished to do +" so, subject to the following conditions: +" +" The above copyright notice and this permission notice +" shall be included in all copies or substantial portions +" of the Software. +" +" THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY +" KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +" THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICU‐ +" LAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CON‐ +" TRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON‐ +" NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +" THE SOFTWARE. + +set background=dark + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "jellybeans" + +if has("gui_running") || (has('termguicolors') && &termguicolors) + let s:true_color = 1 +else + let s:true_color = 0 +endif + +if s:true_color || &t_Co >= 88 + let s:low_color = 0 +else + let s:low_color = 1 +endif + +" Configuration Variables: +" - g:jellybeans_overrides (default = {}) +" - g:jellybeans_use_lowcolor_black (default = 0) +" - g:jellybeans_use_gui_italics (default = 1) +" - g:jellybeans_use_term_italics (default = 0) + +let s:background_color = "151515" + +if exists("g:jellybeans_overrides") + let s:overrides = g:jellybeans_overrides +else + let s:overrides = {} +endif + +" Backwards compatibility +if exists("g:jellybeans_background_color") + \ || exists("g:jellybeans_background_color_256") + \ || exists("g:jellybeans_use_term_background_color") + + let s:overrides = deepcopy(s:overrides) + + if !has_key(s:overrides, "background") + let s:overrides["background"] = {} + endif + + if exists("g:jellybeans_background_color") + let s:overrides["background"]["guibg"] = g:jellybeans_background_color + endif + + if exists("g:jellybeans_background_color_256") + let s:overrides["background"]["256ctermbg"] = g:jellybeans_background_color_256 + endif + + if exists("g:jellybeans_use_term_background_color") + \ && g:jellybeans_use_term_background_color + let s:overrides["background"]["ctermbg"] = "NONE" + let s:overrides["background"]["256ctermbg"] = "NONE" + endif +endif + +if exists("g:jellybeans_use_lowcolor_black") && g:jellybeans_use_lowcolor_black + let s:termBlack = "Black" +else + let s:termBlack = "Grey" +endif + +" When `termguicolors` is set, Vim[^1] ignores `hi Normal guibg=NONE` +" after Normal's `guibg` is already set to a color. See: +" +" - https://github.com/vim/vim/issues/981 +" - https://github.com/nanotech/jellybeans.vim/issues/64 +" +" To work around this, ensure we don't set the default background +" color before an override changes it to `NONE` by ensuring that the +" background color isn't set to a value different from its override. +" +" [^1]: Tested on 8.0.567. Does not apply to Neovim. +" +if has_key(s:overrides, "background") && has_key(s:overrides["background"], "guibg") + let s:background_color = s:overrides["background"]["guibg"] +endif + +" Color approximation functions by Henry So, Jr. and David Liang {{{ +" Added to jellybeans.vim by Daniel Herbert + +if &t_Co == 88 + + " returns an approximate grey index for the given grey level + fun! s:grey_number(x) + if a:x < 23 + return 0 + elseif a:x < 69 + return 1 + elseif a:x < 103 + return 2 + elseif a:x < 127 + return 3 + elseif a:x < 150 + return 4 + elseif a:x < 173 + return 5 + elseif a:x < 196 + return 6 + elseif a:x < 219 + return 7 + elseif a:x < 243 + return 8 + else + return 9 + endif + endfun + + " returns the actual grey level represented by the grey index + fun! s:grey_level(n) + if a:n == 0 + return 0 + elseif a:n == 1 + return 46 + elseif a:n == 2 + return 92 + elseif a:n == 3 + return 115 + elseif a:n == 4 + return 139 + elseif a:n == 5 + return 162 + elseif a:n == 6 + return 185 + elseif a:n == 7 + return 208 + elseif a:n == 8 + return 231 + else + return 255 + endif + endfun + + " returns the palette index for the given grey index + fun! s:grey_color(n) + if a:n == 0 + return 16 + elseif a:n == 9 + return 79 + else + return 79 + a:n + endif + endfun + + " returns an approximate color index for the given color level + fun! s:rgb_number(x) + if a:x < 69 + return 0 + elseif a:x < 172 + return 1 + elseif a:x < 230 + return 2 + else + return 3 + endif + endfun + + " returns the actual color level for the given color index + fun! s:rgb_level(n) + if a:n == 0 + return 0 + elseif a:n == 1 + return 139 + elseif a:n == 2 + return 205 + else + return 255 + endif + endfun + + " returns the palette index for the given R/G/B color indices + fun! s:rgb_color(x, y, z) + return 16 + (a:x * 16) + (a:y * 4) + a:z + endfun + +else " assuming &t_Co == 256 + + " returns an approximate grey index for the given grey level + fun! s:grey_number(x) + if a:x < 14 + return 0 + else + let l:n = (a:x - 8) / 10 + let l:m = (a:x - 8) % 10 + if l:m < 5 + return l:n + else + return l:n + 1 + endif + endif + endfun + + " returns the actual grey level represented by the grey index + fun! s:grey_level(n) + if a:n == 0 + return 0 + else + return 8 + (a:n * 10) + endif + endfun + + " returns the palette index for the given grey index + fun! s:grey_color(n) + if a:n == 0 + return 16 + elseif a:n == 25 + return 231 + else + return 231 + a:n + endif + endfun + + " returns an approximate color index for the given color level + fun! s:rgb_number(x) + if a:x < 75 + return 0 + else + let l:n = (a:x - 55) / 40 + let l:m = (a:x - 55) % 40 + if l:m < 20 + return l:n + else + return l:n + 1 + endif + endif + endfun + + " returns the actual color level for the given color index + fun! s:rgb_level(n) + if a:n == 0 + return 0 + else + return 55 + (a:n * 40) + endif + endfun + + " returns the palette index for the given R/G/B color indices + fun! s:rgb_color(x, y, z) + return 16 + (a:x * 36) + (a:y * 6) + a:z + endfun + +endif + +" returns the palette index to approximate the given R/G/B color levels +fun! s:color(r, g, b) + " map greys directly (see xterm's 256colres.pl) + if &t_Co == 256 && a:r == a:g && a:g == a:b && a:r > 3 && a:r < 243 + return (a:r - 8) / 10 + 232 + endif + + " get the closest grey + let l:gx = s:grey_number(a:r) + let l:gy = s:grey_number(a:g) + let l:gz = s:grey_number(a:b) + + " get the closest color + let l:x = s:rgb_number(a:r) + let l:y = s:rgb_number(a:g) + let l:z = s:rgb_number(a:b) + + if l:gx == l:gy && l:gy == l:gz + " there are two possibilities + let l:dgr = s:grey_level(l:gx) - a:r + let l:dgg = s:grey_level(l:gy) - a:g + let l:dgb = s:grey_level(l:gz) - a:b + let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) + let l:dr = s:rgb_level(l:gx) - a:r + let l:dg = s:rgb_level(l:gy) - a:g + let l:db = s:rgb_level(l:gz) - a:b + let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) + if l:dgrey < l:drgb + " use the grey + return s:grey_color(l:gx) + else + " use the color + return s:rgb_color(l:x, l:y, l:z) + endif + else + " only one possibility + return s:rgb_color(l:x, l:y, l:z) + endif +endfun + +fun! s:is_empty_or_none(str) + return empty(a:str) || a:str ==? "NONE" +endfun + +" returns the palette index to approximate the 'rrggbb' hex string +fun! s:rgb(rgb) + if s:is_empty_or_none(a:rgb) + return "NONE" + endif + let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 + let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 + let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 + return s:color(l:r, l:g, l:b) +endfun + +fun! s:prefix_highlight_value_with(prefix, color) + if s:is_empty_or_none(a:color) + return "NONE" + else + return a:prefix . a:color + endif +endfun + +fun! s:remove_italic_attr(attr) + let l:attr = join(filter(split(a:attr, ","), "v:val !=? 'italic'"), ",") + if empty(l:attr) + let l:attr = "NONE" + endif + return l:attr +endfun + +" sets the highlighting for the given group +fun! s:X(group, fg, bg, attr, lcfg, lcbg) + if s:low_color + let l:cmd = "hi ".a:group. + \ " ctermfg=".s:prefix_highlight_value_with("", a:lcfg). + \ " ctermbg=".s:prefix_highlight_value_with("", a:lcbg) + else + let l:cmd = "hi ".a:group. + \ " guifg=".s:prefix_highlight_value_with("#", a:fg). + \ " guibg=".s:prefix_highlight_value_with("#", a:bg) + if !s:true_color + let l:cmd = l:cmd. + \ " ctermfg=".s:rgb(a:fg). + \ " ctermbg=".s:rgb(a:bg) + endif + endif + + let l:attr = s:prefix_highlight_value_with("", a:attr) + + if exists("g:jellybeans_use_term_italics") && g:jellybeans_use_term_italics + let l:cterm_attr = l:attr + else + let l:cterm_attr = s:remove_italic_attr(l:attr) + endif + + if !exists("g:jellybeans_use_gui_italics") || g:jellybeans_use_gui_italics + let l:gui_attr = l:attr + else + let l:gui_attr = s:remove_italic_attr(l:attr) + endif + + let l:cmd = l:cmd." gui=".l:gui_attr." cterm=".l:cterm_attr + exec l:cmd +endfun +" }}} + +call s:X("Normal","e8e8d3",s:background_color,"","White","") +set background=dark + +call s:X("CursorLine","","1c1c1c","","",s:termBlack) +call s:X("CursorColumn","","1c1c1c","","",s:termBlack) + +" Some of Terminal.app's default themes have a cursor color +" too close to Jellybeans' preferred MatchParen background +" color to be easily distinguishable. Other terminals tend +" to use a brighter cursor color. +" +" Use a more distinct color in Terminal.app, and also in +" low-color terminals if the preferred background color is +" not available. +if !has('gui_running') && $TERM_PROGRAM == "Apple_Terminal" + let s:matchParenGuiFg = "dd0093" + let s:matchParenGuiBg = "000000" +else + let s:matchParenGuiFg = "ffffff" + let s:matchParenGuiBg = "556779" +endif +if s:termBlack != "Black" + let s:matchParenTermFg = "Magenta" + let s:matchParenTermBg = "" +else + let s:matchParenTermFg = "" + let s:matchParenTermBg = s:termBlack +endif +call s:X("MatchParen",s:matchParenGuiFg,s:matchParenGuiBg,"bold", +\ s:matchParenTermFg,s:matchParenTermBg) + +call s:X("TabLine","000000","b0b8c0","italic","",s:termBlack) +call s:X("TabLineFill","9098a0","","","",s:termBlack) +call s:X("TabLineSel","000000","f0f0f0","italic,bold",s:termBlack,"White") + +" Auto-completion +call s:X("Pmenu","ffffff","606060","","White",s:termBlack) +call s:X("PmenuSel","101010","eeeeee","",s:termBlack,"White") + +call s:X("Visual","","404040","","",s:termBlack) +call s:X("Cursor",s:background_color,"b0d0f0","","","") +call s:X("CocErrorFloat", s:background_color,"", "", "", "") + +call s:X("LineNr","605958",s:background_color,"NONE",s:termBlack,"") +call s:X("CursorLineNr","ccc5c4","","NONE","White","") +call s:X("Comment","888888","","italic","Grey","") +call s:X("Todo","c7c7c7","","bold","White",s:termBlack) + +call s:X("StatusLine","000000","dddddd","italic","","White") +call s:X("StatusLineNC","ffffff","403c41","italic","White","Black") +call s:X("VertSplit","777777","403c41","",s:termBlack,s:termBlack) +call s:X("WildMenu","f0a0c0","302028","","Magenta","") + +call s:X("Folded","a0a8b0","384048","italic",s:termBlack,"") +call s:X("FoldColumn","535D66","1f1f1f","","",s:termBlack) +call s:X("SignColumn","777777","333333","","",s:termBlack) +call s:X("ColorColumn","","000000","","",s:termBlack) + +call s:X("Title","70b950","","bold","Green","") + +call s:X("Constant","cf6a4c","","","Red","") +call s:X("Special","799d6a","","","Green","") +call s:X("Delimiter","668799","","","Grey","") + +call s:X("String","99ad6a","","","Green","") +call s:X("StringDelimiter","556633","","","DarkGreen","") + +call s:X("Identifier","c6b6ee","","","LightCyan","") +call s:X("Structure","8fbfdc","","","LightCyan","") +call s:X("Function","fad07a","","","Yellow","") +call s:X("Statement","8197bf","","","DarkBlue","") +call s:X("PreProc","8fbfdc","","","LightBlue","") + +hi! link Operator Structure +hi! link Conceal Operator + +call s:X("Type","ffb964","","","Yellow","") +call s:X("NonText","606060",s:background_color,"",s:termBlack,"") + +call s:X("SpecialKey","444444","1c1c1c","",s:termBlack,"") + +call s:X("Search","f0a0c0","302028","underline","Magenta","") + +call s:X("Directory","dad085","","","Yellow","") +call s:X("ErrorMsg","","902020","","","DarkRed") +hi! link Error ErrorMsg +hi! link MoreMsg Special +call s:X("Question","65C254","","","Green","") + +if exists('*term_setansicolors') + let g:terminal_ansi_colors = repeat([0], 16) + + let g:terminal_ansi_colors[0] = "#" . s:background_color + let g:terminal_ansi_colors[8] = "#e8e8d3" + + let g:terminal_ansi_colors[1] = "#cf6a4c" + let g:terminal_ansi_colors[9] = "#902020" + + let g:terminal_ansi_colors[2] = "#65C254" + let g:terminal_ansi_colors[10] = "#70b950" + + let g:terminal_ansi_colors[3] = "#ffb964" + let g:terminal_ansi_colors[11] = "#fad07a" + + let g:terminal_ansi_colors[4] = "#8197bf" + let g:terminal_ansi_colors[12] = "DarkBlue" + + let g:terminal_ansi_colors[5] = "#c6b6ee" + " Guessed + let g:terminal_ansi_colors[13] = "#a78fe4" + + let g:terminal_ansi_colors[6] = "#8fbfdc" + " Guessed + let g:terminal_ansi_colors[14] = "#89cfec" + + let g:terminal_ansi_colors[7] = "#ffffff" + let g:terminal_ansi_colors[15] = "#ff0000" +endif + +" Spell Checking + +call s:X("SpellBad","","902020","underline","","DarkRed") +call s:X("SpellCap","","0000df","underline","","Blue") +call s:X("SpellRare","","540063","underline","","DarkMagenta") +call s:X("SpellLocal","","2D7067","underline","","Green") + +" Diff + +hi! link diffRemoved Constant +hi! link diffAdded String + +" VimDiff + +call s:X("DiffAdd","D2EBBE","437019","","White","DarkGreen") +call s:X("DiffDelete","40000A","700009","","DarkRed","DarkRed") +call s:X("DiffChange","","2B5B77","","White","DarkBlue") +call s:X("DiffText","8fbfdc","000000","reverse","Yellow","") + +" PHP + +hi! link phpFunctions Function +call s:X("StorageClass","c59f6f","","","Red","") +hi! link phpSuperglobal Identifier +hi! link phpQuoteSingle StringDelimiter +hi! link phpQuoteDouble StringDelimiter +hi! link phpBoolean Constant +hi! link phpNull Constant +hi! link phpArrayPair Operator +hi! link phpOperator Normal +hi! link phpRelation Normal +hi! link phpVarSelector Identifier + +" Python + +hi! link pythonOperator Statement + +" Ruby + +hi! link rubySharpBang Comment +call s:X("rubyClass","447799","","","DarkBlue","") +call s:X("rubyIdentifier","c6b6fe","","","Cyan","") +hi! link rubyConstant Type +hi! link rubyFunction Function + +call s:X("rubyInstanceVariable","c6b6fe","","","Cyan","") +call s:X("rubySymbol","7697d6","","","Blue","") +hi! link rubyGlobalVariable rubyInstanceVariable +hi! link rubyModule rubyClass +call s:X("rubyControl","7597c6","","","Blue","") + +hi! link rubyString String +hi! link rubyStringDelimiter StringDelimiter +hi! link rubyInterpolationDelimiter Identifier + +call s:X("rubyRegexpDelimiter","540063","","","Magenta","") +call s:X("rubyRegexp","dd0093","","","DarkMagenta","") +call s:X("rubyRegexpSpecial","a40073","","","Magenta","") + +call s:X("rubyPredefinedIdentifier","de5577","","","Red","") + +" Erlang + +hi! link erlangAtom rubySymbol +hi! link erlangBIF rubyPredefinedIdentifier +hi! link erlangFunction rubyPredefinedIdentifier +hi! link erlangDirective Statement +hi! link erlangNode Identifier + +" Elixir + +hi! link elixirAtom rubySymbol + + +" JavaScript + +hi! link javaScriptValue Constant +hi! link javaScriptRegexpString rubyRegexp +hi! link javaScriptTemplateVar StringDelim +hi! link javaScriptTemplateDelim Identifier +hi! link javaScriptTemplateString String + +" CoffeeScript + +hi! link coffeeRegExp javaScriptRegexpString + +" Lua + +hi! link luaOperator Conditional + +" C + +hi! link cFormat Identifier +hi! link cOperator Constant + +" Objective-C/Cocoa + +hi! link objcClass Type +hi! link cocoaClass objcClass +hi! link objcSubclass objcClass +hi! link objcSuperclass objcClass +hi! link objcDirective rubyClass +hi! link objcStatement Constant +hi! link cocoaFunction Function +hi! link objcMethodName Identifier +hi! link objcMethodArg Normal +hi! link objcMessageName Identifier + +" Vimscript + +hi! link vimOper Normal + +" HTML + +hi! link htmlTag Statement +hi! link htmlEndTag htmlTag +hi! link htmlTagName htmlTag + +" XML + +hi! link xmlTag Statement +hi! link xmlEndTag xmlTag +hi! link xmlTagName xmlTag +hi! link xmlEqual xmlTag +hi! link xmlEntity Special +hi! link xmlEntityPunct xmlEntity +hi! link xmlDocTypeDecl PreProc +hi! link xmlDocTypeKeyword PreProc +hi! link xmlProcessingDelim xmlAttrib + +" Debugger.vim + +call s:X("DbgCurrent","DEEBFE","345FA8","","White","DarkBlue") +call s:X("DbgBreakPt","","4F0037","","","DarkMagenta") + +" vim-indent-guides + +if !exists("g:indent_guides_auto_colors") + let g:indent_guides_auto_colors = 0 +endif +call s:X("IndentGuidesOdd","","232323","","","") +call s:X("IndentGuidesEven","","1b1b1b","","","") + +" Plugins, etc. + +hi! link TagListFileName Directory +call s:X("PreciseJumpTarget","B9ED67","405026","","White","Green") + +" Manual overrides for 256-color terminals. Dark colors auto-map badly. +if !s:low_color + hi StatusLineNC ctermbg=235 + hi Folded ctermbg=236 + hi DiffText ctermfg=81 + hi DbgBreakPt ctermbg=53 + hi IndentGuidesOdd ctermbg=235 + hi IndentGuidesEven ctermbg=234 +endif + +if !empty("s:overrides") + fun! s:current_attr(group) + let l:synid = synIDtrans(hlID(a:group)) + let l:attrs = [] + for l:attr in ["bold", "italic", "reverse", "standout", "underline", "undercurl"] + if synIDattr(l:synid, l:attr, "gui") == 1 + call add(l:attrs, l:attr) + endif + endfor + return join(l:attrs, ",") + endfun + fun! s:current_color(group, what, mode) + let l:color = synIDattr(synIDtrans(hlID(a:group)), a:what, a:mode) + if l:color == -1 + return "" + else + return substitute(l:color, "^#", "", "") + endif + endfun + fun! s:load_color_def(group, def) + call s:X(a:group, get(a:def, "guifg", s:current_color(a:group, "fg", "gui")), + \ get(a:def, "guibg", s:current_color(a:group, "bg", "gui")), + \ get(a:def, "attr", s:current_attr(a:group)), + \ get(a:def, "ctermfg", s:current_color(a:group, "fg", "cterm")), + \ get(a:def, "ctermbg", s:current_color(a:group, "bg", "cterm"))) + if !s:low_color + for l:prop in ["ctermfg", "ctermbg"] + let l:override_key = "256".l:prop + if has_key(a:def, l:override_key) + exec "hi ".a:group." ".l:prop."=".a:def[l:override_key] + endif + endfor + endif + endfun + fun! s:load_colors(defs) + for [l:group, l:def] in items(a:defs) + if l:group == "background" + call s:load_color_def("LineNr", l:def) + call s:load_color_def("NonText", l:def) + call s:load_color_def("Normal", l:def) + else + call s:load_color_def(l:group, l:def) + endif + unlet l:group + unlet l:def + endfor + endfun + call s:load_colors(s:overrides) + delf s:load_colors + delf s:load_color_def + delf s:current_color + delf s:current_attr +endif + +" delete functions {{{ +delf s:X +delf s:remove_italic_attr +delf s:prefix_highlight_value_with +delf s:rgb +delf s:is_empty_or_none +delf s:color +delf s:rgb_color +delf s:rgb_level +delf s:rgb_number +delf s:grey_color +delf s:grey_level +delf s:grey_number +" }}} diff --git a/copy.sh b/copy.sh index 1ca869d..e479caf 100755 --- a/copy.sh +++ b/copy.sh @@ -1,6 +1,32 @@ #!/bin/bash SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -for f in $(find $SCRIPT_DIR -mindepth 1 -name ".*" -not -name ".git"); do +moving_files="$(find $SCRIPT_DIR -mindepth 1 -maxdepth 1 -type f -not -name "copy.sh" -not -name "*.git*")" +moving_files=$(echo -e "$moving_files\n$(find $SCRIPT_DIR/.vim/colors/ -mindepth 1)") + +home_files="" +for f in $moving_files; do + home_file="$HOME$(echo $f | sed "s@$SCRIPT_DIR@@")" + if test -f "$home_file"; then + home_files="$home_files\n $home_file" + fi +done + +if [[ "$home_files" != "" ]]; then + echo -n "Warning! This will overwrite all of the following files:" + echo -e $home_files + + read -r -p "Are you sure you want to continue? [y/N] " response + response=${response,,} # tolower + if ! [[ "$response" =~ ^(yes|y)$ ]]; then + exit 1 + fi +fi + +for f in $moving_files; do + echo "$f => ~/" ln -sf $f ~/ done + +mkdir -p ~/.vim/colors +ln -sf $SCRIPT_DIR/.vim/colors/* ~/.vim/colors/ From d1347b926aa84afecf68e5c9b9992c142d429b3f Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:01:46 -0400 Subject: [PATCH 08/28] Just touch .zsh_local --- .zsh_local | 0 copy.sh | 2 ++ 2 files changed, 2 insertions(+) delete mode 100644 .zsh_local diff --git a/.zsh_local b/.zsh_local deleted file mode 100644 index e69de29..0000000 diff --git a/copy.sh b/copy.sh index e479caf..e202d34 100755 --- a/copy.sh +++ b/copy.sh @@ -30,3 +30,5 @@ done mkdir -p ~/.vim/colors ln -sf $SCRIPT_DIR/.vim/colors/* ~/.vim/colors/ + +touch ~/.zsh_local From 3f644ee76bdbda22b3ac495eda92dde683ec91bb Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:15:39 -0400 Subject: [PATCH 09/28] Cut a bunch from .zshrc. Now expects starship. --- .zshrc | 84 +++++++++++++++------------------------------------------- 1 file changed, 21 insertions(+), 63 deletions(-) diff --git a/.zshrc b/.zshrc index 7a85d96..901c033 100644 --- a/.zshrc +++ b/.zshrc @@ -1,5 +1,5 @@ source ~/.zsh_local -source ~/.shell_aliases +source /usr/share/doc/fzf/examples/completion.zsh HISTFILE=~/.histfile HISTSIZE=10000 @@ -23,52 +23,40 @@ export EDITOR="vim" zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate zstyle ':completion:*' matcher-list '+' '+m:{[:lower:]}={[:upper:]}' '+m:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+r:|[._-]=** r:|=** l:|=*' zstyle :compinstall filename '~/.zshrc' +zstyle ':completion:*' ignored-patterns '*.class' autoload -Uz compinit compinit -autoload -Uz vcs_info -precmd() { vcs_info } - -zstyle ':vcs_info:git:*' formats ' [%b]' - -_COMP_COLOR=${COMP_COLOR:-"{white}"} -_USER_COLOR=${USER_COLOR:-"{blue}"} - -setopt PROMPT_SUBST -PROMPT="[%(!.%B%F{red}.%B%F$_USER_COLOR)%n%b%F{white}@%B%F$_COMP_COLOR%m%b%f] %b%F{green}%~%B%F{yellow}${vcs_info_msg_0_} %B%f$%b%f " - # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi -export PATH=./:~/.bin:$PATH +export PATH=./:~/.bin:/usr/local/go/bin:$PATH fignore=(o) function SetTtyColors() { - echo -en "\e]P0191e1f" #black 1 - echo -en "\e]P1dc4848" #darkgrey 2 - echo -en "\e]P200aa00" #darkred 3 - echo -en "\e]P3d99f4e" #red 4 - echo -en "\e]P44444aa" #darkgreen 5 - echo -en "\e]P5c436b9" #green 6 - echo -en "\e]P600aaaa" #brown 7 - echo -en "\e]P7d7d7d7" #yellow 8 - echo -en "\e]P87b7b7b" #darkblue 9 - echo -en "\e]P9ff6f6f" #blue 10 - echo -en "\e]PA55ff55" #darkmagenta11 - echo -en "\e]PBffed8b" #magenta 12 - echo -en "\e]PC5555ff" #darkcyan 13 - echo -en "\e]PDff6eff" #cyan 14 - echo -en "\e]PE55ffff" #lightgray 15 - echo -en "\e]PFaaaaaa" #white 16 + echo -en "\e]P0""191e1f" #black 1 + echo -en "\e]P1""dc4848" #darkgrey 2 + echo -en "\e]P2""00aa00" #darkred 3 + echo -en "\e]P3""d99f4e" #red 4 + echo -en "\e]P4""4444aa" #darkgreen 5 + echo -en "\e]P5""c436b9" #green 6 + echo -en "\e]P6""00aaaa" #brown 7 + echo -en "\e]P7""d7d7d7" #yellow 8 + echo -en "\e]P8""7b7b7b" #darkblue 9 + echo -en "\e]P9""ff6f6f" #blue 10 + echo -en "\e]PA""55ff55" #darkmagenta11 + echo -en "\e]PB""ffed8b" #magenta 12 + echo -en "\e]PC""5555ff" #darkcyan 13 + echo -en "\e]PD""ff6eff" #cyan 14 + echo -en "\e]PE""55ffff" #lightgray 15 + echo -en "\e]PF""aaaaaa" #white 16 clear } @@ -76,37 +64,6 @@ if [ "$TERM" = "linux" ]; then SetTtyColors fi -function _open2(){ - var=$(fc -ln -1); - if [[ $var != *"grep"* ]]; then; - return; - fi; - var=$(sed "s/grepr/grepr -l/" <<< $var); - vim -p `zsh -c "$var" | grep $1` -} - -# After running grepr, `open` plus a match will -# search history for the most recent grepr, -# and open the first file matching the text -# in Vim, at the first matching line number -function _open(){ - command=$(fc -ln -1); - count=1; - while [[ $command != *"grepr"* ]]; do - ((count++)) - command=$(fc -ln -$count | head -n 1); - done; - - # echo '$@' - line=$(zsh -c "$command" | grep $1 | sed "s/^[^:]*://g" | sed "s/:.*//" | head -n 1); - echo $line; - file=$(zsh -c "$command" | grep $1 | sed "s/:.*//" | head -n 1); - echo $file; - - vim +$line -p `echo $file`; - -} - function pushdot { cd ~/.dotfiles && if [ $# -eq 0 ]; then @@ -123,4 +80,5 @@ function getdot { cd - } -export fsu="vaillanc@linprog.cs.fsu.edu" +eval "$(starship init zsh)" +source ~/.shell_aliases From be46d132e62dee20b95034ddff66e2a8e7ae8d0e Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:23:45 -0400 Subject: [PATCH 10/28] Add bat, fzf, and grepi to aliases. --- .shell_aliases | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.shell_aliases b/.shell_aliases index 374da58..075d103 100644 --- a/.shell_aliases +++ b/.shell_aliases @@ -4,6 +4,27 @@ function fin { find -iname "*$@*" } +alias cat="bat" +export FZF_DEFAULT_COMMAND='fd --type f' +alias fzf="fzf --preview 'bat --style=numbers --color=always {}'" + +function vo { + if [[ "$1" == "" ]]; then + local f="$(fzf --preview "bat --style=numbers --color=always {}")" + if [[ "$f" != "" ]]; then + print -s "vim $f" + vim $f + fi + else + local f="$(fzf -1 -q $@ | head -n 1)" + if [[ "$f" != "" ]]; then + print -s "vim $f" + vim $f + fi + fi + echo $f +} + # Mkdir should remind you to use git alias mkdir="echo 'Maybe use git init if this is a new project' && mkdir" @@ -31,7 +52,8 @@ alias termrc='vim ~/.config/xfce4/terminal/terminalrc' # Use `grepr` for a recursive, case-insensitive, and filtered grep # alias grepr="grep -RInsi --color=auto --exclude-dir=.git --exclude=tags" # alias grepr='grep -RInsi --color=auto --exclude-dir=.git --exclude-dir=banana_pi_kernel --exclude-dir={bpi_build_scripts, storm_dox, sam_dox} --exclude=tags --exclude=\*.{ko, o}' -alias grepr='grep -RInsi --color=auto --exclude-dir=.git --exclude=tags' +alias grepr='grep -RIns --color=auto --exclude-dir=.git --exclude-dir=venv --exclude-dir=node_modules --exclude=tags --exclude-dir=build' +alias grepi='grepr -i' alias apt="sudo apt" alias apt-get="sudo apt-get" @@ -62,4 +84,4 @@ alias ls='ls --color=auto -F -w 80' # Using du automatically finds the total alias du='du -sh' -alias tags='ctags -f newtags -R . && mv newtags tags' +alias tags='ctags --exclude=node_modules -f newtags -R . && mv newtags tags' From 904bca405c13a8bc47ff8382d072da3fac41aa2d Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:25:31 -0400 Subject: [PATCH 11/28] Switch cargo setup. --- .bash_profile | 2 +- .zprofile | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.bash_profile b/.bash_profile index ae4555c..a7a9ef5 100644 --- a/.bash_profile +++ b/.bash_profile @@ -4,4 +4,4 @@ [[ -f ~/.bashrc ]] && . ~/.bashrc -export PATH="$HOME/.cargo/bin:$PATH" +. "$HOME/.cargo/env" diff --git a/.zprofile b/.zprofile index 71ad6d4..8b13789 100644 --- a/.zprofile +++ b/.zprofile @@ -1,2 +1 @@ -export PATH="$HOME/.cargo/bin:$PATH" From 1ccd582a7be9fb8ffbe1c891cadede82a803d683 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:32:36 -0400 Subject: [PATCH 12/28] Add some dep installation to copy.sh --- copy.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/copy.sh b/copy.sh index e202d34..cb40198 100755 --- a/copy.sh +++ b/copy.sh @@ -32,3 +32,21 @@ mkdir -p ~/.vim/colors ln -sf $SCRIPT_DIR/.vim/colors/* ~/.vim/colors/ touch ~/.zsh_local + +# Install required packages +if [[ "$1" == "--install" ]]; then + echo -n "Rust is " + if ! where cargo; then + echo "not installed. Installing..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + else + echo "installed." + fi + . "$HOME/.cargo/env" + if where cargo; then + cargo install bat + fi + sh -c "$(curl -fsSL https://starship.rs/install.sh)" + echo "Starship requires an NFont: https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/FiraCode.zip" + echo "You may wish to install fzf" +fi From 44ff7c9a958df70b323ce3090793f4dc0fbe70bb Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:41:08 -0400 Subject: [PATCH 13/28] General vim improvements. More dependent on non-defaults however. --- .vimrc | 96 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 28 deletions(-) diff --git a/.vimrc b/.vimrc index e4860b9..b59d1b6 100644 --- a/.vimrc +++ b/.vimrc @@ -1,28 +1,47 @@ -"""""""""""""""""""""" -" __ _____ __ __ " -" \ \ / /_ _| \/ | " -" \ V / | || |\/| | " -" \_/ |___|_| |_| " -" " -"""""""""""""""""""""" +" \ / o _ _ +" \/ | | | | + set nocp - -so ~/.vim/user/files.vim - -colorscheme desert -syntax enable +set shell=/usr/bin/zsh set tsr+=~/.vim/thesaurus/thesaurus-vim-en set dict+=/usr/share/dict/words -set foldmethod=syntax -set foldlevelstart=5 +set tags=./tags;/ " Search up to / for tags file +set updatetime=100 +set clipboard=unnamedplus " Use system clipboard + +set termguicolors +let &t_8f = "\[38:2:%lu:%lu:%lum" +let &t_8b = "\[48:2:%lu:%lu:%lum" +syntax enable + +colorscheme jellybeans + +let mapleader=" " + +" Auto open NERDTree but focus editing window +autocmd VimEnter * NERDTree +autocmd BufEnter * NERDTreeMirror +autocmd VimEnter * wincmd w +autocmd VimEnter * NERDTreeFind +autocmd VimEnter * wincmd w +" Auto close NERDTree +autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + +set mouse=a set backspace=indent,eol,start set splitbelow set splitright +set foldmethod=syntax +set foldlevelstart=99 + +" Leave some room when scrolling +set scrolloff=3 + nnoremap :W :w set conceallevel=0 @@ -33,9 +52,6 @@ set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab " Except for makefiles autocmd FileType make setlocal noexpandtab -" Search up to / for tags file -set tags=./tags;/ - " *** BINDINGS *** " Beautful escapes @@ -55,7 +71,6 @@ set number relativenumber set ignorecase smartcase set autoindent smartindent - "Yank to clipboard nnoremap "+yy vnoremap "+y @@ -81,7 +96,9 @@ tnoremap tnoremap tnoremap -nnoremap ! :! +" Jump to next/prev uppercase/underscore +nnoremap f /[A-Z_] +nnoremap F ?[A-Z_] " Map directions to end/beginning of lines nnoremap yl y$ @@ -96,14 +113,6 @@ nnoremap m`v$hp``y$ nnoremap PP :ha > ~/.vim.ps:!xdg-open ~/.vim.ps vnoremap PP :ha > ~/.vim.ps:!xdg-open ~/.vim.ps -" Return spelling corrections -iab ruetn return -iab reteun return -iab reutner return - -nnoremap cw ciw -nnoremap ciw cw - " Swap current word with next nnoremap gs "xdiwdwep"xp " Inverted @@ -124,9 +133,11 @@ nnoremap gu :!git add -u nnoremap ga :!git add % nnoremap r :source ~/.vimrc -nnoremap v :tabedit~/.vimrc nnoremap n :tabedit~/.notes +nnoremap v :vert term ++cols=80 +nnoremap t :term ++rows=20 + autocmd BufNewFile,BufRead * if expand('%:t') !~ '\.' | setl spell | endif " Expand %% to the current files dir @@ -146,3 +157,32 @@ if has ("autocmd") autocmd BufNewFile makefile 0r ~/.vim/templates/makefile augroup END endif + +let s:copypastemode = 0 +function! ToggleCopyPaste() + if s:copypastemode + set nopaste + set number + set relativenumber + let s:copypastemode = 0 + else + set paste + set nonumber + set norelativenumber + let s:copypastemode = 1 + endif +endfunction +nnoremap :call ToggleCopyPaste() +inoremap :call ToggleCopyPaste()i +nnoremap p +inoremap p + +" Spelling corrections +iab ruetn return +iab reteun return +iab reutner return + +" Keep same gutter color when errored +highlight! link SignColumn LineNr + +so ~/.vim/user/files.vim From 403f1a8a5fd6d28e793d8a7ab7bd599dc62a4063 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:50:04 -0400 Subject: [PATCH 14/28] Add .gitlocal include to .gitconfig --- .gitconfig | 20 ++++++++++++++++---- copy.sh | 5 +++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitconfig b/.gitconfig index 1fe3f6f..8e96130 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,7 +1,19 @@ [user] - name = Sage Vaillancourt - email = sagev9000@tutanota.com + name = Sage Vaillancourt + [core] - autocrlf = input + autocrlf = input + excludesfile = ~/.gitignore + [credential] - helper = store + helper = store + +[push] + default = current + followTags = true + +[help] + autocorrect = 1 + +[include] + path = ~/.gitlocal diff --git a/copy.sh b/copy.sh index cb40198..a2d938d 100755 --- a/copy.sh +++ b/copy.sh @@ -33,6 +33,11 @@ ln -sf $SCRIPT_DIR/.vim/colors/* ~/.vim/colors/ touch ~/.zsh_local +if ! test -f ~/.gitlocal; then + echo "[user]" > ~/.gitlocal + echo " email = sagev9000@tutanota.com" >> ~/.gitlocal +fi + # Install required packages if [[ "$1" == "--install" ]]; then echo -n "Rust is " From def543131beb67cb04955ca79132deb8cc277d87 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:50:49 -0400 Subject: [PATCH 15/28] Remove CopyPaste mode. Let clipboard handle it. --- .vimrc | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.vimrc b/.vimrc index b59d1b6..e203107 100644 --- a/.vimrc +++ b/.vimrc @@ -158,22 +158,6 @@ if has ("autocmd") augroup END endif -let s:copypastemode = 0 -function! ToggleCopyPaste() - if s:copypastemode - set nopaste - set number - set relativenumber - let s:copypastemode = 0 - else - set paste - set nonumber - set norelativenumber - let s:copypastemode = 1 - endif -endfunction -nnoremap :call ToggleCopyPaste() -inoremap :call ToggleCopyPaste()i nnoremap p inoremap p From 182b3b7a8d04a2cdc7cf7f15ae00ada24c202f5d Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:51:40 -0400 Subject: [PATCH 16/28] Run pushdot in background. --- .zshrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index 901c033..00fb59e 100644 --- a/.zshrc +++ b/.zshrc @@ -67,9 +67,9 @@ fi function pushdot { cd ~/.dotfiles && if [ $# -eq 0 ]; then - git commit -a && git push -u origin master + git commit -a && git push -u origin master & else - git commit -a -m "$1" && git push -u origin master + git commit -a -m "$1" && git push -u origin master & fi cd - } From bf441aba5ff53607b31396fc1125ac921b769841 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 13:52:23 -0400 Subject: [PATCH 17/28] Try bg'ing into /dev/null --- .zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index 00fb59e..193407e 100644 --- a/.zshrc +++ b/.zshrc @@ -69,7 +69,7 @@ function pushdot { if [ $# -eq 0 ]; then git commit -a && git push -u origin master & else - git commit -a -m "$1" && git push -u origin master & + git commit -a -m "$1" && git push -u origin master | /dev/null & fi cd - } From dfc6a780e94fba88281c2cce7ca9451dfe80c649 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 14:18:30 -0400 Subject: [PATCH 18/28] Close file tree for commit messages --- .vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.vimrc b/.vimrc index e203107..f83e54f 100644 --- a/.vimrc +++ b/.vimrc @@ -28,6 +28,7 @@ autocmd VimEnter * NERDTreeFind autocmd VimEnter * wincmd w " Auto close NERDTree autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +autocmd VimEnter COMMIT_EDITMSG NERDTreeClose set mouse=a From 2d4801fbe01964c9a193d9f700060dfd8ef4dae5 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Oct 2021 19:16:02 -0400 Subject: [PATCH 19/28] POSIX-compatible command-existence checking. --- copy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/copy.sh b/copy.sh index a2d938d..ed51a8e 100755 --- a/copy.sh +++ b/copy.sh @@ -41,14 +41,14 @@ fi # Install required packages if [[ "$1" == "--install" ]]; then echo -n "Rust is " - if ! where cargo; then + if ! command -v cargo; then echo "not installed. Installing..." curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh else echo "installed." fi . "$HOME/.cargo/env" - if where cargo; then + if command -v cargo; then cargo install bat fi sh -c "$(curl -fsSL https://starship.rs/install.sh)" From 651143817b830d7f3abd07cba07adef8d09d08b6 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Thu, 7 Oct 2021 11:29:19 -0400 Subject: [PATCH 20/28] Check diff before reporting overwrites. Add starship config. --- .config/starship.toml | 80 +++++++++++++++++++++++++++++++++++++++++++ copy.sh | 6 +++- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 .config/starship.toml diff --git a/.config/starship.toml b/.config/starship.toml new file mode 100644 index 0000000..773c5c7 --- /dev/null +++ b/.config/starship.toml @@ -0,0 +1,80 @@ +add_newline = false +format = """ +[\\[sage\\]](bold red) \ +$username\ +$hostname\ +$shlvl\ +$kubernetes\ +$directory\ +$vcsh\ +$java\ +$nodejs\ +$dart\ +$deno\ +$dotnet\ +$elixir\ +$elm\ +$erlang\ +$golang\ +$helm\ +$julia\ +$kotlin\ +$nim\ +$ocaml\ +$perl\ +$php\ +$purescript\ +$python\ +$red\ +$ruby\ +$rust\ +$scala\ +$swift\ +$terraform\ +$vlang\ +$vagrant\ +$zig\ +$git_branch\ +$git_commit\ +$git_state\ +$git_metrics\ +$git_status\ +$hg_branch\ +$docker_context\ +$cmake\ +$nix_shell\ +$conda\ +$memory_usage\ +$aws\ +$gcloud\ +$openstack\ +$env_var\ +$crystal\ +$custom\ +$line_break\ +$lua\ +$jobs\ +$battery\ +$time\ +$status\ +$shell\ +$character""" + +[character] +success_symbol = "[\\$](bold white)" +error_symbol = "[✗](bold red)" + +[directory] +style = "green bold" +truncate_to_repo = false +truncation_length = 0 + +[nodejs] +format = "$symbol" + +[java] +format = "$symbol" + +[time] +disabled = true +use_12hr = true diff --git a/copy.sh b/copy.sh index a2d938d..a031984 100755 --- a/copy.sh +++ b/copy.sh @@ -3,11 +3,12 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) moving_files="$(find $SCRIPT_DIR -mindepth 1 -maxdepth 1 -type f -not -name "copy.sh" -not -name "*.git*")" moving_files=$(echo -e "$moving_files\n$(find $SCRIPT_DIR/.vim/colors/ -mindepth 1)") +moving_files=$(echo -e "$moving_files\n$(find $SCRIPT_DIR/.config/ -mindepth 1)") home_files="" for f in $moving_files; do home_file="$HOME$(echo $f | sed "s@$SCRIPT_DIR@@")" - if test -f "$home_file"; then + if test -f "$home_file" && ! diff $home_file $f &>/dev/null; then home_files="$home_files\n $home_file" fi done @@ -31,6 +32,9 @@ done mkdir -p ~/.vim/colors ln -sf $SCRIPT_DIR/.vim/colors/* ~/.vim/colors/ +mkdir -p ~/.config/ +ln -sf $SCRIPT_DIR/.config/* ~/.config/ + touch ~/.zsh_local if ! test -f ~/.gitlocal; then From c594dd829010b74718fffb2d3064c18a1d367c38 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 29 Dec 2021 19:15:04 -0500 Subject: [PATCH 21/28] Don't use fancy color schemes in TTY --- .vimrc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.vimrc b/.vimrc index f83e54f..cea9182 100644 --- a/.vimrc +++ b/.vimrc @@ -11,12 +11,16 @@ set tags=./tags;/ " Search up to / for tags file set updatetime=100 set clipboard=unnamedplus " Use system clipboard -set termguicolors -let &t_8f = "\[38:2:%lu:%lu:%lum" -let &t_8b = "\[48:2:%lu:%lu:%lum" -syntax enable +if empty($DISPLAY) + colorscheme elflord +else + set termguicolors + let &t_8f = "\[38:2:%lu:%lu:%lum" + let &t_8b = "\[48:2:%lu:%lu:%lum" + syntax enable -colorscheme jellybeans + colorscheme jellybeans +endif let mapleader=" " From a70bceb09af1162ad854582f17d7e4baed9b9a17 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 29 Dec 2021 19:16:08 -0500 Subject: [PATCH 22/28] Tweak TTY colors --- .zshrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index 193407e..b447c57 100644 --- a/.zshrc +++ b/.zshrc @@ -41,7 +41,7 @@ export PATH=./:~/.bin:/usr/local/go/bin:$PATH fignore=(o) function SetTtyColors() { - echo -en "\e]P0""191e1f" #black 1 + echo -en "\e]P0""292e2f" #black 1 echo -en "\e]P1""dc4848" #darkgrey 2 echo -en "\e]P2""00aa00" #darkred 3 echo -en "\e]P3""d99f4e" #red 4 @@ -50,7 +50,7 @@ function SetTtyColors() { echo -en "\e]P6""00aaaa" #brown 7 echo -en "\e]P7""d7d7d7" #yellow 8 echo -en "\e]P8""7b7b7b" #darkblue 9 - echo -en "\e]P9""ff6f6f" #blue 10 + echo -en "\e]P9""6f6fff" #blue 10 echo -en "\e]PA""55ff55" #darkmagenta11 echo -en "\e]PB""ffed8b" #magenta 12 echo -en "\e]PC""5555ff" #darkcyan 13 From 801f824391c7b7fa705c853240f9aedafbd848c0 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 30 Jan 2022 22:42:56 -0500 Subject: [PATCH 23/28] Add some wiki-related changes. Disable automatic NERDTree opening. --- .shell_aliases | 15 +++++++++++++++ .vimrc | 22 ++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.shell_aliases b/.shell_aliases index 075d103..a1d2d66 100644 --- a/.shell_aliases +++ b/.shell_aliases @@ -4,6 +4,21 @@ function fin { find -iname "*$@*" } +function ws { + if [[ "$@" != "" ]]; then + local fzf_args="-q $@" + fi + # fd --type f --search-path ~/wiki -x cat | grep -v "^ *$" | \fzf $fzf_args + local filename="$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')" + if [[ "$filename" != "" ]]; then + vim ~/wiki/$filename + fi +} + +function ww { + ws $(rg --no-line-number --no-filename . ~/wiki | sed 's/[^a-zA-Z0-9]\+/\n/g' | grep -v "^$" | sort -f | uniq -ci | sort -hr | fzf | cut -c 9-) +} + alias cat="bat" export FZF_DEFAULT_COMMAND='fd --type f' alias fzf="fzf --preview 'bat --style=numbers --color=always {}'" diff --git a/.vimrc b/.vimrc index cea9182..fdef6dd 100644 --- a/.vimrc +++ b/.vimrc @@ -23,16 +23,17 @@ else endif let mapleader=" " +nnoremap w yiwq:PI!fd -x cat fzf -q -" Auto open NERDTree but focus editing window -autocmd VimEnter * NERDTree -autocmd BufEnter * NERDTreeMirror -autocmd VimEnter * wincmd w -autocmd VimEnter * NERDTreeFind -autocmd VimEnter * wincmd w -" Auto close NERDTree -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif -autocmd VimEnter COMMIT_EDITMSG NERDTreeClose +" " Auto open NERDTree but focus editing window +" autocmd VimEnter * NERDTree +" autocmd BufEnter * NERDTreeMirror +" autocmd VimEnter * wincmd w +" autocmd VimEnter * NERDTreeFind +" autocmd VimEnter * wincmd w +" " Auto close NERDTree +" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +" autocmd VimEnter COMMIT_EDITMSG NERDTreeClose set mouse=a @@ -47,8 +48,6 @@ set foldlevelstart=99 " Leave some room when scrolling set scrolloff=3 -nnoremap :W :w - set conceallevel=0 " Use 4 spaces @@ -60,7 +59,6 @@ autocmd FileType make setlocal noexpandtab " *** BINDINGS *** " Beautful escapes -inoremap fd l inoremap jj l inoremap jk l inoremap kj l From 3627eac40d2138b948dfa02fdb6c5f1737c1dc72 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 30 Jan 2022 22:44:31 -0500 Subject: [PATCH 24/28] Make defaultBranch main, and show diff in commits --- .gitconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitconfig b/.gitconfig index 8e96130..7c35ed9 100644 --- a/.gitconfig +++ b/.gitconfig @@ -17,3 +17,8 @@ [include] path = ~/.gitlocal +[init] + defaultBranch = main + +[commit] + verbose = true From bcc462e5d2b62a1fd82427fd63c3c06f7fab6cda Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 30 Jan 2022 23:12:32 -0500 Subject: [PATCH 25/28] Make aliases executable. Add separate wf function for wiki work. --- .shell_aliases | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) mode change 100644 => 100755 .shell_aliases diff --git a/.shell_aliases b/.shell_aliases old mode 100644 new mode 100755 index a1d2d66..5505c44 --- a/.shell_aliases +++ b/.shell_aliases @@ -4,14 +4,17 @@ function fin { find -iname "*$@*" } -function ws { +function wf { if [[ "$@" != "" ]]; then local fzf_args="-q $@" fi - # fd --type f --search-path ~/wiki -x cat | grep -v "^ *$" | \fzf $fzf_args - local filename="$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')" + echo ~/wiki/"$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')" +} + +function ws { + local filename="$(wf $@)" if [[ "$filename" != "" ]]; then - vim ~/wiki/$filename + vim $filename fi } @@ -100,3 +103,7 @@ alias ls='ls --color=auto -F -w 80' alias du='du -sh' alias tags='ctags --exclude=node_modules -f newtags -R . && mv newtags tags' + +if [[ "$@" != "" ]]; then + $@ +fi From 74e9c24a40ebe635039ba6c59a6804dffc724f54 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 31 Jan 2022 19:46:19 -0500 Subject: [PATCH 26/28] Correct wiki mappings. --- .vimrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.vimrc b/.vimrc index fdef6dd..64545fc 100644 --- a/.vimrc +++ b/.vimrc @@ -23,7 +23,13 @@ else endif let mapleader=" " -nnoremap w yiwq:PI!fd -x cat fzf -q +"nnoremap w yiwq:PIe `~/.shell_aliases ws +"nnoremap w yiw:let srr_back = &srr set srr=>q:PIr! /home/sage/.shell_aliases wf +" TODO Check if file needs saving +" TODO Set and unset srr from within map +set srr=> +nnoremap w yiw:wq:PIr! /home/sage/.shell_aliases wf yyuq:PIe +nnoremap s yiw:wq:PIr! /home/sage/.shell_aliases wf yyuq:PIvsp " " Auto open NERDTree but focus editing window " autocmd VimEnter * NERDTree From 2e604153254a23fb5a5b467ca850ebe60b0e4efc Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 31 Jan 2022 19:46:51 -0500 Subject: [PATCH 27/28] Add cargo sourcing to zshrc. --- .zshrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.zshrc b/.zshrc index b447c57..811ba59 100644 --- a/.zshrc +++ b/.zshrc @@ -81,4 +81,5 @@ function getdot { } eval "$(starship init zsh)" +source ~/.cargo/env source ~/.shell_aliases From bb30274e25af37f9a875a73e55a1a782a99ecd93 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Tue, 1 Feb 2022 00:23:02 -0500 Subject: [PATCH 28/28] Case-insensitive wiki-searching --- .shell_aliases | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.shell_aliases b/.shell_aliases index 5505c44..827f655 100755 --- a/.shell_aliases +++ b/.shell_aliases @@ -8,7 +8,7 @@ function wf { if [[ "$@" != "" ]]; then local fzf_args="-q $@" fi - echo ~/wiki/"$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')" + echo ~/wiki/"$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf -i $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')" } function ws { @@ -19,7 +19,7 @@ function ws { } function ww { - ws $(rg --no-line-number --no-filename . ~/wiki | sed 's/[^a-zA-Z0-9]\+/\n/g' | grep -v "^$" | sort -f | uniq -ci | sort -hr | fzf | cut -c 9-) + ws $(rg --no-line-number --no-filename . ~/wiki | sed 's/[^a-zA-Z0-9]\+/\n/g' | grep -v "^$" | sort -f | uniq -ci | sort -hr | fzf -i | cut -c 9-) } alias cat="bat"