├── .aliases ├── .bash_logout ├── .bash_profile ├── .bashrc ├── .config └── nvim │ ├── coc-settings.json │ ├── coc.vim │ ├── init-neo.vim │ └── init.vim ├── .env ├── .fasdrc ├── .gitconfig ├── .gitignore ├── .gitmodules ├── .ignore ├── .inputrc ├── .logout ├── .pythonrc.py ├── .screenrc ├── .shenv ├── .tmux.conf ├── .vim ├── autoload │ └── plug.vim └── coc-settings.json ├── .vimpagerrc ├── .vimrc ├── .vimrc.common ├── .zlogout ├── .zsh ├── aliases.zsh ├── bindkey.zsh ├── completion.zsh ├── options.zsh ├── prompt.zsh └── terminal.zsh ├── .zshenv ├── .zshrc └── bin ├── fasd ├── m2t ├── quiz ├── test-nt ├── test-ot ├── vimpager └── wman /.aliases: -------------------------------------------------------------------------------- 1 | # GNU ls color 2 | ls --color=auto > /dev/null 2>&1 && alias ls='ls --color=auto' 3 | 4 | # Only some grep supports `--color=auto' 5 | if echo x | grep --color=auto x >/dev/null 2>&1; then 6 | alias grep='grep --color=auto' 7 | alias fgrep='fgrep --color=auto' 8 | alias egrep='egrep --color=auto' 9 | fi 10 | 11 | alias ll='ls -halF' 12 | alias la='ls -A' 13 | alias l='ls -CF' 14 | alias lt='ls -t' 15 | alias lS='ls -S' 16 | 17 | alias df='df -h' 18 | alias du='du -h' 19 | 20 | { if ! command -v open; then 21 | command -v xdg-open && alias open='xdg-open' 22 | command -v explorer.exe && alias open='explorer.exe' 23 | fi } >/dev/null 24 | 25 | { if command -v nvim; then 26 | alias nv='nvim' 27 | fi } >/dev/null 28 | 29 | { if command -v powershell.exe; then 30 | alias win='powershell.exe' 31 | fi } >/dev/null 32 | 33 | command -v free > /dev/null && \ 34 | alias free='free -h' 35 | 36 | alias ..='cd ..' 37 | 38 | alias e='f -e vim' 39 | alias v='f -t -e vim -b viminfo' 40 | alias o='f -e open' 41 | 42 | [ -s "$HOME/.aliases.local" ] && . "$HOME/.aliases.local" 43 | 44 | # vim: se ft=sh: 45 | -------------------------------------------------------------------------------- /.bash_logout: -------------------------------------------------------------------------------- 1 | source "$HOME/.logout" 2 | -------------------------------------------------------------------------------- /.bash_profile: -------------------------------------------------------------------------------- 1 | [ -s "$HOME/.bashrc" ] && source "$HOME/.bashrc" 2 | -------------------------------------------------------------------------------- /.bashrc: -------------------------------------------------------------------------------- 1 | case $- in 2 | *i*) ;; 3 | *) return;; 4 | esac 5 | 6 | HISTCONTROL=ignoreboth:erasedupes 7 | shopt -s histappend 8 | shopt -s checkwinsize 9 | HISTSIZE=1000 10 | HISTFILESIZE=2000 11 | 12 | PS1='\[\e[0;32m\][\u \h] \[\e[0;33m\][\W$(_gb)] \[\e[0;31m\]\$\[\e[39m\] ' 13 | 14 | if shopt -oq posix; then :; else 15 | if [ -s /etc/bash_completion ]; then 16 | . /etc/bash_completion 17 | elif [ -s /usr/local/etc/bash_completion ]; then 18 | . /usr/local/etc/bash_completion 19 | fi 20 | fi 21 | 22 | [ -s "$HOME/.shenv" ] && source "$HOME/.shenv" 23 | [ -s "$HOME/.aliases" ] && source "$HOME/.aliases" 24 | 25 | FASD_CACHE="$HOME/.fasd-init-bash" 26 | 27 | if [ "$(which fasd)" -nt "$FASD_CACHE" -o ! -f "$FASD_CACHE" ]; then 28 | fasd --init posix-alias bash-{hook,ccomp,ccomp-install} >| "$FASD_CACHE" 29 | fi 30 | 31 | source "$FASD_CACHE" 32 | 33 | _fasd_bash_hook_cmd_complete z e m 34 | 35 | [ -s "$HOME/.bashrc.local" ] && source "$HOME/.bashrc.local" 36 | 37 | -------------------------------------------------------------------------------- /.config/nvim/coc-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "list.normalMappings": { 3 | "q": "do:exit" 4 | }, 5 | "suggest.noselect": true 6 | } 7 | -------------------------------------------------------------------------------- /.config/nvim/coc.vim: -------------------------------------------------------------------------------- 1 | " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable 2 | " delays and poor user experience. 3 | set updatetime=300 4 | 5 | " Avoid showing extra messages when using completion 6 | set shortmess+=c 7 | 8 | " Always show the signcolumn, otherwise it would shift the text each time 9 | " diagnostics appear/become resolved. 10 | if has("nvim-0.5.0") || has("patch-8.1.1564") 11 | " Recently vim can merge signcolumn and number column into one 12 | set signcolumn=number 13 | else 14 | set signcolumn=yes 15 | endif 16 | 17 | " Use tab for trigger completion with characters ahead and navigate. 18 | " NOTE: There's always complete item selected by default, you may want to enable 19 | " no select by `"suggest.noselect": true` in your configuration file. 20 | " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by 21 | " other plugin before putting this into your config. 22 | inoremap 23 | \ coc#pum#visible() ? coc#pum#next(1) : 24 | \ CheckBackspace() ? "\" : 25 | \ coc#refresh() 26 | inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" 27 | 28 | " Make to accept selected completion item or notify coc.nvim to format 29 | " u breaks current undo, please make your own choice. 30 | inoremap coc#pum#visible() ? coc#pum#confirm() 31 | \: "\u\\=coc#on_enter()\" 32 | 33 | function! CheckBackspace() abort 34 | let col = col('.') - 1 35 | return !col || getline('.')[col - 1] =~# '\s' 36 | endfunction 37 | 38 | " Use to trigger completion. 39 | if has('nvim') 40 | inoremap coc#refresh() 41 | else 42 | inoremap coc#refresh() 43 | endif 44 | 45 | " Make auto-select the first completion item and notify coc.nvim to 46 | " format on enter, could be remapped by other vim plugin 47 | " Play well with endwise: https://github.com/tpope/vim-endwise/issues/125#issuecomment-743921576 48 | " 49 | inoremap =coc_confirm() 50 | function! s:coc_confirm() abort 51 | if pumvisible() && complete_info()["selected"] >= 0 52 | return coc#_select_confirm() 53 | else 54 | return "\u\\=coc#on_enter()\" 55 | endif 56 | endfunction 57 | 58 | " Goto previous/next diagnostic warning/error 59 | nmap [d (coc-diagnostic-prev) 60 | nmap ]d (coc-diagnostic-next) 61 | 62 | " Goto previous/next diagnostic error 63 | nmap [e (coc-diagnostic-prev-error) 64 | nmap ]e (coc-diagnostic-next-error) 65 | 66 | " Code navigation 67 | nmap gd (coc-definition) 68 | nmap gD (coc-declaration) 69 | nmap gy (coc-type-definition) 70 | nmap gi (coc-implementation) 71 | nmap gr (coc-references) 72 | 73 | " Use K to show documentation in preview window. 74 | nnoremap K :call show_documentation() 75 | 76 | function! s:show_documentation() 77 | if (index(['vim','help'], &filetype) >= 0) 78 | execute 'h '.expand('') 79 | else 80 | call CocActionAsync('doHover') 81 | endif 82 | endfunction 83 | " Highlight the symbol and its references when holding the cursor. 84 | autocmd CursorHold * silent call CocActionAsync('highlight') 85 | 86 | " Symbol renaming. 87 | nmap rn (coc-rename) 88 | 89 | " Formatting selected code. 90 | xmap f (coc-format-selected) 91 | nmap f (coc-format-selected) 92 | 93 | augroup mygroup 94 | autocmd! 95 | " Setup formatexpr specified filetype(s). 96 | autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') 97 | " Update signature help on jump placeholder. 98 | autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') 99 | augroup end 100 | 101 | " Applying codeAction to the selected region. 102 | " Example: `aap` for current paragraph 103 | xmap a (coc-codeaction-selected) 104 | nmap a (coc-codeaction-selected) 105 | 106 | " Remap keys for applying codeAction to the current buffer. 107 | nmap ac (coc-codeaction) 108 | " Apply AutoFix to problem on the current line. 109 | nmap qf (coc-fix-current) 110 | 111 | " Run the Code Lens action on the current line. 112 | nmap cl (coc-codelens-action) 113 | 114 | " Map function and class text objects 115 | " NOTE: Requires 'textDocument.documentSymbol' support from the language server. 116 | xmap if (coc-funcobj-i) 117 | omap if (coc-funcobj-i) 118 | xmap af (coc-funcobj-a) 119 | omap af (coc-funcobj-a) 120 | xmap ic (coc-classobj-i) 121 | omap ic (coc-classobj-i) 122 | xmap ac (coc-classobj-a) 123 | omap ac (coc-classobj-a) 124 | 125 | " Remap and for scroll float windows/popups. 126 | if has('nvim-0.4.0') || has('patch-8.2.0750') 127 | nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" 128 | nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" 129 | inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" 130 | inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" 131 | vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" 132 | vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" 133 | endif 134 | 135 | " Use CTRL-S for selections ranges. 136 | " Requires 'textDocument/selectionRange' support of language server. 137 | nmap (coc-range-select) 138 | xmap (coc-range-select) 139 | 140 | " Add `:Format` command to format current buffer. 141 | command! -nargs=0 Format :call CocAction('format') 142 | 143 | " Add `:Fold` command to fold current buffer. 144 | command! -nargs=? Fold :call CocAction('fold', ) 145 | 146 | " Add `:OR` command for organize imports of the current buffer. 147 | command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') 148 | 149 | " Add (Neo)Vim's native statusline support. 150 | " NOTE: Please see `:h coc-status` for integrations with external plugins that 151 | " provide custom statusline: lightline.vim, vim-airline. 152 | set statusline=%f\ %h%w%m%r%=%{coc#status()}%{get(b:,'coc_current_function','')}\ %(%l,%c%V\ %=\ %P%) 153 | 154 | " Mappings for CoCList 155 | nnoremap d :CocList diagnostics 156 | nnoremap j :CocList files 157 | nnoremap s :CocList grep 158 | nnoremap l :CocListResume 159 | -------------------------------------------------------------------------------- /.config/nvim/init-neo.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=~/.vim runtimepath+=~/.vim/after 2 | let &packpath=&runtimepath 3 | 4 | if has("nvim-0.6.0") 5 | nnoremap Y yy 6 | endif 7 | 8 | " Plugins {{{ 9 | call plug#begin('~/.vim/plugged') 10 | 11 | " Autocompletion: 12 | Plug 'hrsh7th/nvim-cmp' 13 | Plug 'hrsh7th/cmp-path' 14 | Plug 'hrsh7th/cmp-buffer' 15 | Plug 'hrsh7th/cmp-cmdline' 16 | 17 | " Snippets: 18 | Plug 'hrsh7th/vim-vsnip' 19 | Plug 'hrsh7th/cmp-vsnip' 20 | 21 | " LSP: 22 | Plug 'neovim/nvim-lspconfig' 23 | Plug 'hrsh7th/cmp-nvim-lsp' 24 | Plug 'williamboman/nvim-lsp-installer' 25 | 26 | " Treesitter: 27 | " Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} 28 | " Plug 'ray-x/cmp-treesitter' 29 | 30 | " Language: 31 | Plug 'simrat39/rust-tools.nvim' 32 | 33 | " Optional: 34 | " Plug 'nvim-lua/popup.nvim' 35 | " Plug 'nvim-lua/plenary.nvim' 36 | " Plug 'nvim-telescope/telescope.nvim' 37 | 38 | " Theme: 39 | Plug 'jonathanfilip/vim-lucius' 40 | 41 | " Commands: 42 | Plug 'mileszs/ack.vim', { 'on': 'Ack' } 43 | Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } 44 | Plug 'preservim/tagbar', { 'on': 'TagbarToggle' } 45 | Plug 'tpope/vim-fugitive', { 'on': ['G', 'Git'] } 46 | Plug 'tpope/vim-eunuch' 47 | 48 | " Edit: 49 | Plug 'Raimondi/delimitMate' 50 | "Plug 'ervandew/supertab' 51 | Plug 'godlygeek/tabular', { 'on': 'Tabularize' } 52 | Plug 'tpope/vim-surround' 53 | Plug 'tpope/vim-commentary' 54 | Plug 'tpope/vim-endwise' 55 | Plug 'tpope/vim-repeat' 56 | 57 | " Other: 58 | Plug 'vim-scripts/IndexedSearch' 59 | Plug 'vim-scripts/ZoomWin' 60 | Plug 'bogado/file-line' 61 | 62 | call plug#end() 63 | 64 | " menuone: popup even when there's only one match 65 | " noinsert: Do not insert text until a selection is made 66 | " noselect: Do not select, force user to select one from the menu 67 | set completeopt=menuone,noinsert,noselect 68 | 69 | " Avoid showing extra messages when using completion 70 | set shortmess+=c 71 | 72 | " Configure LSP through rust-tools.nvim plugin. 73 | " rust-tools will configure and enable certain LSP features for us. 74 | " See https://github.com/simrat39/rust-tools.nvim#configuration 75 | lua < 87 | buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') 88 | 89 | -- Mappings. 90 | local opts = { noremap=true, silent=true } 91 | 92 | -- See `:help vim.lsp.*` for documentation on any of the below functions 93 | buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) 94 | buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) 95 | buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) 96 | buf_set_keymap('n', 'gy', 'lua vim.lsp.buf.type_definition()', opts) 97 | buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) 98 | buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) 99 | -- buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) 100 | -- buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) 101 | -- buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) 102 | -- buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) 103 | buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) 104 | buf_set_keymap('n', 'a', 'lua vim.lsp.buf.code_action()', opts) 105 | -- buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) 106 | buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) 107 | buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) 108 | -- buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) 109 | -- buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) 110 | end 111 | 112 | local lsp_installer = require("nvim-lsp-installer") 113 | 114 | lsp_installer.on_server_ready(function(server) 115 | local opts = { 116 | on_attach = on_attach, 117 | flags = { 118 | debounce_text_changes = 150, 119 | } 120 | } 121 | 122 | if server.name == "rust_analyzer" then 123 | -- Initialize the LSP via rust-tools instead 124 | require("rust-tools").setup { 125 | -- The "server" property provided in rust-tools setup function are the 126 | -- settings rust-tools will provide to lspconfig during init. -- 127 | -- We merge the necessary settings from nvim-lsp-installer (server:get_default_options()) 128 | -- with the user's own settings (opts). 129 | tools = { 130 | autoSetHints = true, 131 | hover_with_actions = true, 132 | inlay_hints = { 133 | show_parameter_hints = false, 134 | parameter_hints_prefix = "", 135 | other_hints_prefix = "", 136 | }, 137 | hover_actions = { 138 | border = "none" 139 | } 140 | }, 141 | server = vim.tbl_deep_extend("force", server:get_default_options(), opts), 142 | } 143 | server:attach_buffers() 144 | else 145 | server:setup(opts) 146 | end 147 | end) 148 | EOF 149 | 150 | " Setup Completion 151 | " See https://github.com/hrsh7th/nvim-cmp#basic-configuration 152 | lua <'] = cmp.mapping.select_prev_item(), 162 | [''] = cmp.mapping.select_next_item(), 163 | -- Add tab support 164 | [''] = cmp.mapping.select_prev_item(), 165 | [''] = cmp.mapping.select_next_item(), 166 | [''] = cmp.mapping.scroll_docs(-4), 167 | [''] = cmp.mapping.scroll_docs(4), 168 | [''] = cmp.mapping.complete(), 169 | [''] = cmp.mapping.close(), 170 | [''] = cmp.mapping.confirm({ 171 | behavior = cmp.ConfirmBehavior.Insert, 172 | select = true, 173 | }) 174 | }, 175 | 176 | -- Installed sources 177 | sources = { 178 | { name = 'nvim_lsp' }, 179 | { name = 'vsnip' }, 180 | { name = 'path' }, 181 | { name = 'buffer' }, 182 | { name = 'cmdline' }, 183 | }, 184 | }) 185 | EOF 186 | 187 | " have a fixed column for the diagnostics to appear in 188 | " this removes the jitter when warnings/errors flow in 189 | set signcolumn=number 190 | 191 | " Set updatetime for CursorHold 192 | " 300ms of no cursor movement to trigger CursorHold 193 | set updatetime=300 194 | " Show diagnostic popup on cursor hover 195 | autocmd CursorHold * lua vim.diagnostic.open_float() 196 | " }}} 197 | 198 | source ~/.vimrc.common 199 | " vim:set ft=vim et sw=2: 200 | -------------------------------------------------------------------------------- /.config/nvim/init.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=~/.vim runtimepath+=~/.vim/after 2 | let &packpath=&runtimepath 3 | 4 | if has("nvim-0.6.0") 5 | nnoremap Y yy 6 | endif 7 | 8 | source ~/.vimrc 9 | " vim:set ft=vim et sw=2: 10 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # This file sets up the environment 2 | 3 | pathmunge() { 4 | [ -d "$1" ] && case ":$PATH:" in 5 | *:$1:*) ;; 6 | *) [ "$2" = "after" ] && PATH="$PATH:$1" || PATH="$1:$PATH" 7 | esac 8 | export PATH 9 | } 10 | 11 | pathmunge "$HOME/.cargo/bin" 12 | pathmunge "$HOME/.cabal/bin" 13 | pathmunge "$HOME/node_modules/.bin" 14 | pathmunge "$HOME/.foundry/bin" 15 | pathmunge "$HOME/bin" 16 | pathmunge "$HOME/.local/bin" 17 | 18 | pathmunge "/home/linuxbrew/.linuxbrew/bin" 19 | if [ -e "/home/linuxbrew/.linuxbrew/bin/brew" ]; then 20 | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 21 | else if [ -e "/opt/homebrew/bin/brew" ] 22 | eval "$(/opt/homebrew/bin/brew shellenv)" 23 | fi 24 | 25 | if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then 26 | . "$HOME/.nix-profile/etc/profile.d/nix.sh" 27 | fi 28 | 29 | export PYTHONSTARTUP="$HOME/.pythonrc.py" 30 | export PAGER="$HOME/bin/vimpager" 31 | 32 | export EDITOR=vim 33 | if command -v nvim > /dev/null 2>&1; then 34 | export EDITOR=nvim 35 | fi 36 | 37 | # BSD ls color 38 | export LSCOLORS="Exfxcxdxbxegedabagacad" 39 | ls --color=auto > /dev/null 2>&1 || \ 40 | ls -G -d / > /dev/null 2>&1 && export CLICOLOR=yes 41 | 42 | # vim: se ft=sh: 43 | -------------------------------------------------------------------------------- /.fasdrc: -------------------------------------------------------------------------------- 1 | _FASD_MAX=5000 2 | _FASD_BACKENDS="native current" 3 | 4 | local shell; for shell in dash mksh zsh; do 5 | _FASD_SHELL="$(command -v $shell)" && break 6 | done 7 | 8 | # vim: se ft=sh: 9 | -------------------------------------------------------------------------------- /.gitconfig: -------------------------------------------------------------------------------- 1 | [color] 2 | ui = auto 3 | [user] 4 | name = Wei Dai 5 | email = me@wdai.us 6 | [core] 7 | excludesfile = ~/.ignore 8 | [alias] 9 | ci = commit 10 | co = checkout 11 | rb = rebase 12 | st = status 13 | [merge] 14 | tool = vimdiff 15 | [push] 16 | default = simple 17 | [credential] 18 | helper = store --file ~/.my-credentials 19 | [init] 20 | defaultBranch = main 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/vimpager"] 2 | path = lib/vimpager 3 | url = https://github.com/rkitover/vimpager.git 4 | [submodule "lib/fasd"] 5 | path = lib/fasd 6 | url = https://github.com/clvv/fasd.git 7 | [submodule "lib/vim-plug"] 8 | path = lib/vim-plug 9 | url = https://github.com/junegunn/vim-plug.git 10 | -------------------------------------------------------------------------------- /.ignore: -------------------------------------------------------------------------------- 1 | tags 2 | tags-* 3 | -------------------------------------------------------------------------------- /.inputrc: -------------------------------------------------------------------------------- 1 | $include /etc/inputrc 2 | 3 | set bell-style none 4 | set completion-ignore-case on 5 | set show-all-if-ambiguous on 6 | set completion-ignore-case on 7 | set menu-complete-display-prefix on 8 | 9 | $if Bash 10 | Space: magic-space 11 | $endif 12 | 13 | "\ek": history-search-backward 14 | "\ej": history-search-forward 15 | 16 | # Tab to menucomplete, Shift + Tab to do it backward 17 | Tab: menu-complete 18 | "\e[Z": menu-complete-backward 19 | 20 | # set editing-mode vi 21 | 22 | $if mode=vi 23 | set keymap vi-insert 24 | "\C-l": clear-screen 25 | "\C-w": backward-kill-word 26 | "\C-a": beginning-of-line 27 | "\C-e": end-of-line 28 | $endif 29 | -------------------------------------------------------------------------------- /.logout: -------------------------------------------------------------------------------- 1 | # when leaving the console clear the screen to increase privacy 2 | 3 | if [ "$SHLVL" = 1 ]; then 4 | [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q || clear 5 | fi 6 | 7 | # vim: se ft=sh: 8 | -------------------------------------------------------------------------------- /.pythonrc.py: -------------------------------------------------------------------------------- 1 | import readline 2 | import rlcompleter 3 | 4 | readline.parse_and_bind('tab: complete') 5 | -------------------------------------------------------------------------------- /.screenrc: -------------------------------------------------------------------------------- 1 | startup_message off 2 | 3 | # Allow scrolling in xterm 4 | termcapinfo xterm ti@:te@ 5 | 6 | defmonitor on 7 | activity "activity -> %n%f %t" 8 | 9 | # Keybindings 10 | 11 | bindkey "\033[Z" next # 12 | bindkey ^[[5;5~ prev # 13 | bindkey ^[[6;5~ next # 14 | -------------------------------------------------------------------------------- /.shenv: -------------------------------------------------------------------------------- 1 | # This file is sourced by interactive shells 2 | 3 | [ -s "$HOME/.env" ] && . "$HOME/.env" 4 | 5 | _gb() { 6 | ref="$(git symbolic-ref HEAD 2> /dev/null)" 7 | branch="${ref#refs/heads/}" 8 | [ -z "$branch" ] && return 1 || echo " $branch" 9 | } 10 | 11 | [ -s "$HOME/.shenv.local" ] && . "$HOME/.shenv.local" 12 | 13 | # vim: se ft=sh: 14 | -------------------------------------------------------------------------------- /.tmux.conf: -------------------------------------------------------------------------------- 1 | set-option -g status-keys vi 2 | set -g default-terminal "screen-256color" 3 | setw -g mode-keys vi 4 | setw -g monitor-activity on 5 | bind-key a last-window 6 | set-option -g set-titles on 7 | set-option -g set-titles-string '#H;#S:#I.#P #W #T' 8 | # window number,program name,active (or not) 9 | 10 | bind K confirm-before "kill-window" 11 | bind | split-window -h 12 | bind v split-window -h 13 | bind s split-window 14 | bind < resize-pane -L 2 15 | bind > resize-pane -R 2 16 | bind - resize-pane -D 2 17 | bind + resize-pane -U 2 18 | 19 | bind h select-pane -R 20 | bind j select-pane -D 21 | bind k select-pane -U 22 | bind l select-pane -L 23 | bind r source-file ~/.tmux.conf 24 | 25 | -------------------------------------------------------------------------------- /.vim/autoload/plug.vim: -------------------------------------------------------------------------------- 1 | ../../lib/vim-plug/plug.vim -------------------------------------------------------------------------------- /.vim/coc-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "list.normalMappings": { 3 | "q": "do:exit" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.vimpagerrc: -------------------------------------------------------------------------------- 1 | if &t_Co == 256 2 | set mouse=a 3 | if filereadable(expand('~/.vim/plugged/vim-lucius/colors/lucius.vim')) 4 | let &runtimepath .= ',' . expand('~/.vim/plugged/vim-lucius') 5 | colorscheme lucius 6 | LuciusBlack 7 | endif 8 | endif 9 | 10 | if exists("g:vimpager.enabled") 11 | if exists("g:vimpager_ptree") && g:vimpager_ptree[-2] == 'wman' 12 | set ft=man 13 | endif 14 | endif 15 | 16 | " vim: se ft=vim: 17 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | " Plugins {{{ 2 | call plug#begin('~/.vim/plugged') 3 | 4 | " IDE: Coc, Conquer of completion. Requires nodejs. 5 | Plug 'neoclide/coc.nvim', {'branch': 'release', 6 | \ 'for': ['rust', 'tex', 'markdown', 'typescript', 'solidity'], 7 | \ 'on': 'CocInfo', 8 | \ 'do': ':CocInstall coc-rust-analyzer coc-ltex coc-tsserver coc-solidity coc-lists', 9 | \ } 10 | autocmd! User coc.nvim source ~/.config/nvim/coc.vim 11 | 12 | " Theme: 13 | Plug 'clvv/vim-lucius' 14 | 15 | " Commands: 16 | Plug 'mileszs/ack.vim', { 'on': 'Ack' } 17 | Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } 18 | Plug 'liuchengxu/vista.vim', { 'on': 'Vista' } 19 | Plug 'tpope/vim-fugitive', { 'on': ['G', 'Git'] } 20 | Plug 'tpope/vim-eunuch' 21 | 22 | " Edit: 23 | Plug 'Raimondi/delimitMate' 24 | Plug 'ervandew/supertab' 25 | Plug 'godlygeek/tabular', { 'on': 'Tabularize' } 26 | Plug 'tpope/vim-surround' 27 | Plug 'tpope/vim-commentary' 28 | Plug 'tpope/vim-endwise' 29 | Plug 'tpope/vim-repeat' 30 | 31 | " Language: 32 | Plug 'rust-lang/rust.vim', { 'for': 'rust' } 33 | Plug 'iden3/vim-circom-syntax' 34 | 35 | " Other: 36 | Plug 'vim-scripts/IndexedSearch' 37 | Plug 'bogado/file-line' 38 | 39 | call plug#end() 40 | " }}} 41 | 42 | source ~/.vimrc.common 43 | " vim:set ft=vim et sw=2: 44 | -------------------------------------------------------------------------------- /.vimrc.common: -------------------------------------------------------------------------------- 1 | " Settings {{{ 2 | filetype plugin indent on 3 | syntax on 4 | set tabstop=2 shiftwidth=2 softtabstop=2 expandtab 5 | set smarttab 6 | set autoindent 7 | set autoread 8 | set autowrite 9 | set nobackup 10 | set noswapfile 11 | set ruler 12 | set backspace=indent,eol,start 13 | set listchars=tab:\|_ 14 | set wildmode=full 15 | set wildmenu 16 | if v:version >= 703 17 | set undofile 18 | set undodir=~/.vim/undo 19 | if has("nvim-0.5.0") 20 | set undodir=~/.config/nvim/undo 21 | endif 22 | else 23 | set t_RV= 24 | endif 25 | if v:version > 703 || v:version == 703 && has("patch541") 26 | set formatoptions+=j " Delete comment character when joining commented lines 27 | endif 28 | set noerrorbells 29 | set vb t_vb= 30 | 31 | let g:tex_flavor = "latex" 32 | let mapleader = ',' 33 | 34 | " Search settings {{{ 35 | set hlsearch 36 | set incsearch 37 | set ignorecase 38 | set smartcase 39 | " }}} 40 | 41 | " Plugin options "{{{ 42 | 43 | " For LISP 44 | let g:lisp_rainbow=1 45 | 46 | " Settings for Vim Clojure 47 | let vimclojure#HighlightBuiltins=1 48 | let vimclojure#ParenRainbow=1 49 | 50 | " SuperTab 51 | let g:SuperTabDefaultCompletionType = 'context' 52 | 53 | " DelimitMate 54 | let delimitMate_expand_cr = 1 55 | let delimitMate_expand_space = 1 56 | 57 | " Vista 58 | let g:vista_sidebar_position = 'vertical topleft' 59 | 60 | " NerdTree 61 | let g:NERDTreeWinPos = 'right' 62 | 63 | " JSLint.vim 64 | let g:JSLintHighlightErrorLine = 0 65 | " }}} 66 | " }}} 67 | 68 | " Mappings {{{ 69 | " Toggles {{{ 70 | map gl :set list! 71 | map gn :set number! 72 | if v:version >= 703 73 | map gr :set relativenumber! 74 | endif 75 | map gs :set spell! 76 | map gw :set wrap! 77 | map g1 :NERDTreeToggle 78 | map g2 :Vista!! 79 | " }}} 80 | 81 | " Windows Control {{{ 82 | map h 83 | map j 84 | map k 85 | map l 86 | " }}} 87 | 88 | " Tabs Control {{{ 89 | map H gT 90 | map L gt 91 | map n :tabnew 92 | map c c 93 | map q ZQ 94 | map t :tabnew:terminal 95 | " }}} 96 | 97 | " System Copy & Paste prefix {{{ 98 | map "+ 99 | set pastetoggle=gv 100 | " }}} 101 | 102 | " Indentation {{{ 103 | nmap > >> 104 | nmap < << 105 | vmap > >gv 106 | vmap < 111 | cnoremap 112 | cnoremap 113 | cnoremap 114 | cnoremap j 115 | cnoremap k 116 | cnoremap b 117 | cnoremap 118 | cnoremap f 119 | cnoremap 120 | cnoremap 121 | 122 | inoremap 123 | inoremap 124 | inoremap ka 125 | inoremap ja 126 | inoremap i 127 | inoremap la 128 | inoremap o 129 | inoremap O 130 | imap bi 131 | imap wi 132 | " }}} 133 | 134 | " Misc {{{ 135 | set cedit= " open command line window from normal command line mode 136 | 137 | " Easy jumping and selecting over block of code 138 | map % 139 | 140 | " display line up/down (not actual) 141 | map gk 142 | map gj 143 | 144 | " to clear highlights 145 | nmap L :noh 146 | 147 | vmap T :Tabularize / 148 | nmap T :Tabularize / 149 | 150 | nmap m :make 151 | 152 | command! -bang Q :q 153 | nmap ZS :SudoWrite 154 | nmap ZW :w 155 | nmap zW 156 | " }}} 157 | 158 | " }}} 159 | 160 | " Features {{{ 161 | " Folding {{{ 162 | set foldmethod=marker 163 | set foldenable 164 | "set foldlevel=4 165 | "set foldlevelstart=4 166 | nmap oi :set foldmethod=indent 167 | nmap os :set foldmethod=syntax 168 | nmap om :set foldmethod=marker 169 | set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo 170 | " }}} 171 | 172 | " Ctag {{{ 173 | " Lookup tags file up the dir tree 174 | set tags=tags;~ 175 | " Tab and Vsplit open tag 176 | map :vsp :exec("tag ".expand("")) 177 | map ] :tab split:exec("tag ".expand("")) 178 | " }}} 179 | " }}} 180 | 181 | " Autocmd {{{ 182 | if has("autocmd") 183 | autocmd BufWritePre * :%s/\s\+$//e " remove trailing spaces 184 | autocmd BufNewFile,BufRead *.json set ft=javascript 185 | augroup VIMRC " {{{ 186 | autocmd! 187 | autocmd BufWritePost .vimrc source $MYVIMRC 188 | augroup END " }}} 189 | autocmd FileType *commit* setlocal spell 190 | autocmd FileType tex silent! compiler tex | setlocal tw=78 makeprg=pdflatex\ 191 | \ -interaction=nonstopmode\ % 192 | autocmd BufNewFile,BufRead *.1.md setlocal tw=78 makeprg=pandoc\ -s\ -w\ 193 | \ man\ %\ -o\ %< 194 | autocmd FileType make,snippet,snippets,autohotkey setlocal list ts=8 sw=8 sts=8 noet 195 | autocmd FileType make,snippet,snippets setlocal list ts=8 sw=8 sts=8 noet 196 | autocmd FileType python,lua setlocal ts=4 sw=4 sts=4 et 197 | autocmd FileType vim let b:delimitMate_matchpairs = "(:),[:],{:},<:>" 198 | autocmd FileType lisp,scheme,clojure let b:delimitMate_quotes = '"' 199 | autocmd BufNewFile,BufReadPost *.md set filetype=markdown 200 | endif " }}} 201 | 202 | " Styling {{{ 203 | if has('gui_running') 204 | set guioptions= 205 | set cursorline 206 | colorscheme lucius 207 | LuciusBlack 208 | else 209 | if &t_Co == 256 210 | set mouse=a " Scrolling in urxvt 211 | colorscheme lucius 212 | set cursorline 213 | LuciusBlack 214 | set t_ut= " Background 215 | endif 216 | nmap c2 :set t_Co=256 217 | nmap c8 :set t_Co=8 218 | endif " }}} 219 | 220 | " Helpers {{{ 221 | " runtime ftplugin/man.vim 222 | runtime macros/matchit.vim 223 | 224 | " Stab, tab and space settings helper {{{ 225 | " Calling Stab with no arguments will print current tab and space settings 226 | " Calling Stab with a number will set ts, sw and sts to that number 227 | " Trailing ! will set expandtab, and trailing ? will set noexpandtab 228 | command! -nargs=? Stab call Stab() 229 | function! Stab(...) 230 | if a:0 != 0 231 | if a:1 =~ '!' 232 | set expandtab 233 | elseif a:1 =~ '?' 234 | set noexpandtab 235 | endif 236 | if a:1 > 0 237 | let l:tabstop = 1 * a:1 238 | let &l:sts = l:tabstop 239 | let &l:ts = l:tabstop 240 | let &l:sw = l:tabstop 241 | endif 242 | endif 243 | try 244 | echohl ModeMsg 245 | echon 'tabstop='.&l:ts 246 | echon ' shiftwidth='.&l:sw 247 | echon ' softtabstop='.&l:sts 248 | if &l:et 249 | echon ' expandtab' 250 | else 251 | echon ' noexpandtab' 252 | endif 253 | finally 254 | echohl None 255 | endtry 256 | endfunction " }}} 257 | 258 | " Z - cd to recent / frequent directories {{{ 259 | command! -nargs=* Z :call Z() 260 | function! Z(...) 261 | if a:0 == 0 262 | let list = split(system('fasd -dlR'), '\n') 263 | let path = tlib#input#List('s', 'Select one', list) 264 | else 265 | let cmd = 'fasd -d -e printf' 266 | for arg in a:000 267 | let cmd = cmd . ' ' . arg 268 | endfor 269 | let path = system(cmd) 270 | endif 271 | if isdirectory(path) 272 | echo path 273 | exec 'cd ' . path 274 | endif 275 | endfunction " }}} 276 | 277 | " z - quick spelling correction {{{ 278 | nmap z :QuickSpellingFix 279 | command! QuickSpellingFix call QuickSpellingFix() 280 | function! QuickSpellingFix() 281 | if &spell 282 | normal 1z= 283 | else 284 | set spell 285 | normal 1z= 286 | set nospell 287 | endif 288 | endfunction " }}} 289 | " }}} 290 | 291 | " Source .vimrc.local if present {{{ 292 | if filereadable(expand('~/.vimrc.local')) 293 | source ~/.vimrc.local 294 | endif " }}} 295 | " vim:set ft=vim et sw=2: 296 | -------------------------------------------------------------------------------- /.zlogout: -------------------------------------------------------------------------------- 1 | source "$HOME/.logout" 2 | -------------------------------------------------------------------------------- /.zsh/aliases.zsh: -------------------------------------------------------------------------------- 1 | alias -g A='| awk' 2 | alias -g C='| wc' 3 | alias -g G='| grep' 4 | alias -g L='| less' 5 | alias -g H='| head -n $(($LINES-5))' 6 | alias -g T='| tail -n $(($LINES-5))' 7 | alias -g S='| sed' 8 | alias -g N='&> /dev/null' 9 | alias -g XC='&> xclip -i -sel c' 10 | 11 | alias history='fc -l 1' 12 | 13 | -------------------------------------------------------------------------------- /.zsh/bindkey.zsh: -------------------------------------------------------------------------------- 1 | bindkey -e 2 | bindkey '^R' history-incremental-search-backward 3 | bindkey '^[[5~' up-line-or-history 4 | bindkey '^[[6~' down-line-or-history 5 | 6 | bindkey '^[[A' up-line-or-search 7 | bindkey '^[[B' down-line-or-search 8 | 9 | bindkey '^[[H' beginning-of-line 10 | bindkey '^[[1~' beginning-of-line 11 | bindkey '^[[F' end-of-line 12 | bindkey '^[[4~' end-of-line 13 | bindkey ' ' magic-space 14 | 15 | bindkey '^[[Z' reverse-menu-complete 16 | 17 | bindkey '^[[3~' delete-char 18 | bindkey '^[3;5~' delete-char 19 | bindkey '\e[3~' delete-char 20 | 21 | bindkey '^[m' copy-prev-shell-word 22 | 23 | bindkey '^[k' history-beginning-search-backward 24 | bindkey '^[j' history-beginning-search-forward 25 | bindkey '^[^I' _history-complete-older 26 | bindkey '^[^[^I' _history-complete-newer 27 | 28 | bindkey '^U' backward-kill-line 29 | 30 | bindkey -s '^[l' '^Qls^M' # Alt-l 31 | bindkey -s '^[>' '^Q..^M' # Alt-S-. 32 | bindkey -s '^[-' '^Qcd -^M' 33 | bindkey -s '^[S' '^Asudo ^E' # Alt-S-s add sudo 34 | 35 | # Quick jumping to n-th arguments by pressing Alt-number 36 | bindkey '^[1' beginning-of-line 37 | bindkey -s '^[2' '^A^[f' 38 | bindkey -s '^[3' '^A^[f^[f' 39 | bindkey -s '^[4' '^A^[f^[f^[f' 40 | bindkey -s '^[5' '^A^[f^[f^[f^[f' 41 | bindkey -s '^[6' '^A^[f^[f^[f^[f^[f' 42 | bindkey -s '^[7' '^A^[f^[f^[f^[f^[f^[f' 43 | bindkey -s '^[8' '^A^[f^[f^[f^[f^[f^[f^[f' 44 | bindkey -s '^[9' '^A^[f^[f^[f^[f^[f^[f^[f^[f' 45 | 46 | bindkey '^X^A' fasd-complete 47 | bindkey '^X^F' fasd-complete-f 48 | bindkey '^X^D' fasd-complete-d 49 | 50 | -------------------------------------------------------------------------------- /.zsh/completion.zsh: -------------------------------------------------------------------------------- 1 | unsetopt MENU_COMPLETE # do not autoselect the first completion entry 2 | unsetopt FLOWCONTROL 3 | setopt AUTO_MENU # show completion menu on succesive tab press 4 | setopt COMPLETE_IN_WORD 5 | setopt ALWAYS_TO_END 6 | 7 | # Treat these characters as part of a word. 8 | WORDCHARS='*?_-.[]~&;!#$%^(){}<>' 9 | 10 | # Use caching so that commands like apt and dpkg complete are useable 11 | zstyle ':completion::complete:*' use-cache 1 12 | zstyle ':completion::complete:*' cache-path "$HOME/.zsh/cache/" 13 | 14 | zmodload -i zsh/complist 15 | 16 | zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' 17 | unsetopt CASE_GLOB 18 | 19 | bindkey -M menuselect '^o' accept-and-infer-next-history 20 | 21 | zstyle ':completion:*:*:*:*:*' menu select 22 | zstyle ':completion:*:matches' group 'yes' 23 | zstyle ':completion:*:options' description 'yes' 24 | zstyle ':completion:*:options' auto-description '%d' 25 | zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f' 26 | zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f' 27 | zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f' 28 | zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f' 29 | zstyle ':completion:*:default' list-prompt '%S%M matches%s' 30 | zstyle ':completion:*' format ' %F{yellow}-- %d --%f' 31 | zstyle ':completion:*' group-name '' 32 | zstyle ':completion:*' verbose yes 33 | 34 | # use /etc/hosts and known_hosts for hostname completion 35 | [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=() 36 | [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(/dev/null)"}%%[#| ]*}//,/ } 67 | ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} 68 | ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} 69 | )' 70 | # Don't complete uninteresting users 71 | zstyle ':completion:*:*:*:users' ignored-patterns \ 72 | adm amanda apache avahi beaglidx bin cacti canna clamav daemon \ 73 | dbus distcache dovecot fax ftp games gdm gkrellmd gopher \ 74 | hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \ 75 | mailman mailnull mldonkey mysql nagios \ 76 | named netdump news nfsnobody nobody nscd ntp nut nx openvpn \ 77 | operator pcap postfix postgres privoxy pulse pvm quagga radvd \ 78 | rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs 79 | 80 | # ... unless we really want to. 81 | zstyle '*' single-ignored show 82 | 83 | # Ignore multiple entries. 84 | zstyle ':completion:*:(rm|kill|diff):*' ignore-line other 85 | zstyle ':completion:*:rm:*' file-patterns '*:all-files' 86 | 87 | # Kill 88 | zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" 89 | zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' 90 | zstyle ':completion:*:*:kill:*' menu yes select 91 | zstyle ':completion:*:*:kill:*' force-list always 92 | zstyle ':completion:*:*:kill:*' insert-ids single 93 | 94 | # Man 95 | zstyle ':completion:*:manuals' separate-sections true 96 | zstyle ':completion:*:manuals.(^1*)' insert-sections true 97 | 98 | # SSH/SCP/RSYNC 99 | zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' 100 | zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr 101 | zstyle ':completion:*:ssh:*' tag-order users 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' 102 | zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr 103 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost 104 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*' 105 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*' 106 | 107 | # Fix slow git completion 108 | __git_files () { 109 | _wanted files expl 'local files' _files 110 | } 111 | -------------------------------------------------------------------------------- /.zsh/options.zsh: -------------------------------------------------------------------------------- 1 | # Jobs 2 | setopt LONG_LIST_JOBS # List jobs in the long format by default. 3 | setopt AUTO_RESUME # Attempt to resume existing job before creating a new process. 4 | setopt NOTIFY # Report status of background jobs immediately. 5 | unsetopt BG_NICE # Don't run all background jobs at a lower priority. 6 | unsetopt HUP # Don't kill jobs on shell exit. 7 | unsetopt CHECK_JOBS # Don't report on jobs when shell exit. 8 | 9 | # History 10 | HISTFILE="$HOME/.zhistory" 11 | HISTSIZE=10000 12 | SAVEHIST=10000 13 | setopt HIST_IGNORE_DUPS 14 | setopt HIST_IGNORE_ALL_DUPS 15 | setopt HIST_IGNORE_SPACE 16 | setopt SHARE_HISTORY 17 | setopt APPEND_HISTORY 18 | setopt INC_APPEND_HISTORY 19 | setopt EXTENDED_HISTORY 20 | setopt HIST_EXPIRE_DUPS_FIRST 21 | unsetopt HIST_VERIFY 22 | 23 | # Directory 24 | setopt AUTO_CD 25 | setopt AUTO_PUSHD 26 | setopt AUTO_NAME_DIRS 27 | setopt PUSHD_IGNORE_DUPS 28 | setopt PUSHD_TO_HOME 29 | setopt MULTIOS 30 | 31 | setopt PROMPT_SUBST 32 | setopt INTERACTIVECOMMENTS 33 | setopt NO_BEEP 34 | 35 | autoload colors; colors; 36 | autoload -U url-quote-magic 37 | zle -N self-insert url-quote-magic 38 | 39 | autoload -U edit-command-line 40 | zle -N edit-command-line 41 | 42 | autoload -U add-zsh-hook 43 | 44 | -------------------------------------------------------------------------------- /.zsh/prompt.zsh: -------------------------------------------------------------------------------- 1 | PROMPT='%{$fg[green]%}[%n %m] %{$fg[yellow]%}[%c$(_gb)] %{$fg[red]%}%#%{$reset_color%} ' 2 | PROMPT2='%{$fg[red]%}\ %{$reset_color%}' 3 | RPS1='%{$fg[blue]%}%~ %{$reset_color%}%(?..%{$fg[red]%}%?%{$reset_color%})' 4 | 5 | -------------------------------------------------------------------------------- /.zsh/terminal.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Sets terminal window and tab titles. 3 | # 4 | # Authors: 5 | # James Cox 6 | # Sorin Ionescu 7 | # 8 | 9 | # Dumb terminals lack support. 10 | if [[ "$TERM" == 'dumb' ]]; then 11 | return 12 | fi 13 | 14 | # Set the GNU Screen window number. 15 | if [[ -n "$WINDOW" ]]; then 16 | export SCREEN_NO="%B${WINDOW}%b " 17 | else 18 | export SCREEN_NO="" 19 | fi 20 | 21 | # Sets the GNU Screen title. 22 | function set-screen-title() { 23 | if [[ "$TERM" == screen* ]]; then 24 | printf "\ek%s\e\\" ${(V)argv} 25 | fi 26 | } 27 | 28 | # Sets the terminal window title. 29 | function set-window-title() { 30 | if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then 31 | printf "\e]2;%s\a" ${(V)argv} 32 | fi 33 | } 34 | 35 | # Sets the terminal tab title. 36 | function set-tab-title() { 37 | if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then 38 | printf "\e]1;%s\a" ${(V)argv} 39 | fi 40 | } 41 | 42 | # Sets the tab and window titles with the command name. 43 | function set-title-by-command() { 44 | emulate -L zsh 45 | setopt LOCAL_OPTIONS EXTENDED_GLOB 46 | 47 | # Get the command name that is under job control. 48 | if [[ "${1[(w)1]}" == (fg|%*)(\;|) ]]; then 49 | # Get the job name, and, if missing, set it to the default %+. 50 | local job_name="${${1[(wr)%*(\;|)]}:-%+}" 51 | 52 | # Make a local copy for use in the subshell. 53 | local -A jobtexts_from_parent_shell 54 | jobtexts_from_parent_shell=(${(kv)jobtexts}) 55 | 56 | jobs $job_name 2>/dev/null > >( 57 | read index discarded 58 | # The index is already surrounded by brackets: [1]. 59 | set-title-by-command "${(e):-\$jobtexts_from_parent_shell$index}" 60 | ) 61 | else 62 | # Set the command name, or in the case of sudo or ssh, the next command. 63 | local cmd=${1[(wr)^(*=*|sudo|ssh|-*)]} 64 | 65 | # Right-truncate the command name to 15 characters. 66 | if (( $#cmd > 15 )); then 67 | cmd="${cmd[1,15]}..." 68 | fi 69 | 70 | for kind in window tab screen; do 71 | set-${kind}-title "$cmd" 72 | done 73 | fi 74 | } 75 | 76 | # Don't override precmd/preexec; append to hook array. 77 | autoload -Uz add-zsh-hook 78 | 79 | # Sets the tab and window titles before the prompt is displayed. 80 | function set-title-precmd() { 81 | if [[ "$TERM_PROGRAM" != "Apple_Terminal" ]]; then 82 | set-window-title "${(%):-%~}" 83 | for kind in tab screen; do 84 | # Left-truncate the current working directory to 15 characters. 85 | set-${kind}-title "${(%):-%15<...<%~%<<}" 86 | done 87 | else 88 | # Set Apple Terminal current working directory. 89 | printf '\e]7;%s\a' "file://$HOST${PWD// /%20}" 90 | fi 91 | } 92 | add-zsh-hook precmd set-title-precmd 93 | 94 | # Sets the tab and window titles before command execution. 95 | function set-title-preexec() { 96 | if [[ "$TERM_PROGRAM" != 'Apple_Terminal' ]]; then 97 | set-title-by-command "$2" 98 | fi 99 | } 100 | add-zsh-hook preexec set-title-preexec 101 | 102 | -------------------------------------------------------------------------------- /.zshenv: -------------------------------------------------------------------------------- 1 | [ -s "$HOME/.shenv" ] && source "$HOME/.shenv" 2 | [ -s "$HOME/.aliases" ] && source "$HOME/.aliases" 3 | -------------------------------------------------------------------------------- /.zshrc: -------------------------------------------------------------------------------- 1 | for config ($HOME/.zsh/*.zsh) source "$config" 2 | 3 | { # Compile the completion dump to increase startup speed. 4 | dump_file="$HOME/.zcompdump" 5 | if [[ "$dump_file" -nt "${dump_file}.zwc" || ! -f "${dump_file}.zwc" ]]; then 6 | zcompile "$dump_file" 7 | fi 8 | unset dump_file 9 | } &! 10 | 11 | # Load and initialize the completion system ignoring insecure directories. 12 | autoload -Uz compinit && compinit -i 13 | 14 | FASD_CACHE="$HOME/.fasd-init-zsh" 15 | 16 | if [ "${commands[fasd]}" -nt "$FASD_CACHE" -o ! -f "$FASD_CACHE" ]; then 17 | fasd --init posix-alias zsh-{hook,ccomp,ccomp-install,wcomp,wcomp-install} \ 18 | >! "$FASD_CACHE" 19 | fi 20 | 21 | if [ -e "$HOME/lib/zsh-yarn-completions/zsh-yarn-completions.plugin.zsh" ]; then 22 | source "$HOME/lib/zsh-yarn-completions/zsh-yarn-completions.plugin.zsh" 23 | fi 24 | 25 | source "$FASD_CACHE" 26 | 27 | : # set $? to 0 28 | 29 | -------------------------------------------------------------------------------- /bin/fasd: -------------------------------------------------------------------------------- 1 | ../lib/fasd/fasd -------------------------------------------------------------------------------- /bin/m2t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | length="$(expr length "$1")" 4 | hash="$(echo "$1" | sed -n 's/.*xt=urn:btih:\([^&/]\+\).*/\1/p')" 5 | echo "d10:magnet-uri${length}:${1}e" > "meta-${hash:?"Invalid magnet link"}.torrent" 6 | 7 | -------------------------------------------------------------------------------- /bin/quiz: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This is a quiz that test you on your mental day of the week calculation. 4 | # Enter a number from range {1..7} according to the date prompted, with Monday being 1. 5 | 6 | DEFAULT_TIMES=10 7 | 8 | # getDate generates a random date and find its day of the week 9 | # Output is in this format: "date day-of-the-week" 10 | # DOW(Day of the Week) is a number from range {0..6}, with Monday being 1. 11 | getDate(){ 12 | awk 'function dow(year, month, day) { 13 | # Function that returns the day of the week of a given date 14 | # Below is Zellers congruence 15 | M = 1 + (month + 9) % 12 16 | if( M > 10) year = year - 1 17 | return int((int((13*M-1)/5)+int(year+year/4)-int(year/100)+int(year/400)+day)%7) 18 | } 19 | # doRanDate generates a random date 20 | # If the date is valid, it prints the date and day of the week, then returns 1 21 | # Otherwise it returns 0 22 | function doRanDate() { 23 | if( rand() > 0.45 ) 24 | year = int( rand() * 150 + 1900 ) 25 | else 26 | year = int( rand() * 700 + 1600 ) 27 | # Tweak year for your own needs, this one is pretty general 28 | month = int( rand() * 12 + 1 ) 29 | day = int( rand() * 31 + 1 ) 30 | # We have about 365.25/372 probability to get a valid date here 31 | if( (day>30) && (month==2||month==4||month==6||month==9||month==11) ) { 32 | return 0 33 | } else if( month == 2 ) { 34 | if( day>29 || ((day==29) && (year%4!=0||year%100==0) && (year%400!=0)) ) 35 | return 0 36 | } 37 | printf "%d-%d-%d ", year, month, day 38 | print dow(year, month, day) 39 | return 1 40 | } 41 | BEGIN { 42 | srand('"$NONCE$(date +%s)"') 43 | while(!doRanDate()) {} 44 | }' 45 | } 46 | 47 | # testDate performs the test with a random date 48 | testDate(){ 49 | NONCE=$((NONCE + 1)) 50 | DATE_DOW="$(getDate)" 51 | DATE="${DATE_DOW% *}" 52 | DOW="${DATE_DOW#* }" 53 | echo $DATE 54 | read R 55 | if [ $((R % 7)) = $((DOW % 7)) -a "$R" != "" ]; then 56 | printf '%s\n\n' "Correct!" 57 | return 0 58 | else 59 | printf '%s\n\n' "The correct day of the week is $DOW" 60 | return 1 61 | fi 62 | } 63 | 64 | # The main() 65 | quiz(){ 66 | NONCE=0 67 | ERRORS=0 68 | I=0 69 | START_TIME=`date +%s` 70 | while [ $I -lt $1 ]; do 71 | testDate 72 | RETURN_CODE=$? 73 | ERRORS=$((ERRORS + RETURN_CODE)) 74 | I=$((I + 1)) 75 | done 76 | AVG_TIME=$(awk "BEGIN {print( $(date +%s) - $START_TIME ) / $1}") 77 | SCORE=$(awk "BEGIN {print ( $1 - $ERRORS ) * 100 / $1}") 78 | echo "Average time: $AVG_TIME secs, ${SCORE}% correct" 79 | } 80 | 81 | [ "$1" != "" ] && quiz $1 || quiz $DEFAULT_TIMES 82 | 83 | -------------------------------------------------------------------------------- /bin/test-nt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Compare last modification dates of two files 4 | # Usage: test-nt file1 file2 5 | # Script returns true if file1 is newer than file2 and false otherwise 6 | 7 | [ $# -eq 2 ] || exit 2 8 | 9 | case "$(ls -tdH "$@" 2>/dev/null)" in 10 | $1*$2) exit 0;; 11 | *) exit 1;; 12 | esac 13 | 14 | -------------------------------------------------------------------------------- /bin/test-ot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Compare last modification dates of two files 4 | # Usage: test-ot file1 file2 5 | # Script returns true if file1 is older than file2 and false otherwise 6 | 7 | [ $# -eq 2 ] || exit 2 8 | 9 | case "$(ls -tdH "$@" 2>/dev/null)" in 10 | $2*$1) exit 0;; 11 | *) exit 1;; 12 | esac 13 | 14 | -------------------------------------------------------------------------------- /bin/vimpager: -------------------------------------------------------------------------------- 1 | ../lib/vimpager/vimpager -------------------------------------------------------------------------------- /bin/wman: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clvv/dotfiles/e84233f25cca4a31fcc03754577b15ff390e1a9c/bin/wman --------------------------------------------------------------------------------