Initial Commit
This commit is contained in:
commit
10179cd257
5 changed files with 1247 additions and 0 deletions
142
.bashrc
Normal file
142
.bashrc
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
#
|
||||||
|
# ~/.bashrc
|
||||||
|
#
|
||||||
|
|
||||||
|
# If not running interactively, don't do anything
|
||||||
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
|
alias q=exit
|
||||||
|
|
||||||
|
colors() {
|
||||||
|
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"
|
||||||
|
|
||||||
|
# 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%%;}
|
||||||
|
|
||||||
|
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\\"'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
use_color=true
|
||||||
|
|
||||||
|
# Set colorful PS1 only on colorful terminals.
|
||||||
|
# dircolors --print-database uses its own built-in database
|
||||||
|
# instead of using /etc/DIR_COLORS. Try to use the external file
|
||||||
|
# first to take advantage of user additions. Use internal bash
|
||||||
|
# globbing instead of external grep binary.
|
||||||
|
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
|
||||||
|
match_lhs=""
|
||||||
|
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
|
||||||
|
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
|
||||||
|
[[ -z ${match_lhs} ]] \
|
||||||
|
&& 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
|
||||||
|
|
||||||
|
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'
|
||||||
|
else
|
||||||
|
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
|
||||||
|
|
||||||
|
alias cp="cp -i" # confirm before overwriting something
|
||||||
|
alias df='df -h' # human-readable sizes
|
||||||
|
alias free='free -m' # show sizes in MB
|
||||||
|
alias np='nano -w PKGBUILD'
|
||||||
|
alias more=less
|
||||||
|
|
||||||
|
xhost +local:root > /dev/null 2>&1
|
||||||
|
|
||||||
|
complete -cf sudo
|
||||||
|
|
||||||
|
# Bash won't get SIGWINCH if another process is in the foreground.
|
||||||
|
# Enable checkwinsize so that bash will check the terminal size when
|
||||||
|
# it regains control. #65623
|
||||||
|
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
|
||||||
|
shopt -s checkwinsize
|
||||||
|
|
||||||
|
shopt -s expand_aliases
|
||||||
|
|
||||||
|
# export QT_SELECT=4
|
||||||
|
|
||||||
|
# Enable history appending instead of overwriting. #139609
|
||||||
|
shopt -s histappend
|
||||||
|
|
||||||
|
#
|
||||||
|
# # ex - archive extractor
|
||||||
|
# # usage: ex <file>
|
||||||
|
ex ()
|
||||||
|
{
|
||||||
|
if [ -f $1 ] ; then
|
||||||
|
case $1 in
|
||||||
|
*.tar.bz2) tar xjf $1 ;;
|
||||||
|
*.tar.gz) tar xzf $1 ;;
|
||||||
|
*.bz2) bunzip2 $1 ;;
|
||||||
|
*.rar) unrar x $1 ;;
|
||||||
|
*.gz) gunzip $1 ;;
|
||||||
|
*.tar) tar xf $1 ;;
|
||||||
|
*.tbz2) tar xjf $1 ;;
|
||||||
|
*.tgz) tar xzf $1 ;;
|
||||||
|
*.zip) unzip $1 ;;
|
||||||
|
*.Z) uncompress $1;;
|
||||||
|
*.7z) 7z x $1 ;;
|
||||||
|
*) echo "'$1' cannot be extracted via ex()" ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "'$1' is not a valid file"
|
||||||
|
fi
|
||||||
|
}
|
7
.config/nvim/coc-settings.json
Normal file
7
.config/nvim/coc-settings.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"diagnostic.displayByAle": true
|
||||||
|
/* "coc.preferences.formatOnSaveFiletypes": { */
|
||||||
|
/* "rust" */
|
||||||
|
/* } */
|
||||||
|
}
|
||||||
|
|
553
.config/nvim/init.vim
Normal file
553
.config/nvim/init.vim
Normal file
|
@ -0,0 +1,553 @@
|
||||||
|
"set runtimepath^=~/.vim runtimepath+=~/.vim/after
|
||||||
|
"let &packpath = &runtimepath
|
||||||
|
"source ~/.vimrc
|
||||||
|
|
||||||
|
set suffixes+=.aux,.bbl,.blg,.brf,.cb,.dvi,.idx,.ilg,.ind,.inx,.jpg,.log,.out,.png,.toc
|
||||||
|
set suffixes-=.h
|
||||||
|
set suffixes-=.obj
|
||||||
|
|
||||||
|
set tabstop=3 softtabstop=3
|
||||||
|
set shiftwidth=3
|
||||||
|
set expandtab
|
||||||
|
set smartindent
|
||||||
|
" set foldmethod=indent
|
||||||
|
" set foldlevel=0
|
||||||
|
|
||||||
|
set undodir=~/.vim/undo
|
||||||
|
set undofile
|
||||||
|
|
||||||
|
set guifont=SauceCodePro\ NF\ Regular
|
||||||
|
|
||||||
|
set hlsearch
|
||||||
|
set hidden
|
||||||
|
set ignorecase
|
||||||
|
set smartcase
|
||||||
|
set wrap
|
||||||
|
set linebreak
|
||||||
|
" set guicursor= " always use the block cursor
|
||||||
|
syntax on
|
||||||
|
set redrawtime=1000 " max syntax highlight time
|
||||||
|
set number relativenumber
|
||||||
|
set noerrorbells
|
||||||
|
set encoding=UTF-8
|
||||||
|
set cursorline
|
||||||
|
set mouse=a
|
||||||
|
set incsearch
|
||||||
|
set scrolloff=6
|
||||||
|
" set wildmenu
|
||||||
|
" set wildmode=full
|
||||||
|
" TextEdit might fail if hidden is not set.
|
||||||
|
set hidden
|
||||||
|
set cmdheight=1 " Give more space for displaying messages.
|
||||||
|
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||||
|
" delays and poor user experience.
|
||||||
|
set updatetime=300
|
||||||
|
" Don't pass messages to |ins-completion-menu|.
|
||||||
|
set shortmess+=c
|
||||||
|
" Spell check!
|
||||||
|
set spell spelllang=en_us
|
||||||
|
" spell check in git commits
|
||||||
|
autocmd Filetype gitcommit setlocal spell
|
||||||
|
set showcmd
|
||||||
|
set signcolumn=yes
|
||||||
|
" disable spell check in help files
|
||||||
|
autocmd FileType help setlocal nospell
|
||||||
|
filetype plugin on
|
||||||
|
" Macro for opening a new terminal with spell check off
|
||||||
|
command! Term tabnew | setlocal nospell | term
|
||||||
|
autocmd FileType help setlocal nospell
|
||||||
|
" test whitespace ->
|
||||||
|
" more test whitespace ->
|
||||||
|
" Indented text
|
||||||
|
" even more test whitespace ->
|
||||||
|
|
||||||
|
" Key bindings
|
||||||
|
let mapleader = " "
|
||||||
|
" *sigh*...
|
||||||
|
command! Q q
|
||||||
|
command! W w
|
||||||
|
command! Wq wq
|
||||||
|
command! WQ wq
|
||||||
|
" nnoremap ; :
|
||||||
|
" vnoremap ; :
|
||||||
|
" Press Alt h to toggle highlighting on/off, and show current value.
|
||||||
|
noremap <M-h> :set hlsearch! hlsearch?<CR>
|
||||||
|
" Escape to enter normal mode in the terminal
|
||||||
|
tnoremap <Esc> <C-\><C-n>
|
||||||
|
" Replace with alt S
|
||||||
|
nnoremap <M-s> :%s//g<Left><Left>
|
||||||
|
" Wrapped line movement (hold ctrl to move like a word processor)
|
||||||
|
nmap <C-h> h
|
||||||
|
nmap <C-j> gj
|
||||||
|
nmap <C-k> gk
|
||||||
|
nmap <C-l> l
|
||||||
|
" nmap <C-4> g$
|
||||||
|
nmap <C>$ g$
|
||||||
|
nmap <C-6> g^
|
||||||
|
nmap <C-^> g^
|
||||||
|
nmap <C-0> g^
|
||||||
|
vmap <C-h> h
|
||||||
|
vmap <C-j> gj
|
||||||
|
vmap <C-k> gk
|
||||||
|
vmap <C-l> l
|
||||||
|
vmap <C-4> g$
|
||||||
|
vmap <C>$ g$
|
||||||
|
vmap <C-6> g^
|
||||||
|
vmap <C-^> g^
|
||||||
|
vmap <C-0> g^
|
||||||
|
" " Hold ctrl to move between windows, shift to reorder the windows
|
||||||
|
" nmap <C-h> <C-w>h
|
||||||
|
" nmap <C-j> <C-w>j
|
||||||
|
" nmap <C-k> <C-w>k
|
||||||
|
" nmap <C-l> <C-w>l
|
||||||
|
" nmap <C-H> <C-w>H
|
||||||
|
" nmap <C-J> <C-w>J
|
||||||
|
" nmap <C-K> <C-w>K
|
||||||
|
" nmap <C-L> <C-w>L
|
||||||
|
" " and for visual mode
|
||||||
|
" vmap <C-h> <C-w>h
|
||||||
|
" vmap <C-j> <C-w>j
|
||||||
|
" vmap <C-k> <C-w>k
|
||||||
|
" vmap <C-l> <C-w>l
|
||||||
|
" vmap <C-H> <C-w>H
|
||||||
|
" vmap <C-J> <C-w>J
|
||||||
|
" vmap <C-K> <C-w>K
|
||||||
|
" vmap <C-L> <C-w>L
|
||||||
|
|
||||||
|
""""""" Quality of life things that aren't one line (also from stack overflow and stuff)
|
||||||
|
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
|
||||||
|
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
|
||||||
|
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
|
||||||
|
if (empty($TMUX))
|
||||||
|
if (has("nvim"))
|
||||||
|
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
|
||||||
|
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
||||||
|
endif
|
||||||
|
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
|
||||||
|
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
|
||||||
|
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
|
||||||
|
if (has("termguicolors"))
|
||||||
|
set termguicolors
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" 'Visual At' plugin (https://github.com/stoeffel/.dotfiles/blob/master/vim/visual-at.vim)
|
||||||
|
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
|
||||||
|
function! ExecuteMacroOverVisualRange()
|
||||||
|
echo "@".getcmdline()
|
||||||
|
execute ":'<,'>normal @".nr2char(getchar())
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Make shift-insert work like in Xterm
|
||||||
|
if has('gui_running')
|
||||||
|
map <S-Insert> <MiddleMouse>
|
||||||
|
map! <S-Insert> <MiddleMouse>
|
||||||
|
endif
|
||||||
|
set exrc
|
||||||
|
|
||||||
|
" Automatically jump to the last position in a file when opening
|
||||||
|
if has("autocmd")
|
||||||
|
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
"" Plugins
|
||||||
|
" disable polyglot in markdown (needs to go before it loads)
|
||||||
|
let g:polyglot_disabled = ['markdown']
|
||||||
|
" make ALE work with CoC
|
||||||
|
let g:ale_disable_lsp = 1
|
||||||
|
call plug#begin('$HOME/.vim/plugins/')
|
||||||
|
""" Colors
|
||||||
|
Plug 'joshdick/onedark.vim' " Theme (status line)
|
||||||
|
Plug 'romgrk/doom-one.vim' " Theme (UI)
|
||||||
|
" Plug 'rakr/vim-one' " Theme (UI)
|
||||||
|
Plug 'vim-airline/vim-airline' " Status line theme
|
||||||
|
Plug 'Yggdroot/indentLine' " Indent lines
|
||||||
|
Plug 'sheerun/vim-polyglot' " Syntax highlighting
|
||||||
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Syntax highlighting (neovim 0.5)
|
||||||
|
Plug 'airblade/vim-gitgutter' " Inline git info
|
||||||
|
Plug 'tribela/vim-transparent' " Transparency always
|
||||||
|
|
||||||
|
""" IDE features/LSP
|
||||||
|
Plug 'editorconfig/editorconfig-vim' " editorconfig support
|
||||||
|
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code completion
|
||||||
|
Plug 'dense-analysis/ale' " Code formatting, linting
|
||||||
|
" Plug 'neovim/nvim-lspconfig' " default language server configurations (neovim 0.5)
|
||||||
|
Plug 'dbeniamine/cheat.sh-vim' " cheat.sh
|
||||||
|
|
||||||
|
""" Smaller IDE features
|
||||||
|
Plug 'mbbill/undotree' " Undo tree
|
||||||
|
Plug 'tmsvg/pear-tree' " Quote pairing
|
||||||
|
Plug 'junegunn/vim-easy-align'
|
||||||
|
Plug 'tpope/vim-repeat' " Repeatability for various tpope plugins
|
||||||
|
Plug 'tpope/vim-surround' " Quote/parenthesis changing
|
||||||
|
Plug 'tpope/vim-sensible' " Some sensible defaults
|
||||||
|
Plug 'tpope/vim-commentary' " Comments
|
||||||
|
Plug 'tpope/vim-fugitive' " git integration
|
||||||
|
|
||||||
|
" File explorer
|
||||||
|
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||||
|
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " File type colors
|
||||||
|
Plug 'ryanoasis/vim-devicons' " File icons
|
||||||
|
Plug 'Xuyuanp/nerdtree-git-plugin' " File git status
|
||||||
|
|
||||||
|
" Misc
|
||||||
|
Plug 'junegunn/goyo.vim', {'for': 'markdown', 'on': 'Goyo'} " Minimalist writing mode
|
||||||
|
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } " Firefox nvim integration
|
||||||
|
|
||||||
|
call plug#end()
|
||||||
|
|
||||||
|
"""""""""""""""""""""""""""""" Things set as a result of plugins
|
||||||
|
""" Colors
|
||||||
|
set background=dark
|
||||||
|
if match(&runtimepath, 'doom-one') != -1
|
||||||
|
let g:doom_one_terminal_colors = v:true
|
||||||
|
colorscheme doom-one
|
||||||
|
elseif match(&runtimepath, 'one') != -1
|
||||||
|
let g:one_allow_italics = 1
|
||||||
|
colorscheme one
|
||||||
|
else
|
||||||
|
colorscheme slate
|
||||||
|
set nocursorline
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Transparency
|
||||||
|
if match(&runtimepath, 'transparent') != -1
|
||||||
|
call g:background#clear_background()
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" Airline
|
||||||
|
if match(&runtimepath, 'airline') != -1
|
||||||
|
let g:airline_powerline_fonts = 1
|
||||||
|
let g:airline_detect_spell=0 " (*YES*, I KNOW I have spell check on all the time)
|
||||||
|
let g:airline#extensions#tabline#enabled = 1
|
||||||
|
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
|
||||||
|
if match(&runtimepath, 'onedark') != -1
|
||||||
|
let g:airline_theme='onedark'
|
||||||
|
elseif match(&runtimepath, 'one') != -1
|
||||||
|
let g:airline_theme='one'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" this is the first bit of vimscript I ever wrote
|
||||||
|
function! Tabline_auto_show_hide()
|
||||||
|
let tab_count = tabpagenr("$")
|
||||||
|
if tab_count == 2
|
||||||
|
" if there is one tab
|
||||||
|
if &lines > 3
|
||||||
|
set showtabline=2
|
||||||
|
endif
|
||||||
|
" echom 'The tab bar was enabled'
|
||||||
|
elseif tab_count == 1
|
||||||
|
if &lines > 3
|
||||||
|
set showtabline=1
|
||||||
|
endif
|
||||||
|
" echom 'The tab bar was disabled'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup TablineShowHide
|
||||||
|
" autocmd! BufEnter * call Tabline_auto_show_hide()
|
||||||
|
autocmd! TabNew * call Tabline_auto_show_hide()
|
||||||
|
autocmd! TabClosed * call Tabline_auto_show_hide()
|
||||||
|
autocmd! VimEnter * call Tabline_auto_show_hide()
|
||||||
|
autocmd! User GoyoLeave * call Tabline_auto_show_hide()
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" Commentary
|
||||||
|
if match(&runtimepath, 'commentary') != -1
|
||||||
|
nnoremap <Leader>l :Commentary<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" indentline
|
||||||
|
if match(&runtimepath, 'indentline') != -1
|
||||||
|
let g:indentLine_char = '▏'
|
||||||
|
let g:indentLine_conceallevel = 1
|
||||||
|
let g:indentLine_fileTypeExclude = ['markdown']
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" CtrlP
|
||||||
|
if match(&runtimepath, 'indentline') != -1
|
||||||
|
let g:ctrlp_map = '<c-p>'
|
||||||
|
let g:ctrlp_cmd = 'CtrlP'
|
||||||
|
let g:ctrlp_working_path_mode = 'ra'
|
||||||
|
" set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*. " ignored file extensions
|
||||||
|
" let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] " Ignoer files in .gitignore's
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" Undotree
|
||||||
|
if match(&runtimepath, 'undotree') != -1
|
||||||
|
nnoremap <F5> :UndotreeToggle<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" Asynchronous Lint Engine (ALE)
|
||||||
|
" if match(&runtimepath, 'ale') != -1
|
||||||
|
" endif
|
||||||
|
|
||||||
|
""" Language server configs (not avalible yet. wait until nvim version 5)
|
||||||
|
if match(&runtimepath, 'lspconfig') != -1
|
||||||
|
" set completeopt=menuone,noinsert,noselect
|
||||||
|
" let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" Pear tree
|
||||||
|
if match(&runtimepath, 'peartree') != -1
|
||||||
|
let g:pear_tree_pairs = {
|
||||||
|
\ '(': {'closer': ')'},
|
||||||
|
\ '[': {'closer': ']'},
|
||||||
|
\ '{': {'closer': '}'},
|
||||||
|
\ "'": {'closer': "'"},
|
||||||
|
\ '"': {'closer': '"'}
|
||||||
|
\ }
|
||||||
|
" See pear-tree/after/ftplugin/ for filetype-specific matching rules
|
||||||
|
|
||||||
|
" Pear Tree is enabled for all filetypes by default:
|
||||||
|
let g:pear_tree_ft_disabled = []
|
||||||
|
|
||||||
|
" Pair expansion is dot-repeatable by default:
|
||||||
|
let g:pear_tree_repeatable_expand = 1
|
||||||
|
|
||||||
|
" Smart pairs are disabled by default:
|
||||||
|
let g:pear_tree_smart_openers = 1
|
||||||
|
let g:pear_tree_smart_closers = 1
|
||||||
|
let g:pear_tree_smart_backspace = 1
|
||||||
|
|
||||||
|
" If enabled, smart pair functions timeout after 60ms:
|
||||||
|
let g:pear_tree_timeout = 60
|
||||||
|
|
||||||
|
" Automatically map <BS>, <CR>, and <Esc>
|
||||||
|
let g:pear_tree_map_special_keys = 1
|
||||||
|
|
||||||
|
" Default mappings:
|
||||||
|
imap <BS> <Plug>(PearTreeBackspace)
|
||||||
|
imap <CR> <Plug>(PearTreeExpand)
|
||||||
|
imap <Esc> <Plug>(PearTreeFinishExpansion)
|
||||||
|
" Pear Tree also makes <Plug> mappings for each opening and closing string.
|
||||||
|
" :help <Plug>(PearTreeOpener)
|
||||||
|
" :help <Plug>(PearTreeCloser)
|
||||||
|
|
||||||
|
" Not mapped by default:
|
||||||
|
imap <Space> <Plug>(PearTreeSpace)
|
||||||
|
" <Plug>(PearTreeJump)
|
||||||
|
" <Plug>(PearTreeExpandOne)
|
||||||
|
" <Plug>(PearTreeJNR)
|
||||||
|
" End pear tree
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" Goyo
|
||||||
|
if match(&runtimepath, 'indentline') != -1
|
||||||
|
function! s:goyo_enter()
|
||||||
|
if executable('tmux') && strlen($TMUX)
|
||||||
|
silent !tmux set status off
|
||||||
|
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
|
||||||
|
endif
|
||||||
|
" silent Limelight
|
||||||
|
echo
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:goyo_leave()
|
||||||
|
if executable('tmux') && strlen($TMUX)
|
||||||
|
silent !tmux set status on
|
||||||
|
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
|
||||||
|
endif
|
||||||
|
" set showmode
|
||||||
|
" set showcmd
|
||||||
|
" set scrolloff=5
|
||||||
|
" silent Limelight!
|
||||||
|
echo
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
autocmd! User GoyoEnter nested call <SID>goyo_enter()
|
||||||
|
autocmd! User GoyoLeave nested call <SID>goyo_leave()
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" Treesitter
|
||||||
|
if match(&runtimepath, 'treesitter') != -1
|
||||||
|
lua << EOF
|
||||||
|
require'nvim-treesitter.configs'.setup {
|
||||||
|
ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||||
|
--ignore_install = { "javascript", "java" }, -- List of parsers to ignore installing
|
||||||
|
highlight = {
|
||||||
|
enable = true, -- false will disable the whole extension
|
||||||
|
-- disable = { "c", "rust" }, -- list of language that will be disabled
|
||||||
|
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||||
|
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||||
|
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||||
|
-- Instead of true it can also be a list of languages
|
||||||
|
additional_vim_regex_highlighting = true,
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
enable = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
endif
|
||||||
|
|
||||||
|
""" CoC
|
||||||
|
if match(&runtimepath, 'coc') != -1
|
||||||
|
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
|
||||||
|
" unicode characters in the file autoload/float.vim
|
||||||
|
set encoding=utf-8
|
||||||
|
|
||||||
|
" TextEdit might fail if hidden is not set.
|
||||||
|
set hidden
|
||||||
|
|
||||||
|
" Some servers have issues with backup files, see #649.
|
||||||
|
set nobackup
|
||||||
|
set nowritebackup
|
||||||
|
|
||||||
|
" Give more space for displaying messages.
|
||||||
|
set cmdheight=1
|
||||||
|
|
||||||
|
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||||
|
" delays and poor user experience.
|
||||||
|
set updatetime=300
|
||||||
|
|
||||||
|
" Don't pass messages to |ins-completion-menu|.
|
||||||
|
set shortmess+=c
|
||||||
|
|
||||||
|
" Always show the signcolumn, otherwise it would shift the text each time
|
||||||
|
" diagnostics appear/become resolved.
|
||||||
|
if has("patch-8.1.1564")
|
||||||
|
" Recently vim can merge signcolumn and number column into one
|
||||||
|
set signcolumn=number
|
||||||
|
else
|
||||||
|
set signcolumn=yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Use tab for trigger completion with characters ahead and navigate.
|
||||||
|
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||||
|
" other plugin before putting this into your config.
|
||||||
|
inoremap <silent><expr> <TAB>
|
||||||
|
\ pumvisible() ? "\<C-n>" :
|
||||||
|
\ <SID>check_back_space() ? "\<TAB>" :
|
||||||
|
\ coc#refresh()
|
||||||
|
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||||
|
|
||||||
|
function! s:check_back_space() abort
|
||||||
|
let col = col('.') - 1
|
||||||
|
return !col || getline('.')[col - 1] =~# '\s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Use <c-space> to trigger completion.
|
||||||
|
if has('nvim')
|
||||||
|
inoremap <silent><expr> <c-space> coc#refresh()
|
||||||
|
else
|
||||||
|
inoremap <silent><expr> <c-@> coc#refresh()
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Make <CR> auto-select the first completion item and notify coc.nvim to
|
||||||
|
" format on enter, <cr> could be remapped by other vim plugin
|
||||||
|
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||||
|
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||||
|
|
||||||
|
" Use `[g` and `]g` to navigate diagnostics
|
||||||
|
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||||
|
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||||
|
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||||
|
|
||||||
|
" GoTo code navigation.
|
||||||
|
nmap <silent> gd <Plug>(coc-definition)
|
||||||
|
nmap <silent> gy <Plug>(coc-type-definition)
|
||||||
|
nmap <silent> gi <Plug>(coc-implementation)
|
||||||
|
nmap <silent> gr <Plug>(coc-references)
|
||||||
|
|
||||||
|
" Use K to show documentation in preview window.
|
||||||
|
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||||
|
|
||||||
|
function! s:show_documentation()
|
||||||
|
if (index(['vim','help'], &filetype) >= 0)
|
||||||
|
execute 'h '.expand('<cword>')
|
||||||
|
elseif (coc#rpc#ready())
|
||||||
|
call CocActionAsync('doHover')
|
||||||
|
else
|
||||||
|
execute '!' . &keywordprg . " " . expand('<cword>')
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Highlight the symbol and its references when holding the cursor.
|
||||||
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||||
|
|
||||||
|
" Symbol renaming.
|
||||||
|
nmap <leader>rn <Plug>(coc-rename)
|
||||||
|
|
||||||
|
" Formatting selected code.
|
||||||
|
xmap <leader>f <Plug>(coc-format-selected)
|
||||||
|
nmap <leader>f <Plug>(coc-format-selected)
|
||||||
|
|
||||||
|
augroup mygroup
|
||||||
|
autocmd!
|
||||||
|
" Setup formatexpr specified filetype(s).
|
||||||
|
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
|
||||||
|
" Update signature help on jump placeholder.
|
||||||
|
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||||
|
augroup end
|
||||||
|
|
||||||
|
" Applying codeAction to the selected region.
|
||||||
|
" Example: `<leader>aap` for current paragraph
|
||||||
|
xmap <leader>a <Plug>(coc-codeaction-selected)
|
||||||
|
nmap <leader>a <Plug>(coc-codeaction-selected)
|
||||||
|
|
||||||
|
" Remap keys for applying codeAction to the current buffer.
|
||||||
|
nmap <leader>ac <Plug>(coc-codeaction)
|
||||||
|
" Apply AutoFix to problem on the current line.
|
||||||
|
nmap <leader>qf <Plug>(coc-fix-current)
|
||||||
|
|
||||||
|
" Map function and class text objects
|
||||||
|
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
|
||||||
|
xmap if <Plug>(coc-funcobj-i)
|
||||||
|
omap if <Plug>(coc-funcobj-i)
|
||||||
|
xmap af <Plug>(coc-funcobj-a)
|
||||||
|
omap af <Plug>(coc-funcobj-a)
|
||||||
|
xmap ic <Plug>(coc-classobj-i)
|
||||||
|
omap ic <Plug>(coc-classobj-i)
|
||||||
|
xmap ac <Plug>(coc-classobj-a)
|
||||||
|
omap ac <Plug>(coc-classobj-a)
|
||||||
|
|
||||||
|
" Remap <C-f> and <C-b> for scroll float windows/popups.
|
||||||
|
if has('nvim-0.4.0') || has('patch-8.2.0750')
|
||||||
|
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||||
|
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||||
|
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
||||||
|
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
||||||
|
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||||
|
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Use CTRL-S for selections ranges.
|
||||||
|
" Requires 'textDocument/selectionRange' support of language server.
|
||||||
|
nmap <silent> <C-s> <Plug>(coc-range-select)
|
||||||
|
xmap <silent> <C-s> <Plug>(coc-range-select)
|
||||||
|
|
||||||
|
" Add `:Format` command to format current buffer.
|
||||||
|
command! -nargs=0 Format :call CocAction('format')
|
||||||
|
|
||||||
|
" Add `:Fold` command to fold current buffer.
|
||||||
|
command! -nargs=? Fold :call CocAction('fold', <f-args>)
|
||||||
|
|
||||||
|
" Add `:OR` command for organize imports of the current buffer.
|
||||||
|
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
|
||||||
|
|
||||||
|
" Add (Neo)Vim's native statusline support.
|
||||||
|
" NOTE: Please see `:h coc-status` for integrations with external plugins that
|
||||||
|
" provide custom statusline: lightline.vim, vim-airline.
|
||||||
|
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
|
||||||
|
|
||||||
|
" Mappings for CoCList
|
||||||
|
" Show all diagnostics.
|
||||||
|
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
|
||||||
|
" Manage extensions.
|
||||||
|
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
|
||||||
|
" Show commands.
|
||||||
|
nnoremap <silent><nowait> <space>C :<C-u>CocList commands<cr>
|
||||||
|
" Find symbol of current document.
|
||||||
|
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
|
||||||
|
" Search workspace symbols.
|
||||||
|
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
|
||||||
|
" Do default action for next item.
|
||||||
|
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
|
||||||
|
" Do default action for previous item.
|
||||||
|
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
|
||||||
|
" Resume latest coc list.
|
||||||
|
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
|
||||||
|
endif
|
||||||
|
"""""""""""""""""""""""""""" END Plugin-dependent settings
|
11
.gitconfig
Normal file
11
.gitconfig
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[credential]
|
||||||
|
helper = store
|
||||||
|
[user]
|
||||||
|
email = blakelysnorth@gmail.com
|
||||||
|
name = PowerUser64
|
||||||
|
[alias]
|
||||||
|
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
|
||||||
|
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
|
||||||
|
lg = !"git lg1"
|
||||||
|
tree = !"git lg1"
|
||||||
|
|
534
.zshrc
Normal file
534
.zshrc
Normal file
|
@ -0,0 +1,534 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# Blake's ZSH config file
|
||||||
|
|
||||||
|
# vim:fdm=marker:fmr=>>>,<<<:expandtab:sw=3
|
||||||
|
|
||||||
|
### Basic shell configuration >>>
|
||||||
|
### Environment variables >>>
|
||||||
|
{
|
||||||
|
# [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/envrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/envrc"
|
||||||
|
# Intelligently set $EDITOR
|
||||||
|
if command -v nvim > /dev/null;then
|
||||||
|
export EDITOR=nvim
|
||||||
|
elif command -v vim > /dev/null;then
|
||||||
|
export EDITOR=vim
|
||||||
|
elif command -v vi > /dev/null;then
|
||||||
|
export EDITOR=vi
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PATH="$PATH:${XDG_DATA_HOME:-$HOME/.local/bin}"
|
||||||
|
export SYSTEMD_EDITOR="$EDITOR"
|
||||||
|
# Plugin setting >>>
|
||||||
|
{
|
||||||
|
# ZSH Vi Mode
|
||||||
|
ZVM_VI_HIGHLIGHT_FOREGROUND=#BBC2CF
|
||||||
|
ZVM_VI_HIGHLIGHT_BACKGROUND=#515860
|
||||||
|
# ZVM_VI_HIGHLIGHT_EXTRASTYLE=bold,underline # bold and underline
|
||||||
|
|
||||||
|
# OMZ Completion
|
||||||
|
COMPLETION_WAITING_DOTS=true
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
### Aliases >>>
|
||||||
|
{
|
||||||
|
# [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc"
|
||||||
|
## Short hand programs (ex: sc = shellcheck) >>>
|
||||||
|
# use nvim rather than vim if the command exists
|
||||||
|
[ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d"
|
||||||
|
|
||||||
|
# I do this too much by accident smh my head
|
||||||
|
alias ':q'='exit' \
|
||||||
|
q='exit' \
|
||||||
|
alias vim=nvim
|
||||||
|
alias sc=shellcheck
|
||||||
|
# rmdir is long
|
||||||
|
alias \
|
||||||
|
rmd='rmdir' \
|
||||||
|
rd='rmdir' \
|
||||||
|
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
## Program improvements (ex: ls = ls -h) >>>
|
||||||
|
alias df='df -h' # Human-readable sizes
|
||||||
|
alias free='free -m' # Show sizes in MB
|
||||||
|
alias tm='tmux new -As0' # open a new session called 0, but if there is already a session called 0, connect to it
|
||||||
|
alias bc="bc -ql" # Make bc usable for fast math
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
alias \
|
||||||
|
ls="ls -hN --color=auto --group-directories-first" \
|
||||||
|
grep="grep --color=auto" \
|
||||||
|
diff="diff --color=auto" \
|
||||||
|
ccat="highlight --out-format=ansi" \
|
||||||
|
pacman="pacman --color=auto" \
|
||||||
|
paru="paru --color=auto" \
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
## Mini short-hand scripts (ex: la = ls -a) >>>
|
||||||
|
# dotfile management
|
||||||
|
alias dot='git --git-dir="/home/blake/git/dotfiles" --work-tree="$HOME"'
|
||||||
|
|
||||||
|
# Edit config files
|
||||||
|
alias \
|
||||||
|
vimrc="$EDITOR ~/.config/nvim/init.vim" \
|
||||||
|
zshrc="$EDITOR ~/.zshrc" \
|
||||||
|
todo="$EDITOR ~/todo.md"
|
||||||
|
fstab="sudo $EDITOR /etc/fstab" \
|
||||||
|
|
||||||
|
# Git cLONE
|
||||||
|
alias glone="git clone"
|
||||||
|
|
||||||
|
# random number generation
|
||||||
|
alias \
|
||||||
|
rnd="echo 'Use the the shuf command:' && echo 'shuf --random-source=\"/dev/random\" -i (range, ex: 0-9) -n (number of random numbers)'" \
|
||||||
|
rand=rnd
|
||||||
|
|
||||||
|
# Graphical
|
||||||
|
alias \
|
||||||
|
restart-gnome='killall -SIGQUIT gnome-shell' \
|
||||||
|
guh='guake --hide' \
|
||||||
|
gus='guake --show' \
|
||||||
|
lsx='ls /tmp/.X11-unix | tr "X" ":"' \
|
||||||
|
|
||||||
|
# tar is a dumb program...
|
||||||
|
alias \
|
||||||
|
tarc='tar -c --use-compress-program=pigz -f' \
|
||||||
|
tarx='echo -e "Please use the ext script (https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/ext)\nor look here for more information: https://www.cyberciti.biz/faq/tar-extract-linux"' \
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
alias \
|
||||||
|
logs='docker-compose logs --tail=200 -f' \
|
||||||
|
dupd='docker-compose up -d' \
|
||||||
|
ddwn='docker-compose down' \
|
||||||
|
occ='docker exec -it -u www-data nextcloud php occ' \
|
||||||
|
|
||||||
|
# backs up list of packages
|
||||||
|
alias packback='comm -23 <(paru -Qqett | sort) <(paru -Qqg base -g base-devel | sort | uniq) > ~/pkglist.txt'
|
||||||
|
|
||||||
|
# smart plug things
|
||||||
|
SMART_PLUG_IP='192.168.1.250'
|
||||||
|
alias l='tplink_smartplug.py -t $SMART_PLUG_IP -c'
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
alias \
|
||||||
|
la='ls -ah' \
|
||||||
|
ll='ls -lh' \
|
||||||
|
lla='ls -lah' \
|
||||||
|
|
||||||
|
# find pretty much any file, quickly
|
||||||
|
alias fds='fd --hidden -E /run'
|
||||||
|
# <<<
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
### Functions >>>
|
||||||
|
{
|
||||||
|
# [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc"
|
||||||
|
|
||||||
|
sitepath() {
|
||||||
|
# usage: sitepath <path to file>
|
||||||
|
# usage: sitepath <file to find>
|
||||||
|
# usage: sitepath
|
||||||
|
|
||||||
|
# If there is no input, make the input be the current directory
|
||||||
|
[ -z ${1+x} ] && 1="$(pwd)"
|
||||||
|
FILEPATH="$(([ -e "$1" ] && readlink -f "$1") || fd "$1" /home/blake/docker/blakenorth.net/site)"
|
||||||
|
|
||||||
|
echo "$FILEPATH" | grep -o 'site.*' | sed 's+^site+https://blakenorth.net+g'
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
ERROR_CODE="$?"
|
||||||
|
>&2 echo "An error occurred within a function in the .zshrc on line number ${1}"
|
||||||
|
exit $ERROR_CODE
|
||||||
|
}
|
||||||
|
|
||||||
|
# prcolors and prcolors256: print all colors >>>
|
||||||
|
# Taken from base16shell
|
||||||
|
prcolors1() {
|
||||||
|
ansi_mappings=(
|
||||||
|
Black Red
|
||||||
|
Green Yellow
|
||||||
|
Blue Magenta
|
||||||
|
Cyan White
|
||||||
|
Bright_Black Bright_Red
|
||||||
|
Bright_Green Bright_Yellow
|
||||||
|
Bright_Blue Bright_Magenta
|
||||||
|
Bright_Cyan Bright_White
|
||||||
|
)
|
||||||
|
colors=(
|
||||||
|
base00 base08
|
||||||
|
base0B base0A
|
||||||
|
base0D base0E
|
||||||
|
base0C base05
|
||||||
|
base03 base08
|
||||||
|
base0B base0A
|
||||||
|
base0D base0E
|
||||||
|
base0C base07
|
||||||
|
base09 base0F
|
||||||
|
base01 base02
|
||||||
|
base04 base06
|
||||||
|
)
|
||||||
|
for padded_value in `seq -w 0 21`; do
|
||||||
|
color_variable="color${padded_value}"
|
||||||
|
eval current_color=\$${color_variable}
|
||||||
|
current_color=$(echo ${current_color//\//} | tr '[:lower:]' '[:upper:]') # get rid of slashes, and uppercase
|
||||||
|
non_padded_value=$((10#$padded_value))
|
||||||
|
base16_color_name=${colors[$non_padded_value]}
|
||||||
|
current_color_label=${current_color:-unknown}
|
||||||
|
ansi_label=${ansi_mappings[$non_padded_value]}
|
||||||
|
block=$(printf "\x1b[48;5;${non_padded_value}m___________________________")
|
||||||
|
foreground=$(printf "\x1b[38;5;${non_padded_value}m$color_variable")
|
||||||
|
printf "%s %s %s %-30s %s\x1b[0m\n" $foreground $base16_color_name $current_color_label ${ansi_label:-""} $block
|
||||||
|
done;
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
printf "To restore current theme, source ~/.base16_theme or reopen your terminal\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Taken from manjaro's bashrc
|
||||||
|
prcolors2() {
|
||||||
|
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"
|
||||||
|
|
||||||
|
# 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%%;}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Similar to above, but does 256-bit colors. Taken from this: https://github.com/romkatv/powerlevel10k#set-colors-through-Powerlevel10k-configuration-parameters
|
||||||
|
prcolors256() {
|
||||||
|
for i in {0..255}; do
|
||||||
|
print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
mkcd() {
|
||||||
|
mkdir -p "$1" || error $LINENO
|
||||||
|
cd "$1" || error $LINENO
|
||||||
|
}
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
random-mac() {
|
||||||
|
interfaces=(enp5s0 wlp4s0)
|
||||||
|
for interface in "${interfaces[@]}";do
|
||||||
|
echo " Changing interface: $interface"
|
||||||
|
sudo ip link set dev $interface down
|
||||||
|
sudo macchanger -r $interface
|
||||||
|
sudo ip link set dev $interface up
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Git cLONE cD
|
||||||
|
gloned() {
|
||||||
|
git clone "$1"
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
cd "$(echo "$1" | rev | cut -d '/' -f 1 | rev)" || (echo 'Error: Could not `cd` into the repo' && exit) || exit
|
||||||
|
}
|
||||||
|
|
||||||
|
calc() {
|
||||||
|
echo $(($*))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
# <<<
|
||||||
|
### Plugins >>>
|
||||||
|
{
|
||||||
|
# p10k instant prompt >>>
|
||||||
|
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
|
||||||
|
# <<<
|
||||||
|
# Load zinit >>>
|
||||||
|
{
|
||||||
|
# Install zinit if not installed
|
||||||
|
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
|
||||||
|
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f"
|
||||||
|
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
|
||||||
|
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
|
||||||
|
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
|
||||||
|
print -P "%F{160}▓▒░ The clone has failed.%f%b"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source zinit
|
||||||
|
source "$HOME/.zinit/bin/zinit.zsh"
|
||||||
|
autoload -Uz _zinit
|
||||||
|
(( ${+_comps} )) && _comps[zinit]=_zinit
|
||||||
|
|
||||||
|
# Load a few important annexes, without Turbo
|
||||||
|
# (this is currently required for annexes)
|
||||||
|
zinit light-mode for \
|
||||||
|
zinit-zsh/z-a-rust \
|
||||||
|
zinit-zsh/z-a-as-monitor \
|
||||||
|
zinit-zsh/z-a-patch-dl \
|
||||||
|
zinit-zsh/z-a-bin-gem-node
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
# Plugins to install >>>
|
||||||
|
{
|
||||||
|
zinit ice wait'!0' # Enable turbo mode
|
||||||
|
zinit ice depth"1" # git clone depth
|
||||||
|
zinit snippet OMZ::lib/history.zsh
|
||||||
|
# Some better completion options
|
||||||
|
zinit snippet OMZ::lib/completion.zsh
|
||||||
|
|
||||||
|
# Quality of life
|
||||||
|
zinit load "zsh-users/zsh-autosuggestions"
|
||||||
|
zinit load "zdharma/fast-syntax-highlighting"
|
||||||
|
zinit load "jeffreytse/zsh-vi-mode"
|
||||||
|
zinit load "zsh-users/zsh-history-substring-search"
|
||||||
|
zinit load "zsh-users/zsh-completions"
|
||||||
|
|
||||||
|
# Themes
|
||||||
|
# zplug "themes/robbyrussell", from:oh-my-zsh, as:theme
|
||||||
|
zinit snippet 'https://github.com/chriskempson/base16-shell/blob/master/scripts/base16-onedark.sh' # onedark shell colors
|
||||||
|
zinit load "romkatv/powerlevel10k"
|
||||||
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
### General ZSH configuration >>>
|
||||||
|
# This section is (mostly) From manjaro's "manjaro-zsh-config" (/usr/share/zsh/manjaro-zsh-config) #
|
||||||
|
|
||||||
|
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
|
||||||
|
|
||||||
|
## ZSH Options (opening this fold causes lag in vim for some reason) >>>
|
||||||
|
{
|
||||||
|
# setopt correct # Auto correct mistakes
|
||||||
|
setopt extendedglob # Extended globbing. Allows using regular expressions with *
|
||||||
|
setopt nocaseglob # Case insensitive globbing
|
||||||
|
setopt rcexpandparam # Array expension with parameters
|
||||||
|
setopt checkjobs # Warn about running processes when exiting
|
||||||
|
setopt numericglobsort # Sort filenames numerically when it makes sense
|
||||||
|
setopt nobeep # Most important option
|
||||||
|
setopt appendhistory # Immediately append history instead of overwriting
|
||||||
|
setopt inc_append_history # save commands are added to the history immediately, otherwise only when shell exits.
|
||||||
|
setopt histfindnodups # If a new command is a duplicate, remove the older one
|
||||||
|
setopt histignorealldups # If a new command is a duplicate, remove the older one
|
||||||
|
setopt autocd # if only directory path is entered, cd there.
|
||||||
|
setopt interactive_comments # allow typing comments in line
|
||||||
|
setopt no_rm_star_silent # Ensure the user wants to execute 'rm *'
|
||||||
|
setopt rm_star_wait # Wait before accepting 'rm *' or 'rm /path/*'
|
||||||
|
setopt short_loops # allow things like 'if [ 1=1 ] { echo "okay"}' < https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Alternate-Forms-For-Complex-Commands
|
||||||
|
setopt pipe_fail # When a pipe fails, show the non-0 exit code for the exit code
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
## ZSH Completion Options >>>
|
||||||
|
{
|
||||||
|
# Mine
|
||||||
|
zstyle ':completion:*' completer _expand _complete _ignored _prefix
|
||||||
|
zstyle ':completion:*' expand prefix suffix
|
||||||
|
zstyle ':completion:*' file-sort access
|
||||||
|
zstyle ':completion:*' ignore-parents parent pwd directory
|
||||||
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||||
|
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
|
||||||
|
zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=** r:|=**'
|
||||||
|
zstyle ':completion:*' menu select=long
|
||||||
|
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
||||||
|
zstyle :compinstall filename '/home/blake/.zshrc'
|
||||||
|
|
||||||
|
# Manjaro's
|
||||||
|
# zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive tab completion
|
||||||
|
# zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc)
|
||||||
|
# zstyle ':completion:*' rehash true # automatically find new executables in path
|
||||||
|
# # Speed up completions
|
||||||
|
zstyle ':completion:*' accept-exact '*(N)'
|
||||||
|
zstyle ':completion:*' use-cache on
|
||||||
|
zstyle ':completion:*' cache-path $ZSH_CACHE_DIR
|
||||||
|
WORDCHARS=${WORDCHARS//\/[&.;]} # Don't consider certain characters part of the word
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
## Keybindings >>>
|
||||||
|
bindkey -v # Enable Vi mode
|
||||||
|
bindkey '^[[7~' beginning-of-line # Home key
|
||||||
|
bindkey '^[[H' beginning-of-line # Home key
|
||||||
|
if [[ "${terminfo[khome]}" != "" ]]; then
|
||||||
|
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
|
||||||
|
fi
|
||||||
|
bindkey '^[[8~' end-of-line # End key
|
||||||
|
bindkey '^[[F' end-of-line # End key
|
||||||
|
if [[ "${terminfo[kend]}" != "" ]]; then
|
||||||
|
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
|
||||||
|
fi
|
||||||
|
bindkey '^[[2~' overwrite-mode # Insert key
|
||||||
|
bindkey '^[[3~' delete-char # Delete key
|
||||||
|
bindkey '^[[C' forward-char # Right key
|
||||||
|
bindkey '^[[D' backward-char # Left key
|
||||||
|
bindkey '^[[5~' history-beginning-search-backward # Page up key
|
||||||
|
bindkey '^[[6~' history-beginning-search-forward # Page down key
|
||||||
|
|
||||||
|
# Navigate words with ctrl+arrow keys
|
||||||
|
bindkey '^[Oc' forward-word #
|
||||||
|
bindkey '^[Od' backward-word #
|
||||||
|
bindkey '^[[1;5D' backward-word #
|
||||||
|
bindkey '^[[1;5C' forward-word #
|
||||||
|
bindkey '^H' backward-kill-word # delete previous word with ctrl+backspace
|
||||||
|
bindkey '^[[3;5~' kill-word # delete next word with ctrl+delete
|
||||||
|
bindkey '^[[Z' undo # Shift+tab undo last action
|
||||||
|
|
||||||
|
# bind UP and DOWN arrow keys to history substring search
|
||||||
|
zmodload zsh/terminfo
|
||||||
|
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
||||||
|
bindkey "$terminfo[kcud1]" history-substring-search-down
|
||||||
|
bindkey '^[[A' history-substring-search-up
|
||||||
|
bindkey '^[[B' history-substring-search-down
|
||||||
|
bindkey -M vicmd 'k' history-substring-search-up
|
||||||
|
bindkey -M vicmd 'j' history-substring-search-down
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
autoload -U compinit colors zcalc
|
||||||
|
compinit -d
|
||||||
|
colors
|
||||||
|
|
||||||
|
# Color man pages >>>
|
||||||
|
export LESS_TERMCAP_mb=$'\E[01;32m'
|
||||||
|
export LESS_TERMCAP_md=$'\E[01;32m'
|
||||||
|
export LESS_TERMCAP_me=$'\E[0m'
|
||||||
|
export LESS_TERMCAP_se=$'\E[0m'
|
||||||
|
export LESS_TERMCAP_so=$'\E[01;47;34m'
|
||||||
|
export LESS_TERMCAP_ue=$'\E[0m'
|
||||||
|
export LESS_TERMCAP_us=$'\E[01;36m'
|
||||||
|
export LESS=-R
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
# Offer to install missing package if command is not found >>>
|
||||||
|
# if [[ -r /usr/share/zsh/functions/command-not-found.zsh ]]; then
|
||||||
|
# source /usr/share/zsh/functions/command-not-found.zsh
|
||||||
|
# export PKGFILE_PROMPT_INSTALL_MISSING=1
|
||||||
|
# fi
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
### Various manjaro ZSH functions >>>
|
||||||
|
|
||||||
|
# Set terminal window and tab/icon title
|
||||||
|
# usage: title short_tab_title [long_window_title]
|
||||||
|
# >>>
|
||||||
|
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
||||||
|
# Fully supports screen and probably most modern xterm and rxvt
|
||||||
|
# (In screen, only short_tab_title is used)
|
||||||
|
function title {
|
||||||
|
emulate -L zsh
|
||||||
|
setopt prompt_subst
|
||||||
|
|
||||||
|
[[ "$EMACS" == *term* ]] && return
|
||||||
|
|
||||||
|
# if $2 is unset use $1 as default
|
||||||
|
# if it is set and empty, leave it as is
|
||||||
|
: ${2=$1}
|
||||||
|
|
||||||
|
case "$TERM" in
|
||||||
|
xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
|
||||||
|
print -Pn "\e]2;${2:q}\a" # set window name
|
||||||
|
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||||
|
;;
|
||||||
|
screen*|tmux*)
|
||||||
|
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Try to use terminfo to set the title
|
||||||
|
# If the feature is available set title
|
||||||
|
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
|
||||||
|
echoti tsl
|
||||||
|
print -Pn "$1"
|
||||||
|
echoti fsl
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" # 15 char left truncated PWD
|
||||||
|
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
||||||
|
|
||||||
|
# Runs before showing the prompt
|
||||||
|
function mzc_termsupport_precmd {
|
||||||
|
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||||
|
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
||||||
|
}
|
||||||
|
|
||||||
|
# Runs before executing the command
|
||||||
|
# >>>
|
||||||
|
function mzc_termsupport_preexec {
|
||||||
|
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||||
|
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
# split command into array of arguments
|
||||||
|
local -a cmdargs
|
||||||
|
cmdargs=("${(z)2}") # " <- syntax highlighting fix
|
||||||
|
|
||||||
|
# if running fg, extract the command from the job description
|
||||||
|
if [[ "${cmdargs[1]}" = fg ]]; then
|
||||||
|
# get the job id from the first argument passed to the fg command
|
||||||
|
local job_id jobspec="${cmdargs[2]#%}"
|
||||||
|
# logic based on jobs arguments:
|
||||||
|
# http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs
|
||||||
|
# https://www.zsh.org/mla/users/2007/msg00704.html
|
||||||
|
case "$jobspec" in
|
||||||
|
<->) # %number argument:
|
||||||
|
# use the same <number> passed as an argument
|
||||||
|
job_id=${jobspec} ;;
|
||||||
|
""|%|+) # empty, %% or %+ argument:
|
||||||
|
# use the current job, which appears with a + in $jobstates:
|
||||||
|
# suspended:+:5071=suspended (tty output)
|
||||||
|
job_id=${(k)jobstates[(r)*:+:*]} ;;
|
||||||
|
-) # %- argument:
|
||||||
|
# use the previous job, which appears with a - in $jobstates:
|
||||||
|
# suspended:-:6493=suspended (signal)
|
||||||
|
job_id=${(k)jobstates[(r)*:-:*]} ;;
|
||||||
|
[?]*) # %?string argument:
|
||||||
|
# use $jobtexts to match for a job whose command *contains* <string>
|
||||||
|
job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;;
|
||||||
|
*) # %string argument:
|
||||||
|
# use $jobtexts to match for a job whose command *starts with* <string>
|
||||||
|
job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# override preexec function arguments with job command
|
||||||
|
if [[ -n "${jobtexts[$job_id]}" ]]; then
|
||||||
|
1="${jobtexts[$job_id]}"
|
||||||
|
2="${jobtexts[$job_id]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# cmd name only, or if this is sudo or ssh, the next cmd
|
||||||
|
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
|
||||||
|
local LINE="${2:gs/%/%%}"
|
||||||
|
|
||||||
|
title '$CMD' '%100>...>$LINE%<<'
|
||||||
|
}
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
add-zsh-hook precmd mzc_termsupport_precmd
|
||||||
|
add-zsh-hook preexec mzc_termsupport_preexec
|
||||||
|
# <<<
|
||||||
|
# <<<
|
||||||
|
|
||||||
|
# Optionally source the user's customized .zshrc
|
||||||
|
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshrc.local" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshrc.local"
|
||||||
|
|
Loading…
Add table
Reference in a new issue