From 281b31dae6fd7080b6a8ecef322756d8395f0362 Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Wed, 24 Aug 2022 04:07:33 -0400 Subject: [PATCH] Initial commit --- .gitignore | 8 + a/README.md | 3 + a/bin/consolidate-path | 12 + a/ctags/.ctags | 54 + a/eg/.eg_custom/README.md | 61 + a/eg/.eg_custom/ack.md | 0 a/eg/.eg_custom/bash.md | 75 + a/eg/.eg_custom/csrutil.md | 8 + a/eg/.eg_custom/curl.md | 9 + a/eg/.eg_custom/defaults.md | 5 + a/eg/.eg_custom/git.md | 152 + a/eg/.eg_custom/gnupg.md | 64 + a/eg/.eg_custom/grep.md | 8 + a/eg/.eg_custom/irssi.md | 11 + a/eg/.eg_custom/jira.md | 8 + a/eg/.eg_custom/ln.md | 39 + a/eg/.eg_custom/lsof.md | 5 + a/eg/.eg_custom/mutt.md | 226 ++ a/eg/.eg_custom/nmap.md | 8 + a/eg/.eg_custom/openssl.md | 25 + a/eg/.eg_custom/other.md | 28 + a/eg/.eg_custom/pdftk.md | 10 + a/eg/.eg_custom/rename.md | 6 + a/eg/.eg_custom/sed.md | 0 a/eg/.eg_custom/tar.md | 111 + a/eg/.eg_custom/tmux.md | 92 + a/eg/.eg_custom/uml.md | 50 + a/eg/.eg_custom/vim.md | 5 + a/eg/.eg_custom/youtube-dl.md | 5 + a/eg/.eg_custom/zsh.md | 4 + a/eg/.egrc | 3 + a/git/.git-completion | 2742 +++++++++++++++++ a/git/.gitconfig | 11 + a/install.sh | 6 + a/newsboat/.newsboat/config | 9 + a/newsboat/.newsboat/history.search | 4 + a/newsboat/.newsboat/urls | 38 + a/procs/.procs.toml | 206 ++ a/tmux/.tmux.conf | 64 + a/tmux/.tmuxline_snapshot.conf | 21 + a/tmux/.tmuxp/acorn.json | 26 + a/tmux/.tmuxp/general.json | 16 + a/tmux/.tmuxp/turnip.json | 26 + a/vim/.vim/ftplugin/javascript.vim | 1 + a/vim/.vimrc | 98 + a/zsh/.zshrc | 153 + arch/README.md | 5 + arch/X11/.Xresources | 60 + arch/bin/autoreply/autoreply.sh | 58 + .../autoreply/misdirected_email_autoreply.txt | 12 + arch/bin/conditional-vdirsyncer.sh | 10 + arch/bin/consolidate-path | 13 + arch/bin/facetimehd-reinstall.sh | 65 + arch/bin/failure-notification.sh | 3 + arch/bin/joplin-rename.sh | 19 + arch/bin/notmuch-hook.sh | 7 + arch/bin/w3m-wallabagger.sh | 10 + arch/bin/xmonad-recompile.sh | 3 + arch/fish/config.fish | 44 + arch/fish/fish_variables | 32 + arch/fish/fzf_key_bindings.fish | 172 ++ arch/git/.git-completion | 2742 +++++++++++++++++ arch/git/.gitconfig | 20 + arch/install.sh | 51 + arch/newsboat/.newsboat/config | 27 + arch/newsboat/.newsboat/history.search | 4 + arch/newsboat/.newsboat/urls | 7 + arch/oysttyer/.oysttyerkey | 1 + arch/oysttyer/.oysttyerrc | 11 + arch/post-install.sh | 16 + arch/tmux/.tmux.conf | 82 + arch/tmux/.tmuxline_theme_snapshot | 30 + arch/tmux/.tmuxp/acorn.json | 25 + arch/tmux/.tmuxp/general.json | 8 + arch/tmux/.tmuxp/morning.json | 18 + arch/vim/.vimrc | 105 + arch/xmobar/.xmobarrc | 46 + arch/xmonad/autostart.sh | 14 + arch/xmonad/xmonad.hs | 42 + arch/zsh/.zsh/_keep | 53 + arch/zsh/.zshenv | 49 + arch/zsh/.zshrc | 132 + arch/zsh/aliases.zsh | 2 + arch/zsh/completion.zsh | 75 + arch/zsh/termsupport.zsh | 137 + arch/zsh/theme-and-appearance.zsh | 55 + m/README.md | 21 + m/bin/consolidate-path | 13 + m/eg/.eg_custom/README.md | 61 + m/eg/.eg_custom/ack.md | 0 m/eg/.eg_custom/bash.md | 75 + m/eg/.eg_custom/csrutil.md | 8 + m/eg/.eg_custom/curl.md | 9 + m/eg/.eg_custom/defaults.md | 5 + m/eg/.eg_custom/git.md | 152 + m/eg/.eg_custom/gnupg.md | 64 + m/eg/.eg_custom/grep.md | 8 + m/eg/.eg_custom/irssi.md | 11 + m/eg/.eg_custom/jira.md | 8 + m/eg/.eg_custom/ln.md | 39 + m/eg/.eg_custom/lsof.md | 5 + m/eg/.eg_custom/mutt.md | 226 ++ m/eg/.eg_custom/nmap.md | 8 + m/eg/.eg_custom/openssl.md | 25 + m/eg/.eg_custom/other.md | 28 + m/eg/.eg_custom/pdftk.md | 10 + m/eg/.eg_custom/rename.md | 6 + m/eg/.eg_custom/sed.md | 0 m/eg/.eg_custom/tar.md | 111 + m/eg/.eg_custom/tmux.md | 92 + m/eg/.eg_custom/uml.md | 50 + m/eg/.eg_custom/vim.md | 5 + m/eg/.eg_custom/youtube-dl.md | 5 + m/eg/.eg_custom/zsh.md | 4 + m/eg/.egrc | 3 + m/git/.git-completion | 2742 +++++++++++++++++ m/git/.gitconfig | 5 + m/install.sh | 58 + m/newsboat/.newsboat/config | 10 + m/newsboat/.newsboat/history.search | 0 m/newsboat/.newsboat/urls | 37 + m/oysttyer/.oysttyerkey | 1 + m/oysttyer/.oysttyerrc | 11 + m/post-install.sh | 15 + m/tmux/.tmux.conf | 64 + m/tmux/.tmuxline_theme_snapshot | 21 + m/tmux/.tmuxp/acorn.json | 25 + m/tmux/.tmuxp/general.json | 8 + m/tmux/.tmuxp/morning.json | 18 + m/vim/.vimrc | 96 + m/zsh/.zshrc | 161 + 131 files changed, 13105 insertions(+) create mode 100644 .gitignore create mode 100644 a/README.md create mode 100755 a/bin/consolidate-path create mode 100644 a/ctags/.ctags create mode 100644 a/eg/.eg_custom/README.md create mode 100644 a/eg/.eg_custom/ack.md create mode 100644 a/eg/.eg_custom/bash.md create mode 100644 a/eg/.eg_custom/csrutil.md create mode 100644 a/eg/.eg_custom/curl.md create mode 100644 a/eg/.eg_custom/defaults.md create mode 100644 a/eg/.eg_custom/git.md create mode 100644 a/eg/.eg_custom/gnupg.md create mode 100644 a/eg/.eg_custom/grep.md create mode 100644 a/eg/.eg_custom/irssi.md create mode 100644 a/eg/.eg_custom/jira.md create mode 100644 a/eg/.eg_custom/ln.md create mode 100644 a/eg/.eg_custom/lsof.md create mode 100644 a/eg/.eg_custom/mutt.md create mode 100644 a/eg/.eg_custom/nmap.md create mode 100644 a/eg/.eg_custom/openssl.md create mode 100644 a/eg/.eg_custom/other.md create mode 100644 a/eg/.eg_custom/pdftk.md create mode 100644 a/eg/.eg_custom/rename.md create mode 100644 a/eg/.eg_custom/sed.md create mode 100644 a/eg/.eg_custom/tar.md create mode 100644 a/eg/.eg_custom/tmux.md create mode 100644 a/eg/.eg_custom/uml.md create mode 100644 a/eg/.eg_custom/vim.md create mode 100644 a/eg/.eg_custom/youtube-dl.md create mode 100644 a/eg/.eg_custom/zsh.md create mode 100644 a/eg/.egrc create mode 100644 a/git/.git-completion create mode 100644 a/git/.gitconfig create mode 100644 a/install.sh create mode 100644 a/newsboat/.newsboat/config create mode 100644 a/newsboat/.newsboat/history.search create mode 100644 a/newsboat/.newsboat/urls create mode 100644 a/procs/.procs.toml create mode 100644 a/tmux/.tmux.conf create mode 100644 a/tmux/.tmuxline_snapshot.conf create mode 100644 a/tmux/.tmuxp/acorn.json create mode 100644 a/tmux/.tmuxp/general.json create mode 100644 a/tmux/.tmuxp/turnip.json create mode 100644 a/vim/.vim/ftplugin/javascript.vim create mode 100644 a/vim/.vimrc create mode 100644 a/zsh/.zshrc create mode 100644 arch/README.md create mode 100644 arch/X11/.Xresources create mode 100755 arch/bin/autoreply/autoreply.sh create mode 100644 arch/bin/autoreply/misdirected_email_autoreply.txt create mode 100755 arch/bin/conditional-vdirsyncer.sh create mode 100755 arch/bin/consolidate-path create mode 100755 arch/bin/facetimehd-reinstall.sh create mode 100755 arch/bin/failure-notification.sh create mode 100755 arch/bin/joplin-rename.sh create mode 100755 arch/bin/notmuch-hook.sh create mode 100755 arch/bin/w3m-wallabagger.sh create mode 100755 arch/bin/xmonad-recompile.sh create mode 100644 arch/fish/config.fish create mode 100644 arch/fish/fish_variables create mode 100644 arch/fish/fzf_key_bindings.fish create mode 100644 arch/git/.git-completion create mode 100644 arch/git/.gitconfig create mode 100755 arch/install.sh create mode 100644 arch/newsboat/.newsboat/config create mode 100644 arch/newsboat/.newsboat/history.search create mode 100644 arch/newsboat/.newsboat/urls create mode 100644 arch/oysttyer/.oysttyerkey create mode 100644 arch/oysttyer/.oysttyerrc create mode 100755 arch/post-install.sh create mode 100644 arch/tmux/.tmux.conf create mode 100644 arch/tmux/.tmuxline_theme_snapshot create mode 100644 arch/tmux/.tmuxp/acorn.json create mode 100644 arch/tmux/.tmuxp/general.json create mode 100644 arch/tmux/.tmuxp/morning.json create mode 100644 arch/vim/.vimrc create mode 100644 arch/xmobar/.xmobarrc create mode 100755 arch/xmonad/autostart.sh create mode 100644 arch/xmonad/xmonad.hs create mode 100644 arch/zsh/.zsh/_keep create mode 100644 arch/zsh/.zshenv create mode 100644 arch/zsh/.zshrc create mode 100644 arch/zsh/aliases.zsh create mode 100644 arch/zsh/completion.zsh create mode 100644 arch/zsh/termsupport.zsh create mode 100644 arch/zsh/theme-and-appearance.zsh create mode 100644 m/README.md create mode 100755 m/bin/consolidate-path create mode 100644 m/eg/.eg_custom/README.md create mode 100644 m/eg/.eg_custom/ack.md create mode 100644 m/eg/.eg_custom/bash.md create mode 100644 m/eg/.eg_custom/csrutil.md create mode 100644 m/eg/.eg_custom/curl.md create mode 100644 m/eg/.eg_custom/defaults.md create mode 100644 m/eg/.eg_custom/git.md create mode 100644 m/eg/.eg_custom/gnupg.md create mode 100644 m/eg/.eg_custom/grep.md create mode 100644 m/eg/.eg_custom/irssi.md create mode 100644 m/eg/.eg_custom/jira.md create mode 100644 m/eg/.eg_custom/ln.md create mode 100644 m/eg/.eg_custom/lsof.md create mode 100644 m/eg/.eg_custom/mutt.md create mode 100644 m/eg/.eg_custom/nmap.md create mode 100644 m/eg/.eg_custom/openssl.md create mode 100644 m/eg/.eg_custom/other.md create mode 100644 m/eg/.eg_custom/pdftk.md create mode 100644 m/eg/.eg_custom/rename.md create mode 100644 m/eg/.eg_custom/sed.md create mode 100644 m/eg/.eg_custom/tar.md create mode 100644 m/eg/.eg_custom/tmux.md create mode 100644 m/eg/.eg_custom/uml.md create mode 100644 m/eg/.eg_custom/vim.md create mode 100644 m/eg/.eg_custom/youtube-dl.md create mode 100644 m/eg/.eg_custom/zsh.md create mode 100644 m/eg/.egrc create mode 100644 m/git/.git-completion create mode 100644 m/git/.gitconfig create mode 100755 m/install.sh create mode 100644 m/newsboat/.newsboat/config create mode 100644 m/newsboat/.newsboat/history.search create mode 100644 m/newsboat/.newsboat/urls create mode 100644 m/oysttyer/.oysttyerkey create mode 100644 m/oysttyer/.oysttyerrc create mode 100755 m/post-install.sh create mode 100644 m/tmux/.tmux.conf create mode 100644 m/tmux/.tmuxline_theme_snapshot create mode 100644 m/tmux/.tmuxp/acorn.json create mode 100644 m/tmux/.tmuxp/general.json create mode 100644 m/tmux/.tmuxp/morning.json create mode 100644 m/vim/.vimrc create mode 100644 m/zsh/.zshrc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b3c0db9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.swp +.DS_Store +f/ +**/newsboat/.newsboat/cache.db* +**/newsboat/.newsboat/history.cmdline +**/newsboat/.newsboat/ttrss-pw.txt +**/xmonad/*.hi +**/xmonad/*.o diff --git a/a/README.md b/a/README.md new file mode 100644 index 0000000..6dfe5cc --- /dev/null +++ b/a/README.md @@ -0,0 +1,3 @@ +N.B. .bashrc Linux, .bash_profile Mac + +N.B. install script should correctly install bin/ scripts. diff --git a/a/bin/consolidate-path b/a/bin/consolidate-path new file mode 100755 index 0000000..6ce8991 --- /dev/null +++ b/a/bin/consolidate-path @@ -0,0 +1,12 @@ +#!/bin/bash + +result=":" + +IFS=: + +for p in $1; do + [[ "$result" == *:"$p":* ]] || result="${result}${p}:" +done + +result="${result#:}" +echo "${result%:}" diff --git a/a/ctags/.ctags b/a/ctags/.ctags new file mode 100644 index 0000000..b3e6044 --- /dev/null +++ b/a/ctags/.ctags @@ -0,0 +1,54 @@ +--exclude=.git +--exclude=.hg +--exclude=log +--exclude=tmp + + +--langdef=js +--langmap=js:.js +--langmap=js:+.jsx + +--regex-js=/[ \t.]([A-Z][A-Z0-9._$]+)[ \t]*[=:][ \t]*([0-9"'\[\{]|null)/\1/n,constant/ + +--regex-js=/\.([A-Za-z0-9._$]+)[ \t]*=[ \t]*\{/\1/o,object/ +--regex-js=/['"]*([A-Za-z0-9_$]+)['"]*[ \t]*:[ \t]*\{/\1/o,object/ +--regex-js=/([A-Za-z0-9._$]+)\[["']([A-Za-z0-9_$]+)["']\][ \t]*=[ \t]*\{/\1\.\2/o,object/ + +--regex-js=/([A-Za-z0-9._$]+)[ \t]*=[ \t]*\(function\(\)/\1/c,class/ +--regex-js=/['"]*([A-Za-z0-9_$]+)['"]*:[ \t]*\(function\(\)/\1/c,class/ +--regex-js=/class[ \t]+([A-Za-z0-9._$]+)[ \t]*/\1/c,class/ +--regex-js=/([A-Za-z$][A-Za-z0-9_$()]+)[ \t]*=[ \t]*[Rr]eact.createClass[ \t]*\(/\1/c,class/ +--regex-js=/([A-Z][A-Za-z0-9_$]+)[ \t]*=[ \t]*[A-Za-z0-9_$]*[ \t]*[{(]/\1/c,class/ +--regex-js=/([A-Z][A-Za-z0-9_$]+)[ \t]*:[ \t]*[A-Za-z0-9_$]*[ \t]*[{(]/\1/c,class/ + +--regex-js=/([A-Za-z$][A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\1/f,function/ + +--regex-js=/(function)*[ \t]*([A-Za-z$_][A-Za-z0-9_$]+)[ \t]*\([^)]*\)[ \t]*\{/\2/f,function/ +--regex-js=/['"]*([A-Za-z$][A-Za-z0-9_$]+)['"]*:[ \t]*function[ \t]*\(/\1/m,method/ +--regex-js=/([A-Za-z0-9_$]+)\[["']([A-Za-z0-9_$]+)["']\][ \t]*=[ \t]*function[ \t]*\(/\2/m,method/ + + +--langdef=Rust +--langmap=Rust:.rs +--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]*<[^>]*>)?[ \t]+(([a-zA-Z0-9_:]+)[ \t]*(<[^>]*>)?[ \t]+(for)[ \t]+)?([a-zA-Z0-9_]+)/\4 \6 \7/i,impls,trait implementations/ +--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ + +--langdef=typescript +--langmap=typescript:.ts +--regex-typescript=/^[ \t]*(export)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\2/c,classes/ +--regex-typescript=/^[ \t]*(export)?[ \t]*module[ \t]+([a-zA-Z0-9_]+)/\2/n,modules/ +--regex-typescript=/^[ \t]*(export)?[ \t]*function[ \t]+([a-zA-Z0-9_]+)/\2/f,functions/ +--regex-typescript=/^[ \t]*export[ \t]+var[ \t]+([a-zA-Z0-9_]+)/\1/v,variables/ +--regex-typescript=/^[ \t]*var[ \t]+([a-zA-Z0-9_]+)[ \t]*=[ \t]*function[ \t]*\(\)/\1/v,varlambdas/ +--regex-typescript=/^[ \t]*(export)?[ \t]*(public|private)[ \t]+(static)?[ \t]*([a-zA-Z0-9_]+)/\4/m,members/ +--regex-typescript=/^[ \t]*(export)?[ \t]*interface[ \t]+([a-zA-Z0-9_]+)/\2/i,interfaces/ +--regex-typescript=/^[ \t]*(export)?[ \t]*enum[ \t]+([a-zA-Z0-9_]+)/\2/e,enums/ +--regex-typescript=/^[ \t]*import[ \t]+([a-zA-Z0-9_]+)/\1/I,imports/ + diff --git a/a/eg/.eg_custom/README.md b/a/eg/.eg_custom/README.md new file mode 100644 index 0000000..5ad85e8 --- /dev/null +++ b/a/eg/.eg_custom/README.md @@ -0,0 +1,61 @@ +Cheat Sheets +============ + +> **NOTE**: This repo is best used by placing a bookmark in your address bar. + +This is a collection of cheat sheets that I have compiled over the years that I +put together while learning various tools. They contain some good information +and a few gems that I have learned along the way. Feel free to contribute. + +## Contents + +- [Bash] +- [Git] +- [GnuPG] +- [irssi] +- [JIRA] +- [mutt] +- [nmap] +- [openssl] +- [tmux] +- [uml] +- [vim] +- [zsh] +- [other] + +## License + +
Cheat Sheets +by Joshua Estes is +licensed under a Creative Commons +Attribution-ShareAlike 4.0 International License. Based on a work at https://github.com/JoshuaEstes/CheatSheets. +Permissions beyond the scope of this license may be available at https://github.com/JoshuaEstes/CheatSheets/blob/master/LICENSE. + +See [LICENSE] for full license. + + +[Bash]: https://github.com/JoshuaEstes/CheatSheets/blob/master/bash.md +[Git]: https://github.com/JoshuaEstes/CheatSheets/blob/master/git.md +[GnuPG]: https://github.com/JoshuaEstes/CheatSheets/blob/master/gnupg.md +[irssi]: https://github.com/JoshuaEstes/CheatSheets/blob/master/irssi.md +[JIRA]: https://github.com/JoshuaEstes/CheatSheets/blob/master/jira.md +[mutt]: https://github.com/JoshuaEstes/CheatSheets/blob/master/mutt.md +[nmap]: https://github.com/JoshuaEstes/CheatSheets/blob/master/nmap.md +[openssl]: https://github.com/JoshuaEstes/CheatSheets/blob/master/openssl.md +[tmux]: https://github.com/JoshuaEstes/CheatSheets/blob/master/tmux.md +[uml]: https://github.com/JoshuaEstes/CheatSheets/blob/master/uml.md +[vim]: https://github.com/JoshuaEstes/CheatSheets/blob/master/vim.md +[zsh]: https://github.com/JoshuaEstes/CheatSheets/blob/master/zsh.md +[other]: https://github.com/JoshuaEstes/CheatSheets/blob/master/other.md +[LICENSE]: https://github.com/JoshuaEstes/CheatSheets/blob/master/LICENSE diff --git a/a/eg/.eg_custom/ack.md b/a/eg/.eg_custom/ack.md new file mode 100644 index 0000000..e69de29 diff --git a/a/eg/.eg_custom/bash.md b/a/eg/.eg_custom/bash.md new file mode 100644 index 0000000..3144e29 --- /dev/null +++ b/a/eg/.eg_custom/bash.md @@ -0,0 +1,75 @@ +Bash Cheat Sheet +================ + +## Moving + +| command | description | +|----------|--------------------------------| +| ctrl + a | Goto BEGINNING of command line | +| ctrl + e | Goto END of command line | +| ctrl + b | move back one character | +| ctrl + f | move forward one character | +| alt + f | move cursor FORWARD one word | +| alt + b | move cursor BACK one word | + +## Other + +| command | description | +|----------|--------------------------------| +| ctrl + d | Delete the character under the cursor | +| ctrl + l | Clear the screen (same as clear command) | +| ctrl + p | Fetch the previous command from the history list, moving back in the list (same as up arrow) | +| ctrl + n | Fetch the next command from the history list, moving forward in the list (same as down arrow) | +| ctrl + u | Clear all BEFORE cursor | +| ctrl + k | Clear all AFTER cursor | +| ctrl + r | Search backward starting at the current line and moving 'up' through the history as necessary | +| crtl + s | Search forward starting at the current line and moving 'down' through the history as necessary | +| ctrl + c | kill whatever is running | +| ctrl + d | Exit shell (same as exit command) | +| ctrl + w | delete the word BEFORE the cursor | +| ctrl + t | swap the last two characters before the cursor | +| ctrl + y | paste (if you used a previous command to delete) | +| ctrl + z | Place current process in background | +| ctrl + _ | undo | +| esc + t | Swap last two words before the cursor | +| esc + . | | +| esc + _ | | +| alt + [Backspace] | delete PREVIOUS word | +| alt + < | Move to the first line in the history | +| alt + > | Move to the end of the input history, i.e., the line currently being entered | +| alt + ? | | +| alt + * | | +| alt + . | print the LAST ARGUMENT (ie "vim file1.txt file2.txt" will yield "file2.txt") | +| alt + c | | +| alt + d | | +| alt + l | | +| alt + n | | +| alt + p | | +| alt + r | | +| alt + t | | +| alt + u | | +| ~[TAB][TAB] | List all users | +| $[TAB][TAB] | List all system variables | +| @[TAB][TAB] | List all entries in your /etc/hosts file | +| [TAB] | Auto complete | +| !! | Run PREVIOUS command (ie `sudo !!`) | +| !vi | Run PREVIOUS command that BEGINS with vi | +| cd - | change to PREVIOUS working directory | + +# Kill a job + +n = job number, to list jobs, run `jobs` + +```bash +kill %n +``` + +Example: + +```bash +kill %1 +``` + +## References + +1. http://cnswww.cns.cwru.edu/php/chet/readline/readline.html diff --git a/a/eg/.eg_custom/csrutil.md b/a/eg/.eg_custom/csrutil.md new file mode 100644 index 0000000..a81e838 --- /dev/null +++ b/a/eg/.eg_custom/csrutil.md @@ -0,0 +1,8 @@ +Disable/enable System Integrity Protection + +* Restart the computer +* Hold down `Command-R` to reboot into Recovery Mode +* Click `Utilities` +* Select `Terminal` +* Enter `csrutil [ disable | enable ]` +* Restart the computer into Standard Mode \ No newline at end of file diff --git a/a/eg/.eg_custom/curl.md b/a/eg/.eg_custom/curl.md new file mode 100644 index 0000000..cc8ce6c --- /dev/null +++ b/a/eg/.eg_custom/curl.md @@ -0,0 +1,9 @@ +cURL Cheat Sheet +================ + +## Basics +### Get request + +```bash +curl https://domain.com +``` \ No newline at end of file diff --git a/a/eg/.eg_custom/defaults.md b/a/eg/.eg_custom/defaults.md new file mode 100644 index 0000000..e473d80 --- /dev/null +++ b/a/eg/.eg_custom/defaults.md @@ -0,0 +1,5 @@ +# defaults + +Change the default location of screenshots: + + defaults write com.apple.screencapture location && killall SystemUIServer \ No newline at end of file diff --git a/a/eg/.eg_custom/git.md b/a/eg/.eg_custom/git.md new file mode 100644 index 0000000..e7181dd --- /dev/null +++ b/a/eg/.eg_custom/git.md @@ -0,0 +1,152 @@ +Git Cheat Sheet +=============== + +## Subtree Example + +### Add sub-project as remote + +```bash +git remote add -f RemoteName RemoteUrl +``` + +### Run `git subtree` command + +```bash +git subtree add --prefix Path/To/Put/Code NameOfRemote master --squash +``` + +#### Pull subtree as needed + +```bash +git fetch NameOfRemote master +git subtree pull --prefix Path/To/Put/Code NameOfRemote master --squash +``` + +### Reference + +* http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree + +## Create a branch without a parent + +Very useful when you are updating a project that you are rewriting. For example, +say you are using semantic versioning and are wanting to start a new major +version. + +```bash +git checkout --orphan BRANCH +``` + +## Delete All Branches that have been merged + +Great for cleaning up local branches that aren't being used any more. + +```bash +git checkout master +git branch --merged | grep -v "\*" | xargs -n 1 git branch -d +``` + +## Ignore changes to a file that is being tracked + +### Ignore + +```bash +git update-index --assume-unchanged [directory|file] +``` + +### Unignore + +```bash +git update-index --no-assume-unchanged [directory|file] +``` + +## How to ignore dirty submodules + +Edit your ``.git/config`` and add ``ignore = dirty``. + +```text +[submodule "path/to/submodule"] + path = path/to/submodule + url = git://github.com/username/repo.git + ignore = dirty +``` + +## Clone a repo and give name other than origin + +```bash +git clone -o upstream https://repo.git +``` + +## Ignore Files for Repository without using `.gitignore` + +Add the file `.git/info/exclude` and fill it with the contents you want to ignore. This will ONLY apply to the +repository and will not be tracked by git. + +## Squash Commits + +```bash +git log +``` + +Count the number of commits that you have made, let's say the previous 5 are your commits. + +```bash +git rebase -i HEAD~5 +``` + +The first commit leave as `pick` the rest will need to be changed to `squash`. After that you will be able to +leave a new commit message or just leave as is to keep the commit messages from all previous commits. + +## Search for a specific line of code/file in the history + +```bash +git log -S[search term] +``` + +Example: + +```bash +git log -SThatOneFile.php +``` + +## Copy file from one branch to current branch + +Copy a file from `branch` and put into staging. + +```bash +git checkout BRANCH path/to/file.ext + +# Real Life Examples +git checkout origin/featureBranch web/js/random.js +# Pulls into your current branch web/js/random.js from +# origin/featureBranch +``` + +## Git Grepping for fun and profit! + +```shell +# Basic grep (case sensitive) +$ git grep 'search term' + +# Case Insensitive search +$ git grep -i 'search term' + +# Search within a directory +$ git grep 'search term' src/ + +# Search only files with `php` extension +$ git grep 'search term' -- '*.php' + +# Grep in the 'src/` directory, only yml files +$ git grep 'search term' -- 'src/**.yml' +``` + +## Push Branch to Remote Repository to a different branch name + +```shell +git push origin localBranchName:remoteBranchName +``` + +Use Case: I will often use rebase, I will cut a branch off the branch I want to rebase and +do the rebase on the newly created branch. Once I am done, I will check the diff and see if +I screwed up. If it's all good, `git push -f` **NOTICE**: DO NOT `git push -f` unless you know +what you are doing. diff --git a/a/eg/.eg_custom/gnupg.md b/a/eg/.eg_custom/gnupg.md new file mode 100644 index 0000000..0b740ca --- /dev/null +++ b/a/eg/.eg_custom/gnupg.md @@ -0,0 +1,64 @@ +GnuPG Cheat Sheet +================= + +## Listing Key Pairs + +```bash +gpg --list-keys +``` + +For listing keys with the fingerprint, run + +```bash +gpg --fingerprint +``` + +## Generate New Key Pair + +```bash +gpg --gen-key +``` + +## Encrypt a message on command line + +```bash +echo "Put message here" | gpg --armor --encrypt --recipient Joshua > FILE.gpg +``` + +This will put the encrypted text into `FILE.gpg` which you can send to someone or keep for +later use. For decrypting the message, see the next section. + +## Decrypt a message from the command line + +```bash +cat FILE.gpg | gpg +``` + +Displays the decrypted text on the command line. + +## Only display user X's key information + +```bash +gpg --fingerprint Joshua +``` + +## Signing Messages + +```bash +echo "This is a top secret message" | gpg --clearsign +``` + +## Signing Text Files + +```bash +gpg --clearsign example.txt +``` + +This will create `example.txt.asc` file. + +## Verify Signatures + +```bash +gpg --verifiy example.txt.asc +``` + diff --git a/a/eg/.eg_custom/grep.md b/a/eg/.eg_custom/grep.md new file mode 100644 index 0000000..5a603fc --- /dev/null +++ b/a/eg/.eg_custom/grep.md @@ -0,0 +1,8 @@ +Grep +==== + +## Ignore case + +```shell +grep -i pattern +``` diff --git a/a/eg/.eg_custom/irssi.md b/a/eg/.eg_custom/irssi.md new file mode 100644 index 0000000..d59a218 --- /dev/null +++ b/a/eg/.eg_custom/irssi.md @@ -0,0 +1,11 @@ +Irssi Cheat Sheet +================= + +M = Meta Key, meta key is either the left alt or esc key. + +| command | description | +|----------|-------------| +| M + p | Scroll up in window +| M + n | Scroll down in window +| ctrl + p | Previous window +| ctrl + n | Next window diff --git a/a/eg/.eg_custom/jira.md b/a/eg/.eg_custom/jira.md new file mode 100644 index 0000000..2c957f2 --- /dev/null +++ b/a/eg/.eg_custom/jira.md @@ -0,0 +1,8 @@ +Jira Cheat Sheet +================ + +## Find by Mentions of current user within the past 7 days + +```sql +comment ~ currentUser() AND updatedDate >= -7d +``` diff --git a/a/eg/.eg_custom/ln.md b/a/eg/.eg_custom/ln.md new file mode 100644 index 0000000..0abc4aa --- /dev/null +++ b/a/eg/.eg_custom/ln.md @@ -0,0 +1,39 @@ +# ln + +make a symlink to `foo.txt` + + ln -s foo.txt link-to-foo.txt + + + +# Basic Usage + +Make anchor a link to target: + + ln -s + + + +# Symbolic Links (symlinks) + +Make it symbolic with the `-s` flag: + + $ ln -s foo.txt link-to-foo.txt + $ ls -lF + total 8 + -rw-r--r-- 1 tyrion group 0 Feb 3 14:13 foo.txt + lrwxr-xr-x 1 tyrion group 7 Feb 3 14:14 link-to-foo.txt@ -> foo.txt + + + +# Hard Links + +Omit the `-s` flag: + + $ ln foo.txt hard-link-to-foo.txt + $ ls -lF + total 0 + -rw-r--r-- 2 tyrion group 0B Feb 3 14:13 foo.txt + -rw-r--r-- 2 tyrion group 0B Feb 3 14:13 hard-link-to-foo.txt + + diff --git a/a/eg/.eg_custom/lsof.md b/a/eg/.eg_custom/lsof.md new file mode 100644 index 0000000..cc5bd09 --- /dev/null +++ b/a/eg/.eg_custom/lsof.md @@ -0,0 +1,5 @@ +# lsof + +Examine the process using a specified `port`: + + lsof -i:3000 | grep LISTEN diff --git a/a/eg/.eg_custom/mutt.md b/a/eg/.eg_custom/mutt.md new file mode 100644 index 0000000..b27270f --- /dev/null +++ b/a/eg/.eg_custom/mutt.md @@ -0,0 +1,226 @@ +Mutt Cheat Sheet +================ + +## General + +These key bindings will work on almost any menu you are in. + +| command | description | +|------------|-------------| +| * | Move to last entry +| = | Move to first entry +| : | Enter muttrc command +| > | Scroll down one line +| < | Scroll up one line +| [ | Scroll up half a page +| ] | Scroll down half a page +| ? | Help +| ; | Apply next function to tagged messages only +| ! | Invoke command in subshell +| return | Select the current entry +| esc + / | Search up +| / | Search down +| H | Move to top of page +| j | Move to next entry +| k | Move to previous entry +| ctrl + l | Redraw screen +| L | Move to bottom of page +| M | Move to middle of page +| n | Move to next match of search +| q | Exit menu +| t | Tag current entry +| z | Move to next page +| Z | Move to previous page + +## Index Menu + +When you first open mutt you are in the index menu. + +| command | description | +|---------------|-------------| +| & | Link tagged message to current one +| # | Break the thread in two +| % | Toggle whether mailbox will be rewritten +| . | List mailboxes with new mail +| $ | Save changes to mailbox +| @ | Display full address of sender +| | | Pipe message to a shell command +| esc + tab | Jump to previous new or unread message +| return | Display message +| tab | Jump to next new or unread message +| a | Create alias from message sender +| b | Remail message to another user +| esc + c | Open a different folder (Read Only) +| c | Open a different folder +| esc + C | Make text/plain copy +| C | Copy message to another file/mailbox +| esc + d | Delete all messages in subthread +| d | Delete current message +| ctrl + D | Delete all messages in thread +| D | Delete messages matching a pattern +| esc + e | Use the current message as a template for a new one +| e | Edit the raw message +| ctrl + E | Edit attachment content type +| f | Forward message with comments +| ctrl + F | Wipe passphrase from memory +| F | Toggle the important flag for message +| g | Reply to all +| G | Retrive mail from POP server +| h | Display message and toggle header weeding +| j | Move to next undeleted message +| esc + k | Mail a PGP key +| k | Move to previous undeleted message +| ctrl + K | Extract supported public keys +| esc + l | Show current limit pattern +| l | Only show messages matching a pattern +| L | Reply to specific mailing list +| m | Compose new message +| esc + n | Jump to next subthread +| ctrl + N | Jump to next thread +| N | Toggle new flag +| o | Sort messages +| O | Sort messages in reverse order +| Q | Query external program for addresses +| q | Save changes to mailbox and quit +| r | Reply to message +| ctrl + P | Jump to previous thread +| esc + p | Jump to previous subthread +| p | Print current message +| esc + P | Check for classic PGP +| P | Jump to parent message in thread +| ctrl + R | Mark current thread as read +| R | Recall a postponed message +| esc + r | Mark current subthread as read +| esc + s | Save text/plain copy and delete +| s | Save message/attachment to mailbox/file +| esc + t | Tag current thread +| ctrl + T | Untag messages matching a pattern +| T | Tag messages matching pattern +| esc + u | Undelete all messages in subthread +| u | Undelete current entry +| ctrl + U | Undelete all messages in thread +| U | Undelete messages matching pattern +| esc + v | Collapse/uncollapse current thread +| v | Show mime attachments +| esc + V | Collapse/uncollapse all threads +| V | Show mutt version number and date +| w | Set a status flag +| W | Clear status flags from message + +## Pager Menu + +| command | description | +|---------|-------------| +| # | | +| a | | +| b | | +| c | | +| esc + c | | +| C | | +| esc + C | | +| d | | +| ctrl + D | | +| esc + d | | +| w | | +| W | | +| e | | +| ctrl + E | | +| f | | +| F | | +| g | | +| h | | +| j | | +| J | | +| k | | +| K | | +| & | | +| L | | +| ctrl + L | | +| m | | +| n | | +| N | | +| ctrl + N | | +| esc + n | | +| o | | +| O | | +| p | | +| ctrl + P | | +| esc + p | | +| Q | | +| q | | +| r | | +| R | | +| ctrl + R | | +| esc + r | | +| esc + e | | +| s | | +| S | | +| esc + s | | +| t | | +| T | | +| u | | +| esc + u | | +| ctrl + U | | +| v | | +| V | | +| \\ | | +| @ | | +| | | | +| ? | | +| space | | +| - | | +| ^ | | +| $ | | +| ! | | +| : | | +| . | | +| / | | +| esc + / | | +| return | | +| P | | +| esc + P | | +| esc + k | | +| ctrl + K | | +| ctrl + F | | + +## Useful key remaps + +These need to be placed in your `muttrc` file. I use vim and so I want to use some of the +same commands to manage my mail. + +```muttrc +# Does not replace and currently mapped keys and acts like the vim command gg and takes +# you to the top of the page +bind index gg first-entry + +# Replaces the retrieval of mail from a POP server. This will take you to the bottom of +# the page, just like it does in vim +bind index G last-entry +``` + +## Flags + +When viewing messages in the index menu, you will see various flags such as `N` which mean +the messages is new and `D` which means that the message is to be deleted. This is a short +list of those flags. + +| flag | description | +|------|-------------| +| ! | Message is flagged +| * | Message is tagged +| + | Message is To: you and only you +| C | Message is Cc: to you +| d | Message has attachments marked for deletion +| D | Marked for deletion +| F | Message is From: you +| K | Contains PGP key +| L | Message is sent to a subscribed mailing list +| n | Thread contains new messages (Only when thread is collapsed) +| N | Message is new +| o | Thread contains old messages (Only when thread is collapsed) +| O | Message is old +| P | Message is PGP encrypted +| r | Message has been replied to +| s | Message is signed +| S | Message is signed and verified +| T | Message is to you and has others in To: or Cc: diff --git a/a/eg/.eg_custom/nmap.md b/a/eg/.eg_custom/nmap.md new file mode 100644 index 0000000..2035224 --- /dev/null +++ b/a/eg/.eg_custom/nmap.md @@ -0,0 +1,8 @@ +Nmap Cheat Sheet +================ + +## Scan a Port + +```bash +nmap -p 80 google.com +``` diff --git a/a/eg/.eg_custom/openssl.md b/a/eg/.eg_custom/openssl.md new file mode 100644 index 0000000..b363060 --- /dev/null +++ b/a/eg/.eg_custom/openssl.md @@ -0,0 +1,25 @@ +OpenSSL Cheat Sheet +=================== + +## Generate Self-Signed Certificate and Private Key + +```shell +openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && openssl rsa -passin pass:x -in server.pass.key -out server.key && openssl req -new -key server.key -out server.csr +openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt +``` + +- Use `server.crt` and `server.key` + +### Encypt/Decrypt file + +``` +# Encrypt +openssl aes-128-cbc -a -e -pass pass:test -in vars -out vars.enc +# Puts encrypted data into vars.enc file + +# Decrypt +openssl aes-128-cbc -a -d -pass pass:test -in vars.enc +# Outputs decrypted data to STDOUT +``` + +NOTE: See `openssl passpharse arguments` for information on using the password on the commandline. It can be changed to a file or an environment variable. diff --git a/a/eg/.eg_custom/other.md b/a/eg/.eg_custom/other.md new file mode 100644 index 0000000..5ced564 --- /dev/null +++ b/a/eg/.eg_custom/other.md @@ -0,0 +1,28 @@ +Other Cheat Sheets +================== + +## Using `less` instead of tail + +```shell +less +F -R /path/to/logfile.log +``` + +* To scroll up and down, press `+c` +* Return to tail mode, press `F` + +The `+F` says to follow? The `-R` will process any ANSII color codes. + +## SSH Config File + +``` +# ~/.ssh/config +Host test + HostName testing.example.com + Port 22222 + User joshua + IdentityFile ~/.ssh/test.example.com.key +``` + +Next, all you need to do to ssh into the server is `ssh test` and that's it. + +> **NOTE** `HostName` may be an IP Address instead of a domain name diff --git a/a/eg/.eg_custom/pdftk.md b/a/eg/.eg_custom/pdftk.md new file mode 100644 index 0000000..904620d --- /dev/null +++ b/a/eg/.eg_custom/pdftk.md @@ -0,0 +1,10 @@ +# pdftk + +join a bunch of pdfs + + pdftk file01.pdf file02.pdf file03.pdf cat output combined_file.pdf + + +Add a password to a pdf + + pdftk file.pdf output file_pw.pdf user_pw Passw0rd! diff --git a/a/eg/.eg_custom/rename.md b/a/eg/.eg_custom/rename.md new file mode 100644 index 0000000..ab3d9d1 --- /dev/null +++ b/a/eg/.eg_custom/rename.md @@ -0,0 +1,6 @@ +# rename (concept, not command) + +rename `index.jsx` to `index.tsx` one level down + + for i in **/index.jsx; do mv -v $i ${i/jsx/tsx}; done + diff --git a/a/eg/.eg_custom/sed.md b/a/eg/.eg_custom/sed.md new file mode 100644 index 0000000..e69de29 diff --git a/a/eg/.eg_custom/tar.md b/a/eg/.eg_custom/tar.md new file mode 100644 index 0000000..73c3e2a --- /dev/null +++ b/a/eg/.eg_custom/tar.md @@ -0,0 +1,111 @@ +# tar + +extract .tar file + + tar vfx archive.tar + + +unzip and extract .tar.gz or .tgz file + + tar vfxz g_zipped_archive.tar.gz + + +turn directory into a .tar file + + tar vfc tarred_directory.tar directory + + +turn directory into g-zipped directory + + tar vfcz z_zipped_directory.tar.gz directory + + + +# Basic Usage + +`vf` means verbosely list files (`v`) and use a file (`f`), not `stdin`. +These appear in most commands. + +Untar a file: + + tar vfx + + +Create a tar file from a directory: + + tar vfc + + + +# Remembering the Flags + +`tar` is very finicky. Flags don't need to be prepended by a hyphen, but are +instead bundled into the first word on the command line. A leading hyphen will +break some implementations or require an order. For example, `tar vfx` might +work while with a hyphen it would require `tar -xvf`, with the `x` flag first. +You can get maximum portability is you never use the hyphens, so examples here +are shown without the hyphen. + +You'll almost always want `vf`. `v` verbosely lists files as they are +manipulated, and `f` means you're reading from a file, not `stdin`. You can +remember `vf` if you remember that `tar` is Very Finicky: `vf`. + +Extract things from a tar file with `x` for extraction. Compress things to a +tar file with `c` for compress. + +And you'll have to just remember that g-zipping is `z` and b-zipping is `j`. + + + +# Tarring + +Compress directory (`c`) into g-zipped (`z`) directory: + + tar vfcz z_zipped_directory.tar.gz directory + + +Compress directory (`c`) into b-zipped (`j`) directory: + + tar vfcj b_zipped_directory.tar.bz2 directory + + +Compress directory (`c`) into xz-zipped (`J`) directory: + + tar vfcJ xz_zipped_directory.tar.xz directory + + + +# Untarring + +Untar (`x`) and unzip a g-zipped (`z`) file: + + tar vfxz g_zipped_archive.tar.gz + + +Untar (`x`) and unzip a b-zipped (`j`) file: + + tar vfxj b_zipped_archive.tar.bz2 + + +Untar (`x`) and unzip an xz-zipped (`J`) file: + + tar vfxJ xz_zipped_archive.tar.xz + + + +## Partial Untarring + +Extract only part of the contents (`directory/foo.txt`) from a .tar file: + + tar vfx archived_directory.tar directory/foo.txt + + + +# Display Contents + +List (`t`) the contents of a tar file without untarring it: + + $ tar vft tarred_directory.tar + drwxr-xr-x 0 tyrion group 0 Feb 4 14:54 directory/ + -rw-r--r-- 0 tyrion group 0 Feb 4 14:54 directory/bar.txt + -rw-r--r-- 0 tyrion group 0 Feb 4 14:54 directory/foo.txt diff --git a/a/eg/.eg_custom/tmux.md b/a/eg/.eg_custom/tmux.md new file mode 100644 index 0000000..0569971 --- /dev/null +++ b/a/eg/.eg_custom/tmux.md @@ -0,0 +1,92 @@ +Tmux Cheat Sheet +================ + +`ctrl + b` is default to enter before you enter the commands. `M` = Left Alt key +or ESC key + +## Windows + +| command | description | +|---------|-------------| +| c | Create a new window. +| & | Kill the current window. +| n | Change to the next window. +| p | Change to the previous window. +| , | Rename the current window. +| w | Choose the current window interactively. +| M-n | Move to the next window with a bell or activity marker. +| M-p | Move to the previous window with a bell or activity marker. + +## Panes + +| command | description | +|---------|------------ | +| " | Split the current pane into two, top and bottom. +| % | Split the current pane into two, left and right. +| x | Kill the current pane. +| ; | Move to the previously active pane. +| o | Select the next pane in the current window. +| ! | Break the current pane out of the window. +| q | Briefly display pane indexes. + +## Other + +| command | description | +|---------|-------------| +| d | Detach the current client. +| $ | Rename the current session. +| [ | Enter copy mode to copy text or view the history. +| f | Prompt to search for text in open windows. +| r | Force redraw of the attached client. +| L | Switch the attached client back to the last session. +| : | Enter the tmux command prompt +| ? | List all key bindings +| f | Search window titles and goto that window +| i | Briefly display window information +| r | Force redraw of the attached client. +| s | Select a new session for the attached client interactively. +| t | Show the time. +| = | Choose which buffer to paste interactively from a list. +| ] | Paste the most recently copied buffer of text. +| . | Move window + +## Create a new session + +Any of these will work. + +```bash +tmux +tmux new +tmux new-session +``` + +## Reattach to a session + +Any of these commands will work. + +```bash +tmux at +tmux attach +tmux attach-session +``` + +## List sessions + +Any of these commands will work. + +```bash +tmux ls +tmux list-sessions +``` + +## How to copy and paste + +1. Enter copy-mode `C-b [` +2. Move to text, press `Space` to select text, move cursor to highlight text +3. Press `Enter` +4. Back at the command prompt, press `C-b ]` and the text you selected is pasted + +## References + +* http://man.openbsd.org/OpenBSD-current/man1/tmux.1 + diff --git a/a/eg/.eg_custom/uml.md b/a/eg/.eg_custom/uml.md new file mode 100644 index 0000000..d8ab0d3 --- /dev/null +++ b/a/eg/.eg_custom/uml.md @@ -0,0 +1,50 @@ +UML Cheat Sheet +=============== + + +``` +<> +<> +<> + +- private +# protected ++ public + +name : type = default value +``` + +Examples: + +``` +<> +Name\Space\To\ClassAbstract +--- +- $privateAttribute : string = '' +# $protected : integer = 1 ++ $public : string = 'DefaultValue' +--- ++ getPrivateAttribute() : string ++ getValueForKey($key : string) : mixed ++ get($key : string, $default : mixed = null) : mixed +``` + +``` +Class A "uses" Class B +[Class A]- - - ->[Class B] +``` + +``` +Class A "has a" Class B +[Class A]---->[Class B] +``` + +``` +Company "owns" Employee +[Company]⃟----[Employee] +``` + +``` +Ford "is a" Car +[Car]◁----[Ford] +``` diff --git a/a/eg/.eg_custom/vim.md b/a/eg/.eg_custom/vim.md new file mode 100644 index 0000000..ac55b89 --- /dev/null +++ b/a/eg/.eg_custom/vim.md @@ -0,0 +1,5 @@ +# vim + +paste from clipboard into vim + + "*yy OR "+yy (clarify this) diff --git a/a/eg/.eg_custom/youtube-dl.md b/a/eg/.eg_custom/youtube-dl.md new file mode 100644 index 0000000..4a28b2f --- /dev/null +++ b/a/eg/.eg_custom/youtube-dl.md @@ -0,0 +1,5 @@ +# youtube-dl + +Download a video and convert it to MP4 + + youtube-dl -v -o '%(title)s.%(ext)s' --restrict-filenames --recode-video mp4 qXYh8DmBZek diff --git a/a/eg/.eg_custom/zsh.md b/a/eg/.eg_custom/zsh.md new file mode 100644 index 0000000..0a236f8 --- /dev/null +++ b/a/eg/.eg_custom/zsh.md @@ -0,0 +1,4 @@ +Zsh Cheat Sheet +=============== + +Still haven't got around to digging in a reading the man pages for this yet. diff --git a/a/eg/.egrc b/a/eg/.egrc new file mode 100644 index 0000000..ece0afe --- /dev/null +++ b/a/eg/.egrc @@ -0,0 +1,3 @@ +[eg-config] +examples-dir = ~/builds/eg/eg/examples +custom-dir = ~/.eg_custom diff --git a/a/git/.git-completion b/a/git/.git-completion new file mode 100644 index 0000000..482ca84 --- /dev/null +++ b/a/git/.git-completion @@ -0,0 +1,2742 @@ +# bash/zsh completion support for core Git. +# +# Copyright (C) 2006,2007 Shawn O. Pearce +# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). +# Distributed under the GNU General Public License, version 2.0. +# +# The contained completion routines provide support for completing: +# +# *) local and remote branch names +# *) local and remote tag names +# *) .git/remotes file names +# *) git 'subcommands' +# *) tree paths within 'ref:path/to/file' expressions +# *) file paths within current working directory and index +# *) common --long-options +# +# To use these routines: +# +# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). +# 2) Add the following line to your .bashrc/.zshrc: +# source ~/.git-completion.bash +# 3) Consider changing your PS1 to also show the current branch, +# see git-prompt.sh for details. +# +# If you use complex aliases of form '!f() { ... }; f', you can use the null +# command ':' as the first command in the function body to declare the desired +# completion style. For example '!f() { : git commit ; ... }; f' will +# tell the completion to use commit completion. This also works with aliases +# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". + +case "$COMP_WORDBREAKS" in +*:*) : great ;; +*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" +esac + +# __gitdir accepts 0 or 1 arguments (i.e., location) +# returns location of .git repo +__gitdir () +{ + if [ -z "${1-}" ]; then + if [ -n "${__git_dir-}" ]; then + echo "$__git_dir" + elif [ -n "${GIT_DIR-}" ]; then + test -d "${GIT_DIR-}" || return 1 + echo "$GIT_DIR" + elif [ -d .git ]; then + echo .git + else + git rev-parse --git-dir 2>/dev/null + fi + elif [ -d "$1/.git" ]; then + echo "$1/.git" + else + echo "$1" + fi +} + +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald +# © 2009-2010, Bash Completion Maintainers +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function can be used to access a tokenized list of words +# on the command line: +# +# __git_reassemble_comp_words_by_ref '=:' +# if test "${words_[cword_-1]}" = -w +# then +# ... +# fi +# +# The argument should be a collection of characters from the list of +# word completion separators (COMP_WORDBREAKS) to treat as ordinary +# characters. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude those characters. The intent is to +# make option types like --date= and : easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. +# +# Output: words_, cword_, cur_. + +__git_reassemble_comp_words_by_ref() +{ + local exclude i j first + # Which word separators to exclude? + exclude="${1//[^$COMP_WORDBREAKS]}" + cword_=$COMP_CWORD + if [ -z "$exclude" ]; then + words_=("${COMP_WORDS[@]}") + return + fi + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + return + fi + done + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + done +} + +if ! type _get_comp_words_by_ref >/dev/null 2>&1; then +_get_comp_words_by_ref () +{ + local exclude cur_ words_ cword_ + if [ "$1" = "-n" ]; then + exclude=$2 + shift 2 + fi + __git_reassemble_comp_words_by_ref "$exclude" + cur_=${words_[cword_]} + while [ $# -gt 0 ]; do + case "$1" in + cur) + cur=$cur_ + ;; + prev) + prev=${words_[$cword_-1]} + ;; + words) + words=("${words_[@]}") + ;; + cword) + cword=$cword_ + ;; + esac + shift + done +} +fi + +__gitcompappend () +{ + local x i=${#COMPREPLY[@]} + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +__gitcompadd () +{ + COMPREPLY=() + __gitcompappend "$@" +} + +# Generates completion reply, appending a space to possible completion words, +# if necessary. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp () +{ + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + *) + local c i=0 IFS=$' \t\n' + for c in $1; do + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; + esac +} + +# Variation of __gitcomp_nl () that appends to the existing list of +# completion candidates, COMPREPLY. +__gitcomp_nl_append () +{ + local IFS=$'\n' + __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words, separated by a single newline. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word instead of +# the default space (optional). If specified but empty, nothing is +# appended. +__gitcomp_nl () +{ + COMPREPLY=() + __gitcomp_nl_append "$@" +} + +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + __gitcompadd "$1" "${2-}" "${3-$cur}" "" + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ > /dev/null +} + +# Execute 'git ls-files', unless the --committable option is specified, in +# which case it runs 'git diff-index' to find out the files that can be +# committed. It return paths relative to the directory specified in the first +# argument, and using the options specified in the second argument. +__git_ls_files_helper () +{ + if [ "$2" == "--committable" ]; then + git -C "$1" diff-index --name-only --relative HEAD + else + # NOTE: $2 is not quoted in order to support multiple options + git -C "$1" ls-files --exclude-standard $2 + fi 2>/dev/null +} + + +# __git_index_files accepts 1 or 2 arguments: +# 1: Options to pass to ls-files (required). +# 2: A directory path (optional). +# If provided, only files within the specified directory are listed. +# Sub directories are never recursed. Path must have a trailing +# slash. +__git_index_files () +{ + local dir="$(__gitdir)" root="${2-.}" file + + if [ -d "$dir" ]; then + __git_ls_files_helper "$root" "$1" | + while read -r file; do + case "$file" in + ?*/*) echo "${file%%/*}" ;; + *) echo "$file" ;; + esac + done | sort | uniq + fi +} + +__git_heads () +{ + local dir="$(__gitdir)" + if [ -d "$dir" ]; then + git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + refs/heads + return + fi +} + +__git_tags () +{ + local dir="$(__gitdir)" + if [ -d "$dir" ]; then + git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + refs/tags + return + fi +} + +# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments +# presence of 2nd argument means use the guess heuristic employed +# by checkout for tracking branches +__git_refs () +{ + local i hash dir="$(__gitdir "${1-}")" track="${2-}" + local format refs + if [ -d "$dir" ]; then + case "$cur" in + refs|refs/*) + format="refname" + refs="${cur%/*}" + track="" + ;; + *) + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do + if [ -e "$dir/$i" ]; then echo $i; fi + done + format="refname:short" + refs="refs/tags refs/heads refs/remotes" + ;; + esac + git --git-dir="$dir" for-each-ref --format="%($format)" \ + $refs + if [ -n "$track" ]; then + # employ the heuristic used by git checkout + # Try to find a remote branch that matches the completion word + # but only output if the branch name is unique + local ref entry + git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \ + "refs/remotes/" | \ + while read -r entry; do + eval "$entry" + ref="${ref#*/}" + if [[ "$ref" == "$cur"* ]]; then + echo "$ref" + fi + done | sort | uniq -u + fi + return + fi + case "$cur" in + refs|refs/*) + git ls-remote "$dir" "$cur*" 2>/dev/null | \ + while read -r hash i; do + case "$i" in + *^{}) ;; + *) echo "$i" ;; + esac + done + ;; + *) + echo "HEAD" + git for-each-ref --format="%(refname:short)" -- \ + "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##" + ;; + esac +} + +# __git_refs2 requires 1 argument (to pass to __git_refs) +__git_refs2 () +{ + local i + for i in $(__git_refs "$1"); do + echo "$i:$i" + done +} + +# __git_refs_remotes requires 1 argument (to pass to ls-remote) +__git_refs_remotes () +{ + local i hash + git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \ + while read -r hash i; do + echo "$i:refs/remotes/$1/${i#refs/heads/}" + done +} + +__git_remotes () +{ + local d="$(__gitdir)" + test -d "$d/remotes" && ls -1 "$d/remotes" + git --git-dir="$d" remote +} + +__git_list_merge_strategies () +{ + git merge -s help 2>&1 | + sed -n -e '/[Aa]vailable strategies are: /,/^$/{ + s/\.$// + s/.*:// + s/^[ ]*// + s/[ ]*$// + p + }' +} + +__git_merge_strategies= +# 'git merge -s help' (and thus detection of the merge strategy +# list) fails, unfortunately, if run outside of any git working +# tree. __git_merge_strategies is set to the empty string in +# that case, and the detection will be repeated the next time it +# is needed. +__git_compute_merge_strategies () +{ + test -n "$__git_merge_strategies" || + __git_merge_strategies=$(__git_list_merge_strategies) +} + +__git_complete_revlist_file () +{ + local pfx ls ref cur_="$cur" + case "$cur_" in + *..?*:*) + return + ;; + ?*:*) + ref="${cur_%%:*}" + cur_="${cur_#*:}" + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + ls="$ref:$pfx" + pfx="$pfx/" + ;; + *) + ls="$ref" + ;; + esac + + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="$ref:$pfx" ;; + esac + + __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \ + | sed '/^100... blob /{ + s,^.* ,, + s,$, , + } + /^120000 blob /{ + s,^.* ,, + s,$, , + } + /^040000 tree /{ + s,^.* ,, + s,$,/, + } + s/^.* //')" \ + "$pfx" "$cur_" "" + ;; + *...*) + pfx="${cur_%...*}..." + cur_="${cur_#*...}" + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + ;; + *..*) + pfx="${cur_%..*}.." + cur_="${cur_#*..}" + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac +} + + +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local pfx="" cur_="$cur" + + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + pfx="${pfx}/" + ;; + esac + + __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" +} + +__git_complete_file () +{ + __git_complete_revlist_file +} + +__git_complete_revlist () +{ + __git_complete_revlist_file +} + +__git_complete_remote_or_refspec () +{ + local cur_="$cur" cmd="${words[1]}" + local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 + if [ "$cmd" = "remote" ]; then + ((c++)) + fi + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; + --all) + case "$cmd" in + push) no_complete_refspec=1 ;; + fetch) + return + ;; + *) ;; + esac + ;; + -*) ;; + *) remote="$i"; break ;; + esac + ((c++)) + done + if [ -z "$remote" ]; then + __gitcomp_nl "$(__git_remotes)" + return + fi + if [ $no_complete_refspec = 1 ]; then + return + fi + [ "$remote" = "." ] && remote= + case "$cur_" in + *:*) + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="${cur_%%:*}:" ;; + esac + cur_="${cur_#*:}" + lhs=0 + ;; + +*) + pfx="+" + cur_="${cur_#+}" + ;; + esac + case "$cmd" in + fetch) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + fi + ;; + pull|remote) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + fi + ;; + push) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" + fi + ;; + esac +} + +__git_complete_strategy () +{ + __git_compute_merge_strategies + case "$prev" in + -s|--strategy) + __gitcomp "$__git_merge_strategies" + return 0 + esac + case "$cur" in + --strategy=*) + __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" + return 0 + ;; + esac + return 1 +} + +__git_commands () { + if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}" + then + printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}" + else + git help -a|egrep '^ [a-zA-Z0-9]' + fi +} + +__git_list_all_commands () +{ + local i IFS=" "$'\n' + for i in $(__git_commands) + do + case $i in + *--*) : helper pattern;; + *) echo $i;; + esac + done +} + +__git_all_commands= +__git_compute_all_commands () +{ + test -n "$__git_all_commands" || + __git_all_commands=$(__git_list_all_commands) +} + +__git_list_porcelain_commands () +{ + local i IFS=" "$'\n' + __git_compute_all_commands + for i in $__git_all_commands + do + case $i in + *--*) : helper pattern;; + applymbox) : ask gittus;; + applypatch) : ask gittus;; + archimport) : import;; + cat-file) : plumbing;; + check-attr) : plumbing;; + check-ignore) : plumbing;; + check-mailmap) : plumbing;; + check-ref-format) : plumbing;; + checkout-index) : plumbing;; + commit-tree) : plumbing;; + count-objects) : infrequent;; + credential) : credentials;; + credential-*) : credentials helper;; + cvsexportcommit) : export;; + cvsimport) : import;; + cvsserver) : daemon;; + daemon) : daemon;; + diff-files) : plumbing;; + diff-index) : plumbing;; + diff-tree) : plumbing;; + fast-import) : import;; + fast-export) : export;; + fsck-objects) : plumbing;; + fetch-pack) : plumbing;; + fmt-merge-msg) : plumbing;; + for-each-ref) : plumbing;; + hash-object) : plumbing;; + http-*) : transport;; + index-pack) : plumbing;; + init-db) : deprecated;; + local-fetch) : plumbing;; + ls-files) : plumbing;; + ls-remote) : plumbing;; + ls-tree) : plumbing;; + mailinfo) : plumbing;; + mailsplit) : plumbing;; + merge-*) : plumbing;; + mktree) : plumbing;; + mktag) : plumbing;; + pack-objects) : plumbing;; + pack-redundant) : plumbing;; + pack-refs) : plumbing;; + parse-remote) : plumbing;; + patch-id) : plumbing;; + prune) : plumbing;; + prune-packed) : plumbing;; + quiltimport) : import;; + read-tree) : plumbing;; + receive-pack) : plumbing;; + remote-*) : transport;; + rerere) : plumbing;; + rev-list) : plumbing;; + rev-parse) : plumbing;; + runstatus) : plumbing;; + sh-setup) : internal;; + shell) : daemon;; + show-ref) : plumbing;; + send-pack) : plumbing;; + show-index) : plumbing;; + ssh-*) : transport;; + stripspace) : plumbing;; + symbolic-ref) : plumbing;; + unpack-file) : plumbing;; + unpack-objects) : plumbing;; + update-index) : plumbing;; + update-ref) : plumbing;; + update-server-info) : daemon;; + upload-archive) : plumbing;; + upload-pack) : plumbing;; + write-tree) : plumbing;; + var) : infrequent;; + verify-pack) : infrequent;; + verify-tag) : plumbing;; + *) echo $i;; + esac + done +} + +__git_porcelain_commands= +__git_compute_porcelain_commands () +{ + test -n "$__git_porcelain_commands" || + __git_porcelain_commands=$(__git_list_porcelain_commands) +} + +# Lists all set config variables starting with the given section prefix, +# with the prefix removed. +__git_get_config_variables () +{ + local section="$1" i IFS=$'\n' + for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do + echo "${i#$section.}" + done +} + +__git_pretty_aliases () +{ + __git_get_config_variables "pretty" +} + +__git_aliases () +{ + __git_get_config_variables "alias" +} + +# __git_aliased_command requires 1 argument +__git_aliased_command () +{ + local word cmdline=$(git --git-dir="$(__gitdir)" \ + config --get "alias.$1") + for word in $cmdline; do + case "$word" in + \!gitk|gitk) + echo "gitk" + return + ;; + \!*) : shell command alias ;; + -*) : option ;; + *=*) : setting env ;; + git) : git itself ;; + \(\)) : skip parens of shell function definition ;; + {) : skip start of shell helper function ;; + :) : skip null command ;; + \'*) : skip opening quote after sh -c ;; + *) + echo "$word" + return + esac + done +} + +# __git_find_on_cmdline requires 1 argument +__git_find_on_cmdline () +{ + local word subcommand c=1 + while [ $c -lt $cword ]; do + word="${words[c]}" + for subcommand in $1; do + if [ "$subcommand" = "$word" ]; then + echo "$subcommand" + return + fi + done + ((c++)) + done +} + +__git_has_doubledash () +{ + local c=1 + while [ $c -lt $cword ]; do + if [ "--" = "${words[c]}" ]; then + return 0 + fi + ((c++)) + done + return 1 +} + +# Try to count non option arguments passed on the command line for the +# specified git command. +# When options are used, it is necessary to use the special -- option to +# tell the implementation were non option arguments begin. +# XXX this can not be improved, since options can appear everywhere, as +# an example: +# git mv x -n y +# +# __git_count_arguments requires 1 argument: the git command executed. +__git_count_arguments () +{ + local word i c=0 + + # Skip "git" (first argument) + for ((i=1; i < ${#words[@]}; i++)); do + word="${words[i]}" + + case "$word" in + --) + # Good; we can assume that the following are only non + # option arguments. + ((c = 0)) + ;; + "$1") + # Skip the specified git command and discard git + # main options + ((c = 0)) + ;; + ?*) + ((c++)) + ;; + esac + done + + printf "%d" $c +} + +__git_whitespacelist="nowarn warn error error-all fix" + +_git_am () +{ + local dir="$(__gitdir)" + if [ -d "$dir"/rebase-apply ]; then + __gitcomp "--skip --continue --resolved --abort" + return + fi + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --3way --committer-date-is-author-date --ignore-date + --ignore-whitespace --ignore-space-change + --interactive --keep --no-utf8 --signoff --utf8 + --whitespace= --scissors + " + return + esac +} + +_git_apply () +{ + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --stat --numstat --summary --check --index + --cached --index-info --reverse --reject --unidiff-zero + --apply --no-add --exclude= + --ignore-whitespace --ignore-space-change + --whitespace= --inaccurate-eof --verbose + " + return + esac +} + +_git_add () +{ + case "$cur" in + --*) + __gitcomp " + --interactive --refresh --patch --update --dry-run + --ignore-errors --intent-to-add + " + return + esac + + # XXX should we check for --update and --all options ? + __git_complete_index_file "--others --modified --directory --no-empty-directory" +} + +_git_archive () +{ + case "$cur" in + --format=*) + __gitcomp "$(git archive --list)" "" "${cur##--format=}" + return + ;; + --remote=*) + __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}" + return + ;; + --*) + __gitcomp " + --format= --list --verbose + --prefix= --remote= --exec= + " + return + ;; + esac + __git_complete_file +} + +_git_bisect () +{ + __git_has_doubledash && return + + local subcommands="start bad good skip reset visualize replay log run" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + if [ -f "$(__gitdir)"/BISECT_START ]; then + __gitcomp "$subcommands" + else + __gitcomp "replay start" + fi + return + fi + + case "$subcommand" in + bad|good|reset|skip|start) + __gitcomp_nl "$(__git_refs)" + ;; + *) + ;; + esac +} + +_git_branch () +{ + local i c=1 only_local_ref="n" has_r="n" + + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -d|-m) only_local_ref="y" ;; + -r) has_r="y" ;; + esac + ((c++)) + done + + case "$cur" in + --set-upstream-to=*) + __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}" + ;; + --*) + __gitcomp " + --color --no-color --verbose --abbrev= --no-abbrev + --track --no-track --contains --merged --no-merged + --set-upstream-to= --edit-description --list + --unset-upstream + " + ;; + *) + if [ $only_local_ref = "y" -a $has_r = "n" ]; then + __gitcomp_nl "$(__git_heads)" + else + __gitcomp_nl "$(__git_refs)" + fi + ;; + esac +} + +_git_bundle () +{ + local cmd="${words[2]}" + case "$cword" in + 2) + __gitcomp "create list-heads verify unbundle" + ;; + 3) + # looking for a file + ;; + *) + case "$cmd" in + create) + __git_complete_revlist + ;; + esac + ;; + esac +} + +_git_checkout () +{ + __git_has_doubledash && return + + case "$cur" in + --conflict=*) + __gitcomp "diff3 merge" "" "${cur##--conflict=}" + ;; + --*) + __gitcomp " + --quiet --ours --theirs --track --no-track --merge + --conflict= --orphan --patch + " + ;; + *) + # check if --track, --no-track, or --no-guess was specified + # if so, disable DWIM mode + local flags="--track --no-track --no-guess" track=1 + if [ -n "$(__git_find_on_cmdline "$flags")" ]; then + track='' + fi + __gitcomp_nl "$(__git_refs '' $track)" + ;; + esac +} + +_git_cherry () +{ + __gitcomp_nl "$(__git_refs)" +} + +_git_cherry_pick () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/CHERRY_PICK_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi + case "$cur" in + --*) + __gitcomp "--edit --no-commit --signoff --strategy= --mainline" + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac +} + +_git_clean () +{ + case "$cur" in + --*) + __gitcomp "--dry-run --quiet" + return + ;; + esac + + # XXX should we check for -x option ? + __git_complete_index_file "--others --directory" +} + +_git_clone () +{ + case "$cur" in + --*) + __gitcomp " + --local + --no-hardlinks + --shared + --reference + --quiet + --no-checkout + --bare + --mirror + --origin + --upload-pack + --template= + --depth + --single-branch + --branch + " + return + ;; + esac +} + +_git_commit () +{ + case "$prev" in + -c|-C) + __gitcomp_nl "$(__git_refs)" "" "${cur}" + return + ;; + esac + + case "$cur" in + --cleanup=*) + __gitcomp "default scissors strip verbatim whitespace + " "" "${cur##--cleanup=}" + return + ;; + --reuse-message=*|--reedit-message=*|\ + --fixup=*|--squash=*) + __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" + return + ;; + --untracked-files=*) + __gitcomp "all no normal" "" "${cur##--untracked-files=}" + return + ;; + --*) + __gitcomp " + --all --author= --signoff --verify --no-verify + --edit --no-edit + --amend --include --only --interactive + --dry-run --reuse-message= --reedit-message= + --reset-author --file= --message= --template= + --cleanup= --untracked-files --untracked-files= + --verbose --quiet --fixup= --squash= + " + return + esac + + if git rev-parse --verify --quiet HEAD >/dev/null; then + __git_complete_index_file "--committable" + else + # This is the first commit + __git_complete_index_file "--cached" + fi +} + +_git_describe () +{ + case "$cur" in + --*) + __gitcomp " + --all --tags --contains --abbrev= --candidates= + --exact-match --debug --long --match --always + " + return + esac + __gitcomp_nl "$(__git_refs)" +} + +__git_diff_algorithms="myers minimal patience histogram" + +__git_diff_common_options="--stat --numstat --shortstat --summary + --patch-with-stat --name-only --name-status --color + --no-color --color-words --no-renames --check + --full-index --binary --abbrev --diff-filter= + --find-copies-harder + --text --ignore-space-at-eol --ignore-space-change + --ignore-all-space --ignore-blank-lines --exit-code + --quiet --ext-diff --no-ext-diff + --no-prefix --src-prefix= --dst-prefix= + --inter-hunk-context= + --patience --histogram --minimal + --raw --word-diff + --dirstat --dirstat= --dirstat-by-file + --dirstat-by-file= --cumulative + --diff-algorithm= +" + +_git_diff () +{ + __git_has_doubledash && return + + case "$cur" in + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --*) + __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs --no-index + $__git_diff_common_options + " + return + ;; + esac + __git_complete_revlist_file +} + +__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff + tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare +" + +_git_difftool () +{ + __git_has_doubledash && return + + case "$cur" in + --tool=*) + __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}" + return + ;; + --*) + __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs + --no-renames --diff-filter= --find-copies-harder + --relative --ignore-submodules + --tool=" + return + ;; + esac + __git_complete_revlist_file +} + +__git_fetch_recurse_submodules="yes on-demand no" + +__git_fetch_options=" + --quiet --verbose --append --upload-pack --force --keep --depth= + --tags --no-tags --all --prune --dry-run --recurse-submodules= +" + +_git_fetch () +{ + case "$cur" in + --recurse-submodules=*) + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --*) + __gitcomp "$__git_fetch_options" + return + ;; + esac + __git_complete_remote_or_refspec +} + +__git_format_patch_options=" + --stdout --attach --no-attach --thread --thread= --no-thread + --numbered --start-number --numbered-files --keep-subject --signoff + --signature --no-signature --in-reply-to= --cc= --full-index --binary + --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= + --inline --suffix= --ignore-if-in-upstream --subject-prefix= + --output-directory --reroll-count --to= --quiet --notes +" + +_git_format_patch () +{ + case "$cur" in + --thread=*) + __gitcomp " + deep shallow + " "" "${cur##--thread=}" + return + ;; + --*) + __gitcomp "$__git_format_patch_options" + return + ;; + esac + __git_complete_revlist +} + +_git_fsck () +{ + case "$cur" in + --*) + __gitcomp " + --tags --root --unreachable --cache --no-reflogs --full + --strict --verbose --lost-found + " + return + ;; + esac +} + +_git_gc () +{ + case "$cur" in + --*) + __gitcomp "--prune --aggressive" + return + ;; + esac +} + +_git_gitk () +{ + _gitk +} + +__git_match_ctag() { + awk "/^${1//\//\\/}/ { print \$1 }" "$2" +} + +_git_grep () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp " + --cached + --text --ignore-case --word-regexp --invert-match + --full-name --line-number + --extended-regexp --basic-regexp --fixed-strings + --perl-regexp + --files-with-matches --name-only + --files-without-match + --max-depth + --count + --and --or --not --all-match + " + return + ;; + esac + + case "$cword,$prev" in + 2,*|*,-*) + if test -r tags; then + __gitcomp_nl "$(__git_match_ctag "$cur" tags)" + return + fi + ;; + esac + + __gitcomp_nl "$(__git_refs)" +} + +_git_help () +{ + case "$cur" in + --*) + __gitcomp "--all --info --man --web" + return + ;; + esac + __git_compute_all_commands + __gitcomp "$__git_all_commands $(__git_aliases) + attributes cli core-tutorial cvs-migration + diffcore gitk glossary hooks ignore modules + namespaces repository-layout tutorial tutorial-2 + workflows + " +} + +_git_init () +{ + case "$cur" in + --shared=*) + __gitcomp " + false true umask group all world everybody + " "" "${cur##--shared=}" + return + ;; + --*) + __gitcomp "--quiet --bare --template= --shared --shared=" + return + ;; + esac +} + +_git_ls_files () +{ + case "$cur" in + --*) + __gitcomp "--cached --deleted --modified --others --ignored + --stage --directory --no-empty-directory --unmerged + --killed --exclude= --exclude-from= + --exclude-per-directory= --exclude-standard + --error-unmatch --with-tree= --full-name + --abbrev --ignored --exclude-per-directory + " + return + ;; + esac + + # XXX ignore options like --modified and always suggest all cached + # files. + __git_complete_index_file "--cached" +} + +_git_ls_remote () +{ + __gitcomp_nl "$(__git_remotes)" +} + +_git_ls_tree () +{ + __git_complete_file +} + +# Options that go well for log, shortlog and gitk +__git_log_common_options=" + --not --all + --branches --tags --remotes + --first-parent --merges --no-merges + --max-count= + --max-age= --since= --after= + --min-age= --until= --before= + --min-parents= --max-parents= + --no-min-parents --no-max-parents +" +# Options that go well for log and gitk (not shortlog) +__git_log_gitk_options=" + --dense --sparse --full-history + --simplify-merges --simplify-by-decoration + --left-right --notes --no-notes +" +# Options that go well for log and shortlog (not gitk) +__git_log_shortlog_options=" + --author= --committer= --grep= + --all-match --invert-grep +" + +__git_log_pretty_formats="oneline short medium full fuller email raw format:" +__git_log_date_formats="relative iso8601 rfc2822 short local default raw" + +_git_log () +{ + __git_has_doubledash && return + + local g="$(git rev-parse --git-dir 2>/dev/null)" + local merge="" + if [ -f "$g/MERGE_HEAD" ]; then + merge="--merge" + fi + case "$cur" in + --pretty=*|--format=*) + __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) + " "" "${cur#*=}" + return + ;; + --date=*) + __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" + return + ;; + --decorate=*) + __gitcomp "full short no" "" "${cur##--decorate=}" + return + ;; + --*) + __gitcomp " + $__git_log_common_options + $__git_log_shortlog_options + $__git_log_gitk_options + --root --topo-order --date-order --reverse + --follow --full-diff + --abbrev-commit --abbrev= + --relative-date --date= + --pretty= --format= --oneline + --show-signature + --cherry-pick + --graph + --decorate --decorate= + --walk-reflogs + --parents --children + $merge + $__git_diff_common_options + --pickaxe-all --pickaxe-regex + " + return + ;; + esac + __git_complete_revlist +} + +# Common merge options shared by git-merge(1) and git-pull(1). +__git_merge_options=" + --no-commit --no-stat --log --no-log --squash --strategy + --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit + --verify-signatures --no-verify-signatures --gpg-sign + --quiet --verbose --progress --no-progress +" + +_git_merge () +{ + __git_complete_strategy && return + + case "$cur" in + --*) + __gitcomp "$__git_merge_options + --rerere-autoupdate --no-rerere-autoupdate --abort" + return + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_mergetool () +{ + case "$cur" in + --tool=*) + __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}" + return + ;; + --*) + __gitcomp "--tool=" + return + ;; + esac +} + +_git_merge_base () +{ + case "$cur" in + --*) + __gitcomp "--octopus --independent --is-ancestor --fork-point" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_mv () +{ + case "$cur" in + --*) + __gitcomp "--dry-run" + return + ;; + esac + + if [ $(__git_count_arguments "mv") -gt 0 ]; then + # We need to show both cached and untracked files (including + # empty directories) since this may not be the last argument. + __git_complete_index_file "--cached --others --directory" + else + __git_complete_index_file "--cached" + fi +} + +_git_name_rev () +{ + __gitcomp "--tags --all --stdin" +} + +_git_notes () +{ + local subcommands='add append copy edit list prune remove show' + local subcommand="$(__git_find_on_cmdline "$subcommands")" + + case "$subcommand,$cur" in + ,--*) + __gitcomp '--ref' + ;; + ,*) + case "$prev" in + --ref) + __gitcomp_nl "$(__git_refs)" + ;; + *) + __gitcomp "$subcommands --ref" + ;; + esac + ;; + add,--reuse-message=*|append,--reuse-message=*|\ + add,--reedit-message=*|append,--reedit-message=*) + __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" + ;; + add,--*|append,--*) + __gitcomp '--file= --message= --reedit-message= + --reuse-message=' + ;; + copy,--*) + __gitcomp '--stdin' + ;; + prune,--*) + __gitcomp '--dry-run --verbose' + ;; + prune,*) + ;; + *) + case "$prev" in + -m|-F) + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac + ;; + esac +} + +_git_pull () +{ + __git_complete_strategy && return + + case "$cur" in + --recurse-submodules=*) + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --*) + __gitcomp " + --rebase --no-rebase + $__git_merge_options + $__git_fetch_options + " + return + ;; + esac + __git_complete_remote_or_refspec +} + +__git_push_recurse_submodules="check on-demand" + +__git_complete_force_with_lease () +{ + local cur_=$1 + + case "$cur_" in + --*=) + ;; + *:*) + __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" + ;; + *) + __gitcomp_nl "$(__git_refs)" "" "$cur_" + ;; + esac +} + +_git_push () +{ + case "$prev" in + --repo) + __gitcomp_nl "$(__git_remotes)" + return + ;; + --recurse-submodules) + __gitcomp "$__git_push_recurse_submodules" + return + ;; + esac + case "$cur" in + --repo=*) + __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}" + return + ;; + --recurse-submodules=*) + __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --force-with-lease=*) + __git_complete_force_with_lease "${cur##--force-with-lease=}" + return + ;; + --*) + __gitcomp " + --all --mirror --tags --dry-run --force --verbose + --quiet --prune --delete --follow-tags + --receive-pack= --repo= --set-upstream + --force-with-lease --force-with-lease= --recurse-submodules= + " + return + ;; + esac + __git_complete_remote_or_refspec +} + +_git_rebase () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/rebase-merge/interactive ]; then + __gitcomp "--continue --skip --abort --edit-todo" + return + elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then + __gitcomp "--continue --skip --abort" + return + fi + __git_complete_strategy && return + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --onto --merge --strategy --interactive + --preserve-merges --stat --no-stat + --committer-date-is-author-date --ignore-date + --ignore-whitespace --whitespace= + --autosquash --fork-point --no-fork-point + --autostash + " + + return + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_reflog () +{ + local subcommands="show delete expire" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + else + __gitcomp_nl "$(__git_refs)" + fi +} + +__git_send_email_confirm_options="always never auto cc compose" +__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" + +_git_send_email () +{ + case "$cur" in + --confirm=*) + __gitcomp " + $__git_send_email_confirm_options + " "" "${cur##--confirm=}" + return + ;; + --suppress-cc=*) + __gitcomp " + $__git_send_email_suppresscc_options + " "" "${cur##--suppress-cc=}" + + return + ;; + --smtp-encryption=*) + __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}" + return + ;; + --thread=*) + __gitcomp " + deep shallow + " "" "${cur##--thread=}" + return + ;; + --*) + __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to + --compose --confirm= --dry-run --envelope-sender + --from --identity + --in-reply-to --no-chain-reply-to --no-signed-off-by-cc + --no-suppress-from --no-thread --quiet + --signed-off-by-cc --smtp-pass --smtp-server + --smtp-server-port --smtp-encryption= --smtp-user + --subject --suppress-cc= --suppress-from --thread --to + --validate --no-validate + $__git_format_patch_options" + return + ;; + esac + __git_complete_revlist +} + +_git_stage () +{ + _git_add +} + +__git_config_get_set_variables () +{ + local prevword word config_file= c=$cword + while [ $c -gt 1 ]; do + word="${words[c]}" + case "$word" in + --system|--global|--local|--file=*) + config_file="$word" + break + ;; + -f|--file) + config_file="$word $prevword" + break + ;; + esac + prevword=$word + c=$((--c)) + done + + git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null +} + +_git_config () +{ + case "$prev" in + branch.*.remote|branch.*.pushremote) + __gitcomp_nl "$(__git_remotes)" + return + ;; + branch.*.merge) + __gitcomp_nl "$(__git_refs)" + return + ;; + branch.*.rebase) + __gitcomp "false true" + return + ;; + remote.pushdefault) + __gitcomp_nl "$(__git_remotes)" + return + ;; + remote.*.fetch) + local remote="${prev#remote.}" + remote="${remote%.fetch}" + if [ -z "$cur" ]; then + __gitcomp_nl "refs/heads/" "" "" "" + return + fi + __gitcomp_nl "$(__git_refs_remotes "$remote")" + return + ;; + remote.*.push) + local remote="${prev#remote.}" + remote="${remote%.push}" + __gitcomp_nl "$(git --git-dir="$(__gitdir)" \ + for-each-ref --format='%(refname):%(refname)' \ + refs/heads)" + return + ;; + pull.twohead|pull.octopus) + __git_compute_merge_strategies + __gitcomp "$__git_merge_strategies" + return + ;; + color.branch|color.diff|color.interactive|\ + color.showbranch|color.status|color.ui) + __gitcomp "always never auto" + return + ;; + color.pager) + __gitcomp "false true" + return + ;; + color.*.*) + __gitcomp " + normal black red green yellow blue magenta cyan white + bold dim ul blink reverse + " + return + ;; + diff.submodule) + __gitcomp "log short" + return + ;; + help.format) + __gitcomp "man info web html" + return + ;; + log.date) + __gitcomp "$__git_log_date_formats" + return + ;; + sendemail.aliasesfiletype) + __gitcomp "mutt mailrc pine elm gnus" + return + ;; + sendemail.confirm) + __gitcomp "$__git_send_email_confirm_options" + return + ;; + sendemail.suppresscc) + __gitcomp "$__git_send_email_suppresscc_options" + return + ;; + sendemail.transferencoding) + __gitcomp "7bit 8bit quoted-printable base64" + return + ;; + --get|--get-all|--unset|--unset-all) + __gitcomp_nl "$(__git_config_get_set_variables)" + return + ;; + *.*) + return + ;; + esac + case "$cur" in + --*) + __gitcomp " + --system --global --local --file= + --list --replace-all + --get --get-all --get-regexp + --add --unset --unset-all + --remove-section --rename-section + --name-only + " + return + ;; + branch.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" + return + ;; + branch.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "." + __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_" + return + ;; + guitool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp " + argprompt cmd confirm needsfile noconsole norescan + prompt revprompt revunmerged title + " "$pfx" "$cur_" + return + ;; + difftool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path" "$pfx" "$cur_" + return + ;; + man.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path" "$pfx" "$cur_" + return + ;; + mergetool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" + return + ;; + pager.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __git_compute_all_commands + __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" + return + ;; + remote.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp " + url proxy fetch push mirror skipDefaultUpdate + receivepack uploadpack tagopt pushurl + " "$pfx" "$cur_" + return + ;; + remote.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." + __gitcomp_nl_append "pushdefault" "$pfx" "$cur_" + return + ;; + url.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" + return + ;; + esac + __gitcomp " + add.ignoreErrors + advice.commitBeforeMerge + advice.detachedHead + advice.implicitIdentity + advice.pushNonFastForward + advice.resolveConflict + advice.statusHints + alias. + am.keepcr + apply.ignorewhitespace + apply.whitespace + branch.autosetupmerge + branch.autosetuprebase + browser. + clean.requireForce + color.branch + color.branch.current + color.branch.local + color.branch.plain + color.branch.remote + color.decorate.HEAD + color.decorate.branch + color.decorate.remoteBranch + color.decorate.stash + color.decorate.tag + color.diff + color.diff.commit + color.diff.frag + color.diff.func + color.diff.meta + color.diff.new + color.diff.old + color.diff.plain + color.diff.whitespace + color.grep + color.grep.context + color.grep.filename + color.grep.function + color.grep.linenumber + color.grep.match + color.grep.selected + color.grep.separator + color.interactive + color.interactive.error + color.interactive.header + color.interactive.help + color.interactive.prompt + color.pager + color.showbranch + color.status + color.status.added + color.status.changed + color.status.header + color.status.nobranch + color.status.unmerged + color.status.untracked + color.status.updated + color.ui + commit.status + commit.template + core.abbrev + core.askpass + core.attributesfile + core.autocrlf + core.bare + core.bigFileThreshold + core.compression + core.createObject + core.deltaBaseCacheLimit + core.editor + core.eol + core.excludesfile + core.fileMode + core.fsyncobjectfiles + core.gitProxy + core.ignoreStat + core.ignorecase + core.logAllRefUpdates + core.loosecompression + core.notesRef + core.packedGitLimit + core.packedGitWindowSize + core.pager + core.preferSymlinkRefs + core.preloadindex + core.quotepath + core.repositoryFormatVersion + core.safecrlf + core.sharedRepository + core.sparseCheckout + core.symlinks + core.trustctime + core.warnAmbiguousRefs + core.whitespace + core.worktree + diff.autorefreshindex + diff.external + diff.ignoreSubmodules + diff.mnemonicprefix + diff.noprefix + diff.renameLimit + diff.renames + diff.statGraphWidth + diff.submodule + diff.suppressBlankEmpty + diff.tool + diff.wordRegex + diff.algorithm + difftool. + difftool.prompt + fetch.recurseSubmodules + fetch.unpackLimit + format.attach + format.cc + format.coverLetter + format.headers + format.numbered + format.pretty + format.signature + format.signoff + format.subjectprefix + format.suffix + format.thread + format.to + gc. + gc.aggressiveWindow + gc.auto + gc.autopacklimit + gc.packrefs + gc.pruneexpire + gc.reflogexpire + gc.reflogexpireunreachable + gc.rerereresolved + gc.rerereunresolved + gitcvs.allbinary + gitcvs.commitmsgannotation + gitcvs.dbTableNamePrefix + gitcvs.dbdriver + gitcvs.dbname + gitcvs.dbpass + gitcvs.dbuser + gitcvs.enabled + gitcvs.logfile + gitcvs.usecrlfattr + guitool. + gui.blamehistoryctx + gui.commitmsgwidth + gui.copyblamethreshold + gui.diffcontext + gui.encoding + gui.fastcopyblame + gui.matchtrackingbranch + gui.newbranchtemplate + gui.pruneduringfetch + gui.spellingdictionary + gui.trustmtime + help.autocorrect + help.browser + help.format + http.lowSpeedLimit + http.lowSpeedTime + http.maxRequests + http.minSessions + http.noEPSV + http.postBuffer + http.proxy + http.sslCipherList + http.sslVersion + http.sslCAInfo + http.sslCAPath + http.sslCert + http.sslCertPasswordProtected + http.sslKey + http.sslVerify + http.useragent + i18n.commitEncoding + i18n.logOutputEncoding + imap.authMethod + imap.folder + imap.host + imap.pass + imap.port + imap.preformattedHTML + imap.sslverify + imap.tunnel + imap.user + init.templatedir + instaweb.browser + instaweb.httpd + instaweb.local + instaweb.modulepath + instaweb.port + interactive.singlekey + log.date + log.decorate + log.showroot + mailmap.file + man. + man.viewer + merge. + merge.conflictstyle + merge.log + merge.renameLimit + merge.renormalize + merge.stat + merge.tool + merge.verbosity + mergetool. + mergetool.keepBackup + mergetool.keepTemporaries + mergetool.prompt + notes.displayRef + notes.rewrite. + notes.rewrite.amend + notes.rewrite.rebase + notes.rewriteMode + notes.rewriteRef + pack.compression + pack.deltaCacheLimit + pack.deltaCacheSize + pack.depth + pack.indexVersion + pack.packSizeLimit + pack.threads + pack.window + pack.windowMemory + pager. + pretty. + pull.octopus + pull.twohead + push.default + push.followTags + rebase.autosquash + rebase.stat + receive.autogc + receive.denyCurrentBranch + receive.denyDeleteCurrent + receive.denyDeletes + receive.denyNonFastForwards + receive.fsckObjects + receive.unpackLimit + receive.updateserverinfo + remote.pushdefault + remotes. + repack.usedeltabaseoffset + rerere.autoupdate + rerere.enabled + sendemail. + sendemail.aliasesfile + sendemail.aliasfiletype + sendemail.bcc + sendemail.cc + sendemail.cccmd + sendemail.chainreplyto + sendemail.confirm + sendemail.envelopesender + sendemail.from + sendemail.identity + sendemail.multiedit + sendemail.signedoffbycc + sendemail.smtpdomain + sendemail.smtpencryption + sendemail.smtppass + sendemail.smtpserver + sendemail.smtpserveroption + sendemail.smtpserverport + sendemail.smtpuser + sendemail.suppresscc + sendemail.suppressfrom + sendemail.thread + sendemail.to + sendemail.validate + showbranch.default + status.relativePaths + status.showUntrackedFiles + status.submodulesummary + submodule. + tar.umask + transfer.unpackLimit + url. + user.email + user.name + user.signingkey + web.browser + branch. remote. + " +} + +_git_remote () +{ + local subcommands="add rename remove set-head set-branches set-url show prune update" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + return + fi + + case "$subcommand" in + rename|remove|set-url|show|prune) + __gitcomp_nl "$(__git_remotes)" + ;; + set-head|set-branches) + __git_complete_remote_or_refspec + ;; + update) + __gitcomp "$(__git_get_config_variables "remotes")" + ;; + *) + ;; + esac +} + +_git_replace () +{ + __gitcomp_nl "$(__git_refs)" +} + +_git_reset () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp "--merge --mixed --hard --soft --patch" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_revert () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/REVERT_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi + case "$cur" in + --*) + __gitcomp "--edit --mainline --no-edit --no-commit --signoff" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_rm () +{ + case "$cur" in + --*) + __gitcomp "--cached --dry-run --ignore-unmatch --quiet" + return + ;; + esac + + __git_complete_index_file "--cached" +} + +_git_shortlog () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp " + $__git_log_common_options + $__git_log_shortlog_options + --numbered --summary + " + return + ;; + esac + __git_complete_revlist +} + +_git_show () +{ + __git_has_doubledash && return + + case "$cur" in + --pretty=*|--format=*) + __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) + " "" "${cur#*=}" + return + ;; + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --*) + __gitcomp "--pretty= --format= --abbrev-commit --oneline + --show-signature + $__git_diff_common_options + " + return + ;; + esac + __git_complete_revlist_file +} + +_git_show_branch () +{ + case "$cur" in + --*) + __gitcomp " + --all --remotes --topo-order --current --more= + --list --independent --merge-base --no-name + --color --no-color + --sha1-name --sparse --topics --reflog + " + return + ;; + esac + __git_complete_revlist +} + +_git_stash () +{ + local save_opts='--keep-index --no-keep-index --quiet --patch' + local subcommands='save list show apply clear drop pop create branch' + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + case "$cur" in + --*) + __gitcomp "$save_opts" + ;; + *) + if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then + __gitcomp "$subcommands" + fi + ;; + esac + else + case "$subcommand,$cur" in + save,--*) + __gitcomp "$save_opts" + ;; + apply,--*|pop,--*) + __gitcomp "--index --quiet" + ;; + show,--*|drop,--*|branch,--*) + ;; + show,*|apply,*|drop,*|pop,*|branch,*) + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ + | sed -n -e 's/:.*//p')" + ;; + *) + ;; + esac + fi +} + +_git_submodule () +{ + __git_has_doubledash && return + + local subcommands="add status init deinit update summary foreach sync" + if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then + case "$cur" in + --*) + __gitcomp "--quiet --cached" + ;; + *) + __gitcomp "$subcommands" + ;; + esac + return + fi +} + +_git_svn () +{ + local subcommands=" + init fetch clone rebase dcommit log find-rev + set-tree commit-diff info create-ignore propget + proplist show-ignore show-externals branch tag blame + migrate mkdirs reset gc + " + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + else + local remote_opts="--username= --config-dir= --no-auth-cache" + local fc_opts=" + --follow-parent --authors-file= --repack= + --no-metadata --use-svm-props --use-svnsync-props + --log-window-size= --no-checkout --quiet + --repack-flags --use-log-author --localtime + --ignore-paths= --include-paths= $remote_opts + " + local init_opts=" + --template= --shared= --trunk= --tags= + --branches= --stdlayout --minimize-url + --no-metadata --use-svm-props --use-svnsync-props + --rewrite-root= --prefix= --use-log-author + --add-author-from $remote_opts + " + local cmt_opts=" + --edit --rmdir --find-copies-harder --copy-similarity= + " + + case "$subcommand,$cur" in + fetch,--*) + __gitcomp "--revision= --fetch-all $fc_opts" + ;; + clone,--*) + __gitcomp "--revision= $fc_opts $init_opts" + ;; + init,--*) + __gitcomp "$init_opts" + ;; + dcommit,--*) + __gitcomp " + --merge --strategy= --verbose --dry-run + --fetch-all --no-rebase --commit-url + --revision --interactive $cmt_opts $fc_opts + " + ;; + set-tree,--*) + __gitcomp "--stdin $cmt_opts $fc_opts" + ;; + create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ + show-externals,--*|mkdirs,--*) + __gitcomp "--revision=" + ;; + log,--*) + __gitcomp " + --limit= --revision= --verbose --incremental + --oneline --show-commit --non-recursive + --authors-file= --color + " + ;; + rebase,--*) + __gitcomp " + --merge --verbose --strategy= --local + --fetch-all --dry-run $fc_opts + " + ;; + commit-diff,--*) + __gitcomp "--message= --file= --revision= $cmt_opts" + ;; + info,--*) + __gitcomp "--url" + ;; + branch,--*) + __gitcomp "--dry-run --message --tag" + ;; + tag,--*) + __gitcomp "--dry-run --message" + ;; + blame,--*) + __gitcomp "--git-format" + ;; + migrate,--*) + __gitcomp " + --config-dir= --ignore-paths= --minimize + --no-auth-cache --username= + " + ;; + reset,--*) + __gitcomp "--revision= --parent" + ;; + *) + ;; + esac + fi +} + +_git_tag () +{ + local i c=1 f=0 + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -d|-v) + __gitcomp_nl "$(__git_tags)" + return + ;; + -f) + f=1 + ;; + esac + ((c++)) + done + + case "$prev" in + -m|-F) + ;; + -*|tag) + if [ $f = 1 ]; then + __gitcomp_nl "$(__git_tags)" + fi + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac + + case "$cur" in + --*) + __gitcomp " + --list --delete --verify --annotate --message --file + --sign --cleanup --local-user --force --column --sort + --contains --points-at + " + ;; + esac +} + +_git_whatchanged () +{ + _git_log +} + +__git_main () +{ + local i c=1 command __git_dir + + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + --git-dir=*) __git_dir="${i#--git-dir=}" ;; + --git-dir) ((c++)) ; __git_dir="${words[c]}" ;; + --bare) __git_dir="." ;; + --help) command="help"; break ;; + -c|--work-tree|--namespace) ((c++)) ;; + -*) ;; + *) command="$i"; break ;; + esac + ((c++)) + done + + if [ -z "$command" ]; then + case "$cur" in + --*) __gitcomp " + --paginate + --no-pager + --git-dir= + --bare + --version + --exec-path + --exec-path= + --html-path + --man-path + --info-path + --work-tree= + --namespace= + --no-replace-objects + --help + " + ;; + *) __git_compute_porcelain_commands + __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; + esac + return + fi + + local completion_func="_git_${command//-/_}" + declare -f $completion_func >/dev/null && $completion_func && return + + local expansion=$(__git_aliased_command "$command") + if [ -n "$expansion" ]; then + words[1]=$expansion + completion_func="_git_${expansion//-/_}" + declare -f $completion_func >/dev/null && $completion_func + fi +} + +__gitk_main () +{ + __git_has_doubledash && return + + local g="$(__gitdir)" + local merge="" + if [ -f "$g/MERGE_HEAD" ]; then + merge="--merge" + fi + case "$cur" in + --*) + __gitcomp " + $__git_log_common_options + $__git_log_gitk_options + $merge + " + return + ;; + esac + __git_complete_revlist +} + +if [[ -n ${ZSH_VERSION-} ]]; then + echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 + + autoload -U +X compinit && compinit + + __gitcomp () + { + emulate -L zsh + + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + *) + local c IFS=$' \t\n' + local -a array + for c in ${=1}; do + c="$c${4-}" + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + array[${#array[@]}+1]="$c" + done + compset -P '*[=:]' + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 + ;; + esac + } + + __gitcomp_nl () + { + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + } + + __gitcomp_file () + { + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 + } + + _git () + { + local _ret=1 cur cword prev + cur=${words[CURRENT]} + prev=${words[CURRENT-1]} + let cword=CURRENT-1 + emulate ksh -c __${service}_main + let _ret && _default && _ret=0 + return _ret + } + + compdef _git git gitk + return +fi + +__git_func_wrap () +{ + local cur words cword prev + _get_comp_words_by_ref -n =: cur words cword prev + $1 +} + +# Setup completion for certain functions defined above by setting common +# variables and workarounds. +# This is NOT a public function; use at your own risk. +__git_complete () +{ + local wrapper="__git_wrap${2}" + eval "$wrapper () { __git_func_wrap $2 ; }" + complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \ + || complete -o default -o nospace -F $wrapper $1 +} + +# wrapper for backwards compatibility +_git () +{ + __git_wrap__git_main +} + +# wrapper for backwards compatibility +_gitk () +{ + __git_wrap__gitk_main +} + +__git_complete git __git_main +__git_complete gitk __gitk_main + +# The following are necessary only for Cygwin, and only are needed +# when the user has tab-completed the executable name and consequently +# included the '.exe' suffix. +# +if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then +__git_complete git.exe __git_main +fi diff --git a/a/git/.gitconfig b/a/git/.gitconfig new file mode 100644 index 0000000..0ce3104 --- /dev/null +++ b/a/git/.gitconfig @@ -0,0 +1,11 @@ +[user] + name = Adam Cooper + email = theadamcooper@protonmail.com +[core] + pager = diff-so-fancy | less --tabs=4 -RFX + editor = vim +[filter "lfs"] + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f + process = git-lfs filter-process + required = true diff --git a/a/install.sh b/a/install.sh new file mode 100644 index 0000000..ad22c74 --- /dev/null +++ b/a/install.sh @@ -0,0 +1,6 @@ +# This script should install oh-my-zsh and vim-plug +# oh-my-zsh +sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" + +# vim-plug +curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim diff --git a/a/newsboat/.newsboat/config b/a/newsboat/.newsboat/config new file mode 100644 index 0000000..91a37ba --- /dev/null +++ b/a/newsboat/.newsboat/config @@ -0,0 +1,9 @@ +color background black default +color listnormal black default +color listfocus white blue +color listnormal_unread magenta default +color listfocus_unread white blue bold +color info white blue +color article black default +max-items 4096 +keep-articles-days 45 diff --git a/a/newsboat/.newsboat/history.search b/a/newsboat/.newsboat/history.search new file mode 100644 index 0000000..12d25ce --- /dev/null +++ b/a/newsboat/.newsboat/history.search @@ -0,0 +1,4 @@ +finger +finger +finger +selfie diff --git a/a/newsboat/.newsboat/urls b/a/newsboat/.newsboat/urls new file mode 100644 index 0000000..e8bb1c5 --- /dev/null +++ b/a/newsboat/.newsboat/urls @@ -0,0 +1,38 @@ +http://feeds.guardian.co.uk/theguardian/world/rss "nuggets" +http://www.wsws.org/rss/en.xml "nuggets" +http://www.democracynow.org/democracynow.rss "nuggets" +http://news.ycombinator.com/rss "tech" +https://lobste.rs/rss "tech" +http://www.languagehat.com/index.rdf "linguistics" +http://www.opengeodata.org/?feed=rss2 "tech" +http://feeds.arstechnica.com/arstechnica/index/ "tech" +http://feeds.feedburner.com/TheCssAwards "tech" +http://feeds.feedburner.com/CssTricks "tech" +https://protonvpn.com/blog/feed/ "tech" +https://cloudblog.withgoogle.com/rss/ "tech" +https://spreadprivacy.com/feed "tech" +https://protonmail.ch/blog/feed/ "tech" +https://os.phil-opp.com/rss.xml "tech" +http://www.bleepingcomputer.com/feed/ "tech" +https://mondediplo.com/backend "nuggets" +http://feeds.feedburner.com/Metafilter "nuggets" +http://feeds.feedburner.com/InTheseTimes "nuggets" +http://whowhatwhy.com/feed/ "nuggets" +http://jacobinmag.com/feed/ "nuggets" +http://www.thebaffler.com/blog/rss "nuggets" +http://www.dissentmagazine.org/feed "nuggets" +https://www.govtrack.us/events/events.rss?feeds=bill%3As116-1489 "nuggets" +https://www.govtrack.us/events/events.rss?feeds=bill%3Ah116-2728 "nuggets" +https://www.govtrack.us/events/events.rss?feeds=bill%3Ah116-2065 "nuggets" +https://harpers.org/feed/ "nuggets" +http://feeds.propublica.org/propublica/nerds "nuggets" +http://feeds.propublica.org/propublica/main "nuggets" +http://www.counterpunch.org/feed/ "nuggets" +http://thenewinquiry.com/rss "nuggets" +http://editor.currentaffairs.org/feed/ "nuggets" +https://www.truthdig.com/feed/ "nuggets" +http://googletesting.blogspot.com/feeds/posts/default "webdev" +http://javascriptweekly.com/rss "webdev" +http://feeds.feedburner.com/Bludice "webdev" +https://reactjs.org/feed.xml "webdev" +https://theintercept.com/feed/?lang=en "nuggets" diff --git a/a/procs/.procs.toml b/a/procs/.procs.toml new file mode 100644 index 0000000..6c04495 --- /dev/null +++ b/a/procs/.procs.toml @@ -0,0 +1,206 @@ +[[columns]] +kind = "Pid" +style = "BrightYellow" +numeric_search = true +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "User" +style = "BrightGreen" +numeric_search = false +nonnumeric_search = true +align = "Left" + +[[columns]] +kind = "Separator" +style = "Magenta" +numeric_search = false +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "State" +style = "ByState" +numeric_search = false +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "Nice" +style = "BrightMagenta" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "Tty" +style = "Blue" +numeric_search = false +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "UsageCpu" +style = "ByPercentage" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "UsageMem" +style = "ByPercentage" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "VmSize" +style = "ByUnit" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "VmRss" +style = "ByUnit" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "TcpPort" +style = "BrightCyan" +numeric_search = true +nonnumeric_search = false +align = "Left" +max_width = 20 + +[[columns]] +kind = "UdpPort" +style = "BrightCyan" +numeric_search = true +nonnumeric_search = false +align = "Left" +max_width = 20 + +[[columns]] +kind = "ReadBytes" +style = "ByUnit" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "WriteBytes" +style = "ByUnit" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "Slot" +style = "ByUnit" +numeric_search = false +nonnumeric_search = false +align = "Right" + +[[columns]] +kind = "Separator" +style = "Magenta" +numeric_search = false +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "CpuTime" +style = "BrightCyan" +numeric_search = false +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "StartTime" +style = "BrightMagenta" +numeric_search = false +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "Docker" +style = "BrightGreen" +numeric_search = false +nonnumeric_search = true +align = "Left" + +[[columns]] +kind = "Separator" +style = "Magenta" +numeric_search = false +nonnumeric_search = false +align = "Left" + +[[columns]] +kind = "Command" +style = "Blue" +numeric_search = false +nonnumeric_search = true +align = "Left" + +[style] +header = "Blue" +unit = "Blue" + +[style.by_percentage] +color_000 = "BrightBlue" +color_025 = "BrightGreen" +color_050 = "BrightYellow" +color_075 = "BrightRed" +color_100 = "BrightRed" + +[style.by_state] +color_d = "BrightRed" +color_r = "BrightGreen" +color_s = "BrightBlue" +color_t = "BrightCyan" +color_z = "BrightMagenta" +color_x = "BrightMagenta" +color_k = "BrightYellow" +color_w = "BrightYellow" +color_p = "BrightYellow" + +[style.by_unit] +color_k = "BrightBlue" +color_m = "BrightGreen" +color_g = "BrightYellow" +color_t = "BrightRed" +color_p = "BrightRed" +color_x = "BrightBlue" + +[search] +numeric_search = "Exact" +nonnumeric_search = "Partial" +logic = "And" + +[display] +show_self = false +cut_to_terminal = true +cut_to_pager = false +cut_to_pipe = false +color_mode = "Auto" +separator = "│" +ascending = "▲" +descending = "▼" +tree_symbols = ["│", "─", "┬", "├", "└"] +abbr_sid = true + +[sort] +column = 0 +order = "Ascending" + +[docker] +path = "unix:///var/run/docker.sock" + +[pager] +mode = "Auto" + diff --git a/a/tmux/.tmux.conf b/a/tmux/.tmux.conf new file mode 100644 index 0000000..b2bfbf3 --- /dev/null +++ b/a/tmux/.tmux.conf @@ -0,0 +1,64 @@ +# 256 colors for vim +set -g default-terminal "screen-256color" + +# Set default shell to zsh +set-option -g default-shell /bin/zsh + +# Tmuxline +if-shell "test -f ~/.tmuxline_snapshot.conf" "source ~/.tmuxline_snapshot.conf" + +# Start window numbering at 1 +set-option -g base-index 1 +set-window-option -g pane-base-index 1 + +# Cycle panes with C-b C-b +unbind ^B +bind ^B select-pane -t :.+ + +# Reload config wtih a key +bind-key r source-file ~/.tmux.conf \; display "Config reloaded!" + +# Mouse works as expected +set -g mouse on +# set -g mode-mouse on +# set -g mouse-select-pane on +# set -g mouse-resize-pane on +# set -g mouse-select-window on + +# Scrolling works as expected +set -g terminal-overrides 'xterm*:smcup@:rmcup@' + +# Use the system clipboard +# set-option -g default-command "reattach-to-user-namespace -l zsh" + +# Clear the pane and its history +bind -n C-k send-keys C-l \; clear-history + +# Smart pane switching with awareness of vim splits +# From github.com/christoomey/vim-tmux-navigator +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind-key -n C-\\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" +bind-key -T copy-mode-vi C-h select-pane -L +bind-key -T copy-mode-vi C-j select-pane -D +bind-key -T copy-mode-vi C-k select-pane -U +bind-key -T copy-mode-vi C-l select-pane -R +bind-key -T copy-mode-vi C-\\ select-pane -l + +# C-l is taken over by vim style pane navigation (not sure where this comes from or whether I still need this) +bind C-l send-keys 'C-l' + +# Use vim keybindings in copy mode +setw -g mode-keys vi + +# Setup 'v' to begin selection as in Vim +# bind-key -t vi-copy v begin-selection +# bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" + +# Update default binding of `Enter` to also use copy-pipe +# unbind -t vi-copy Enter +# bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy" diff --git a/a/tmux/.tmuxline_snapshot.conf b/a/tmux/.tmuxline_snapshot.conf new file mode 100644 index 0000000..65c8ddf --- /dev/null +++ b/a/tmux/.tmuxline_snapshot.conf @@ -0,0 +1,21 @@ +# This tmux statusbar config was created by tmuxline.vim +# on Mon, 13 Jul 2020 + +set -g status-justify "left" +set -g status "on" +set -g status-left-style "none" +set -g message-command-style "fg=colour18,bg=colour45" +set -g status-right-style "none" +set -g pane-active-border-style "fg=colour27" +set -g status-style "none,bg=colour159" +set -g message-style "fg=colour18,bg=colour45" +set -g pane-border-style "fg=colour45" +set -g status-right-length "100" +set -g status-left-length "100" +setw -g window-status-activity-style "none" +setw -g window-status-separator "" +setw -g window-status-style "none,fg=colour27,bg=colour159" +set -g status-left "#[fg=colour255,bg=colour27] #S #[fg=colour27,bg=colour159,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=colour45,bg=colour159,nobold,nounderscore,noitalics]#[fg=colour18,bg=colour45] %Y-%m-%d  %H:%M #[fg=colour27,bg=colour45,nobold,nounderscore,noitalics]#[fg=colour255,bg=colour27] #h " +setw -g window-status-format "#[fg=colour27,bg=colour159] #I #[fg=colour27,bg=colour159] #W " +setw -g window-status-current-format "#[fg=colour159,bg=colour45,nobold,nounderscore,noitalics]#[fg=colour18,bg=colour45] #I #[fg=colour18,bg=colour45] #W #[fg=colour45,bg=colour159,nobold,nounderscore,noitalics]" diff --git a/a/tmux/.tmuxp/acorn.json b/a/tmux/.tmuxp/acorn.json new file mode 100644 index 0000000..34022bc --- /dev/null +++ b/a/tmux/.tmuxp/acorn.json @@ -0,0 +1,26 @@ +{ + "session_name": "acorn", + "windows": [{ + "window_name": "ide", + "panes": [ + "vim -R package.json", + "ls", + "git status" + ], + "layout": "main-horizontal", + "main-pane-height": 32, + "start_directory": "~/code/acorn-glen" + }, { + "window_name": "servers", + "start_directory": "~/code/acorn-glen", + "layout": "main-horizontal", + "panes": [{ + "shell_command": [ "cd ~/code/acorn-glen", "echo 'yarn dev'" ] + }, { + "shell_command": [ "sleep 4", "echo 'yarn relay --watch'" ] + }, { + "shell_command": [ "sleep 4", "echo 'yarn start'" ] + }] + }] +} + diff --git a/a/tmux/.tmuxp/general.json b/a/tmux/.tmuxp/general.json new file mode 100644 index 0000000..5742953 --- /dev/null +++ b/a/tmux/.tmuxp/general.json @@ -0,0 +1,16 @@ +{ + "session_name": "general", + "windows": [{ + "window_name": "ytop", + "panes": ["ytop -c default-dark"] + }, { + "window_name": "newsboat", + "panes": ["newsboat"] + }, { + "window_name": "ddgr", + "panes": ["ddgr --unsafe --noua"] + }, { + "panes": ["echo 'session \"general\"'"] + }], + "start_directory": "~" +} diff --git a/a/tmux/.tmuxp/turnip.json b/a/tmux/.tmuxp/turnip.json new file mode 100644 index 0000000..e152be3 --- /dev/null +++ b/a/tmux/.tmuxp/turnip.json @@ -0,0 +1,26 @@ +{ + "session_name": "turnip", + "windows": [{ + "window_name": "ide", + "panes": [ + "echo 'vim -R package.json'", + "ls", + "echo 'git was here'" + ], + "layout": "main-horizontal", + "main-pane-height": 32, + "start_directory": "~/code/turnip-glen" + }, { + "window_name": "servers", + "start_directory": "~/code/turnip-glen", + "layout": "main-horizontal", + "panes": [{ + "shell_command": [ "cd ~/code/cornish-glen", "yarn dev" ] + }, { + "shell_command": [ "sleep 4", "yarn relay --watch" ] + }, { + "shell_command": [ "sleep 4", "yarn start" ] + }] + }] +} + diff --git a/a/vim/.vim/ftplugin/javascript.vim b/a/vim/.vim/ftplugin/javascript.vim new file mode 100644 index 0000000..f623df4 --- /dev/null +++ b/a/vim/.vim/ftplugin/javascript.vim @@ -0,0 +1 @@ +let b:ale_linters = {'javascript': ['eslint']} diff --git a/a/vim/.vimrc b/a/vim/.vimrc new file mode 100644 index 0000000..09c49df --- /dev/null +++ b/a/vim/.vimrc @@ -0,0 +1,98 @@ +" Make backspace behave in a sane manner. +set backspace=indent,eol,start + +" Tab indentation: see `:help tabstop` +set shiftwidth=2 +set tabstop=2 +" set softtabstop=2 +set expandtab +" Consider installing the Smart Tabs plugin + +" Default: split right +set splitright + +" Show whitespace +set listchars=eol:¬,tab:>-,trail:~,extends:>,precedes:<,space:· + +" Show line numbers +set number +set relativenumber + +" Allow hidden buffers, don't limit to one file per window/split +set hidden + +" Sane vim split naviagation (via Gaslight blog) +nnoremap j +nnoremap k +nnoremap h +nnoremap l + +" Disable filetype detection +filetype off + +" vim-plug +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif +call plug#begin('~/.vim/plugged') +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'edkolev/tmuxline.vim' +Plug 'christoomey/vim-tmux-navigator' +Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } +Plug '/usr/local/opt/fzf' +Plug 'junegunn/fzf.vim' +Plug 'dense-analysis/ale' +Plug 'Valloric/YouCompleteMe' +Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } +Plug 'pangloss/vim-javascript' +Plug 'MaxMEllon/vim-jsx-pretty' +Plug 'leafgarland/typescript-vim' +Plug 'HerringtonDarkholme/yats.vim' +Plug 'Quramy/tsuquyomi' +Plug 'severij/vadelma' +Plug 'tpope/vim-surround' +Plug 'rust-lang/rust.vim' +call plug#end() + +" NERDTree on ctrl+n +let NERDTreeShowHidden=1 +map :NERDTreeToggle + +" close NERDTree after opening a file +" let g:NERDTreeQuitOnOpen=1 + +" Tsuquyomi +autocmd FileType typescript nmap t : echo tsuquyomi#hint() + +" Airline +let g:airline_powerline_fonts = 1 +let g:airline_theme = 'light' +let g:airline#extensions#tmuxline#enabled = 0 + +" Tmuxline +let g:tmuxline_theme = 'iceberg' + +" YouCompleteMe <> TypeScript +if !exists("g:ycm_semantic_triggers") + let g:ycm_semantic_triggers = {} +endif +let g:ycm_semantic_triggers['typescript'] = ['.'] + +" Enable file type detection and do language-dependent indenting +filetype plugin indent on + +" Switch syntax highlighting on +syntax enable + +" Set color scheme +set background=light +colorscheme vadelma + +" Temporary file locations +set backupdir=.backup/,~/.backup/,/tmp// +set directory=.swp/,~/.swp/,/tmp// +set undodir=.undo/,~/.undo/,/tmp// + diff --git a/a/zsh/.zshrc b/a/zsh/.zshrc new file mode 100644 index 0000000..70cd612 --- /dev/null +++ b/a/zsh/.zshrc @@ -0,0 +1,153 @@ +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +# Set name of the theme to load. +# Look in ~/.oh-my-zsh/themes/ +# Optionally, if you set this to "random", it'll load a random theme each +# time that oh-my-zsh is loaded. +ZSH_THEME="" + +# Suppress display of name of default user in prompt +DEFAULT_USER=$USER +prompt_context() {} + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_ZSH_DAYS=13 + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +export DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +HIST_STAMPS="yyyy-mm-dd" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(git nvm vi-mode) + +source $ZSH/oh-my-zsh.sh + +# User configuration + +export PATH="/Users/adamcooper/Library/Python/3.7/bin:/Users/adamcooper/.cargo/bin:$(brew --prefix coreutils)/libexec/gnubin:/opt/local/bin:/opt/local/sbin:/usr/local/sbin:$PATH" + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi +export VISUAL=vim +export EDITOR=$VISUAL + +export BROWSER=w3m + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# ssh +# export SSH_KEY_PATH="~/.ssh/dsa_id" + +# Set personal aliases, overriding those provided by oh-my-zsh libs, +# plugins, and themes. Aliases can be placed here, though oh-my-zsh +# users are encouraged to define aliases within the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" + +# Replace native OS X ctags with Homebrew ctags +alias ctags=`brew --prefix`/bin/ctags + +# If not running interactively, don't do anything + +[ -z "$PS1" ] && return + +# Why are these not exports? +# enable git unstaged indicators - set to a non-empty value +GIT_PS1_SHOWDIRTYSTATE="." + +# enable showing of untracked files - set to a non-empty value +GIT_PS1_SHOWUNTRACKEDFILES="." + +# enable stash checking - set to a non-empty value +GIT_PS1_SHOWSTASHSTATE="." + +# enable showing of HEAD vs its upstream +GIT_PS1_SHOWUPSTREAM="auto" + +BLACK=$(tput setaf 0) +RED=$(tput setaf 1) +GREEN=$(tput setaf 2) +YELLOW=$(tput setaf 3) +LIME_YELLOW=$(tput setaf 190) +POWDER_BLUE=$(tput setaf 153) +BLUE=$(tput setaf 4) +MAGENTA=$(tput setaf 5) +CYAN=$(tput setaf 6) +WHITE=$(tput setaf 7) +BRIGHT=$(tput bold) +NORMAL=$(tput sgr0) +BLINK=$(tput blink) +REVERSE=$(tput smso) +UNDERLINE=$(tput smul) + +## NVM ## +# Functionality now handled by Oh My Zsh plugin +# export NVM_DIR="$HOME/.nvm" +# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Starship +eval "$(starship init zsh)" + +## FZF ## +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh +export FZF_DEFAULT_COMMAND="fd --hidden . $HOME" # Includes hidden files +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +export FZF_ALT_C_COMMAND="fd -t d . $HOME" + +# Tmuxp completion # +eval "$(_TMUXP_COMPLETE=source_zsh tmuxp)" + +# ddgr colors +export DDGR_COLORS="MBdexy" + +# exa colors +export LS_COLORS="*.md=30" +export EXA_COLORS="uu=33;43;1" + +# Consolidate PATH +export PATH="$(consolidate-path "$PATH")" diff --git a/arch/README.md b/arch/README.md new file mode 100644 index 0000000..d798922 --- /dev/null +++ b/arch/README.md @@ -0,0 +1,5 @@ +These are the messy dotfiles for my Arch Linux system. They're useful for +- restoring my system after a catastrophe +- almost nothing else :) + +Please feel free to contact me with any questions; I'll be glad to help. diff --git a/arch/X11/.Xresources b/arch/X11/.Xresources new file mode 100644 index 0000000..038a3d0 --- /dev/null +++ b/arch/X11/.Xresources @@ -0,0 +1,60 @@ +*.termName: xterm-256color +*faceName: Fantasque Sans Mono:size=10 +! XTerm*eightBitInput: false +! XTerm*eightBitOutput: true +*metaSendsEscape: true + +*VT100.Translations: #override \n\ + Ctrl Shift V: insert-selection(CLIPBOARD) \n\ + Ctrl Shift C: copy-selection(CLIPBOARD) \n\ + Shift : exec-formatted("xdg-open '%t'", PRIMARY) select-start() select-end() \n\ + Ctrl minus: smaller-vt-font() \n\ + Ctrl plus: larger-vt-font() \n\ + Ctrl 0: set-vt-font(d) \n\ + +*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48 +*on3Clicks: regex ([[:alpha:]]+:\/\/)?([[:alnum:]!#+,.\/=?@_~-]|(%[[:xdigit:]][[:xdigit:]]))+ + +! Fonts {{{ +Xft.antialias: true +Xft.hinting: true +Xft.rgba: rgb +Xft.hintstyle: hintfull +Xft.dpi: 220 +! }}} + +! Cursor {{{ +*cursorTheme: Adwaita +Xcursor.size: 48 +! }}} + +! VT Font Menu: Unreadable +*faceSize1: 8 +! VT font menu: Tiny +*faceSize2: 10 +! VT font menu: Medium +*faceSize3: 12 +! VT font menu: Large +*faceSize4: 16 +! VT font menu: Huge +*faceSize5: 22 + +! Theme +*background: #f6f5f4 +*foreground: #000000 +*color0: #000000 +*color1: #d64541 +*color2: #019875 +*color3: #e47833 +*color4: #34495e +*color5: #674172 +*color6: #12cfc0 +*color7: #eeeeee +*color8: #505050 +*color9: #d24d57 +*color10: #019875 +*color11: #f4b350 +*color12: #2574a9 +*color13: #913d88 +*color14: #81cfe0 +*color15: #ffffff diff --git a/arch/bin/autoreply/autoreply.sh b/arch/bin/autoreply/autoreply.sh new file mode 100755 index 0000000..f43ec2a --- /dev/null +++ b/arch/bin/autoreply/autoreply.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# autoreply.sh +# +# This script sends a canned email response to those who've errone- +# ously emailed me at . Once I've manually +# moved those emails into the `misdirected` folder, it iterates +# over those emails and responds. + +set -euo pipefail + +MISDIRECTED_DIR=/home/adam/Maildir/misdirected + +if [[ -z "$(ls -A "$MISDIRECTED_DIR/cur")" ]] && [[ -z "$(ls -A "$MISDIRECTED_DIR/new")" ]]; then + echo "[autoreply.sh] The misdirected folders are currently empty. Exiting..." + exit 1 +fi + +# This weird feed-find-output-into-while-loop comes from +# https://github.com/koalaman/shellcheck/wiki/SC2044#correct-code +while IFS= read -r -d '' file ; do + echo "[loop] Preparing the email..." + + # Make a temporary file + temporary_file=$(mktemp /tmp/autoreplyXXXXX) + + # Pull sender (i.e. recipient of my email) and subject from email + recipient="$(perl -lane 'print if /^From:/' "$file" | cut -d' ' -f2-)" ### "Frantz Fanon " + subject="Re: $(perl -lane 'print if /^Subject:/' "$file" | cut -d' ' -f2-)" ### "Re: Lorem ipsum baby" + + # Copy canned message to temporary file + cp /home/adam/dotfiles/arch/bin/autoreply/misdirected_email_autoreply.txt "$temporary_file" + + # Append email body to temporary file + discard="0" + while IFS= read -r line ; do + if [[ $discard = "1" ]]; then + echo "$line" >> "$temporary_file" + else + if [[ -z "$line" ]]; then + discard="1" + fi + fi + done < "$file" + + # Send the email! + echo "[loop] Sending reply to $recipient ... " + neomutt -s "$subject" -c amcooper@gmail.com "$recipient" < "$temporary_file" + + # Move the misdirected email into `INBOX/cur` + echo "[loop] Moving the emails..." + mv "$file" /home/adam/Maildir/INBOX/cur + + echo "[loop] Done." + +done < <(find "$MISDIRECTED_DIR" -path "$MISDIRECTED_DIR/tmp" -prune -o -type f -print0) + +echo "[autoreply.sh] All done!" diff --git a/arch/bin/autoreply/misdirected_email_autoreply.txt b/arch/bin/autoreply/misdirected_email_autoreply.txt new file mode 100644 index 0000000..c7f6f33 --- /dev/null +++ b/arch/bin/autoreply/misdirected_email_autoreply.txt @@ -0,0 +1,12 @@ +Hi, + +Looks like you've mistakenly emailed me at my old GMail address. I get a +misdirected email at that address about once a week. Please double check +your recipient's email address. + +Regards, +A.C. + +[This is an automated email reply. For more context, see: +https://theadamcooper.com/home/wrong-email.html ] + diff --git a/arch/bin/conditional-vdirsyncer.sh b/arch/bin/conditional-vdirsyncer.sh new file mode 100755 index 0000000..80554ac --- /dev/null +++ b/arch/bin/conditional-vdirsyncer.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail + +if [[ -n $(secret-tool lookup service nextcloud) ]]; then + /usr/bin/vdirsyncer discover + /usr/bin/vdirsyncer sync --force-delete my_contacts/z-app-generated--contactsinteraction--recent +else + echo "Failed to unlock database" +fi diff --git a/arch/bin/consolidate-path b/arch/bin/consolidate-path new file mode 100755 index 0000000..d302afd --- /dev/null +++ b/arch/bin/consolidate-path @@ -0,0 +1,13 @@ +#!/bin/bash +# Usage: PATH="$(consolidate-path "$PATH")" +# +# Remove duplicate entries from PATH. + +result=":" +IFS=: +for p in $1; do + [[ "$result" == *:"$p":* ]] || result="${result}${p}:" +done + +result="${result#:}" +echo "${result%:}" diff --git a/arch/bin/facetimehd-reinstall.sh b/arch/bin/facetimehd-reinstall.sh new file mode 100755 index 0000000..2d59af8 --- /dev/null +++ b/arch/bin/facetimehd-reinstall.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# facetimehd-reinstall.sh +# +# Reinstalls the facetimehd kernel module. We do this because each time we bump +# the kernel, this module usually breaks. The script can be set as a pacman hook +# to run after each kernel bump. The script should be run as root. +# +# Ref.: +# https://github.com/patjak/facetimehd/wiki/Installation#get-started-on-arch +set -euo pipefail + +# +# These text wrangles are meant to convert package numbers from pacman style to +# uname style. So: +# 5.18.16.arch1-1 -> 5.18.16-arch1-1 +# 5.15.58-2 -> 5.15.58-2-lts +# +kernel_release=$(pacman -Qi linux | grep Version | \ + perl -ple 's/^Version.*([0-9]+\.[0-9]+\.[0-9]+)\.(.*)$/$1-$2/') +kernel_release_lts=$(pacman -Qi linux-lts | grep Version | \ + perl -ple 's/^Version.*([0-9]+\.[0-9]+\.[0-9]+.*)$/$1-lts/') +cd /home/adam/builds/bcwc_pcie || exit 1 + +# +# Linux +# +echo "*** Linux FacetimeHD driver ***" +echo "[linux] make clean" +KERNELRELEASE=$kernel_release make clean +echo "[linux] make" +KERNELRELEASE=$kernel_release make +echo "[linux] make install" +KERNELRELEASE=$kernel_release make install +echo "[linux] depmod" +depmod "$kernel_release" +if ! (modprobe --set-version "$kernel_release" -r bdc_pci); then + echo "[linux] Removal of module bdc_pci failed." +fi +if ! (modprobe --set-version "$kernel_release" -r facetimehd); then + echo "[linux] Removal of module facetimehd failed." +fi +echo "[linux] Installing module facetimehd" +modprobe --set-version "$kernel_release" facetimehd + +# +# Linux LTS +# +echo "*** Linux-LTS FacetimeHD driver ***" +echo "[linux-lts] make clean" +KERNELRELEASE=$kernel_release_lts make clean +echo "[linux-lts] make" +KERNELRELEASE=$kernel_release_lts make +echo "[linux-lts] make install" +KERNELRELEASE=$kernel_release_lts make install +echo "[linux-lts] depmod" +depmod "$kernel_release_lts" +if ! (modprobe --set-version "$kernel_release_lts" -r bdc_pci); then + echo "[linux-lts] Removal of module bdc_pci failed." +fi +if ! (modprobe --set-version "$kernel_release_lts" -r facetimehd); then + echo "[linux-lts] Removal of module facetimehd failed." +fi +echo "[linux-lts] Installing module facetimehd" +modprobe --set-version "$kernel_release_lts" facetimehd diff --git a/arch/bin/failure-notification.sh b/arch/bin/failure-notification.sh new file mode 100755 index 0000000..a48ecbb --- /dev/null +++ b/arch/bin/failure-notification.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +notify-send "Systemd unit failure: $1" "The systemd unit $1 has failed" diff --git a/arch/bin/joplin-rename.sh b/arch/bin/joplin-rename.sh new file mode 100755 index 0000000..665bc2b --- /dev/null +++ b/arch/bin/joplin-rename.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# joplin-rename.sh +# +# This script slugifies joplin entities (notes and todos) +# (Work in progress) + +set -euo pipefail + +set -x + +joplin use test-notebook + +while IFS= read -r -d '' item ; do + echo "$item" + +done < <(joplin ls) + +echo "[joplin-rename] All done!" diff --git a/arch/bin/notmuch-hook.sh b/arch/bin/notmuch-hook.sh new file mode 100755 index 0000000..82bfe38 --- /dev/null +++ b/arch/bin/notmuch-hook.sh @@ -0,0 +1,7 @@ +#!/bin/sh +notmuch new +# retag all "new" messages "inbox" and "unread" +notmuch tag +inbox +unread -new -- tag:new +# tag all messages from "me" as sent and remove tags inbox and unread +notmuch tag -new -inbox +sent -- from:adam@theadamcooper.com + diff --git a/arch/bin/w3m-wallabagger.sh b/arch/bin/w3m-wallabagger.sh new file mode 100755 index 0000000..3878584 --- /dev/null +++ b/arch/bin/w3m-wallabagger.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail +# curl commands are currently '--insecure' until the certificate situation is sorted out +token=$(curl --silent --insecure -X POST --data grant_type=password --data client_id=3_3kfqif569iqsk8s88koccsk8kkg8oc0o4k8kckoo8ss84cgw0k --data client_secret=4s5ioftf8juocc0woskscogogwgw0wwwsg4cccoscwoc0c88cc --data username=adam --data password="$(secret-tool lookup Title wallabag)" 'https://wallabag.theadamcooper.com/oauth/v2/token' | jshon -e access_token | sed 's/"//g') +if [[ -n $token ]]; then + curl --silent --insecure -X POST --header "Authorization: Bearer ${token}" --data url="$1" 'https://wallabag.theadamcooper.com/api/entries.json' &> /dev/null +else + echo "$(date +"%Y-%m-%d %H:%M") Invalid token" >> /home/adam/.config/local/share/w3m/w3m-wallabagger.log +fi diff --git a/arch/bin/xmonad-recompile.sh b/arch/bin/xmonad-recompile.sh new file mode 100755 index 0000000..014859d --- /dev/null +++ b/arch/bin/xmonad-recompile.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +xmonad --recompile diff --git a/arch/fish/config.fish b/arch/fish/config.fish new file mode 100644 index 0000000..c589e8a --- /dev/null +++ b/arch/fish/config.fish @@ -0,0 +1,44 @@ +if status is-interactive + # Commands to run in interactive sessions can go here + + fish_add_path --path /usr/sbin /usr/bin /sbin /bin /usr/local/bin /opt/local/bin /opt/local/sbin /usr/local/go/bin $HOME/.local/bin $HOME/.cargo/bin $HOME/.cargo/env $HOME/code/go/bin $HOME/.rbenv + + # Currently using the default $MANPATH; see /etc/man_db.conf + + set --global fish_key_bindings fish_vi_key_bindings + + ## XDG + set --global --export XDG_CONFIG_HOME "$HOME/.config" + set --global --export XDG_DATA_HOME "$HOME/.config/local/share" + set --global --export XDG_CACHE_HOME "$HOME/.config/cache" + + set --global --export EDITOR "vim" + set --global --export VISUAL "vim" + + # FZF + set --global --export FZF_DEFAULT_COMMAND "fd --no-ignore --hidden --type f" # Includes hidden files + set --global --export FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND" + fzf_key_bindings + + # bat theme + set --global --export BAT_THEME OneHalfLight + + # exa colors + set --global --export LS_COLORS "*.md=36" + + # ddgr + set --global --export BROWSER w3m + set --global --export DDGR_COLORS "MBdexy" + + # navi + set --global --export NAVI_TAG_COLOR 6 + set --global --export NAVI_COMMENT_COLOR 3 + navi widget fish | source + + # starship + starship init fish | source + + ## zoxide ## + zoxide init fish | source + +end diff --git a/arch/fish/fish_variables b/arch/fish/fish_variables new file mode 100644 index 0000000..44ab71f --- /dev/null +++ b/arch/fish/fish_variables @@ -0,0 +1,32 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR --export --path GOPATH:/home/adam/code/go/ +SETUVAR __fish_initialized:3100 +SETUVAR _fish_abbr_exi:exa\x20\x2d\x2dall\x20\x2d\x2dlong\x20\x2d\x2dicons\x20\x2d\x2dgroup +SETUVAR fish_color_autosuggestion:555\x1ebrblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:005fd7 +SETUVAR fish_color_comment:990000 +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:009900 +SETUVAR fish_color_error:ff0000 +SETUVAR fish_color_escape:00a6b2 +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:00a6b2 +SETUVAR fish_color_param:00afff +SETUVAR fish_color_quote:999900 +SETUVAR fish_color_redirection:00afff +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:\x1d +SETUVAR fish_pager_color_description:B3A06D\x1eyellow +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan diff --git a/arch/fish/fzf_key_bindings.fish b/arch/fish/fzf_key_bindings.fish new file mode 100644 index 0000000..18678b0 --- /dev/null +++ b/arch/fish/fzf_key_bindings.fish @@ -0,0 +1,172 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ key-bindings.fish +# +# - $FZF_TMUX_OPTS +# - $FZF_CTRL_T_COMMAND +# - $FZF_CTRL_T_OPTS +# - $FZF_CTRL_R_OPTS +# - $FZF_ALT_C_COMMAND +# - $FZF_ALT_C_OPTS + +# Key bindings +# ------------ +function fzf_key_bindings + + # Store current token in $dir as root for the 'find' command + function fzf-file-widget -d "List files and folders" + set -l commandline (__fzf_parse_commandline) + set -l dir $commandline[1] + set -l fzf_query $commandline[2] + set -l prefix $commandline[3] + + # "-path \$dir'*/\\.*'" matches hidden files/folders inside $dir but not + # $dir itself, even if hidden. + test -n "$FZF_CTRL_T_COMMAND"; or set -l FZF_CTRL_T_COMMAND " + command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | sed 's@^\./@@'" + + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + begin + set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" + eval "$FZF_CTRL_T_COMMAND | "(__fzfcmd)' -m --query "'$fzf_query'"' | while read -l r; set result $result $r; end + end + if [ -z "$result" ] + commandline -f repaint + return + else + # Remove last token from commandline. + commandline -t "" + end + for i in $result + commandline -it -- $prefix + commandline -it -- (string escape $i) + commandline -it -- ' ' + end + commandline -f repaint + end + + function fzf-history-widget -d "Show command history" + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + begin + set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS +m" + + set -l FISH_MAJOR (echo $version | cut -f1 -d.) + set -l FISH_MINOR (echo $version | cut -f2 -d.) + + # history's -z flag is needed for multi-line support. + # history's -z flag was added in fish 2.4.0, so don't use it for versions + # before 2.4.0. + if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ]; + history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result + and commandline -- $result + else + history | eval (__fzfcmd) -q '(commandline)' | read -l result + and commandline -- $result + end + end + commandline -f repaint + end + + function fzf-cd-widget -d "Change directory" + set -l commandline (__fzf_parse_commandline) + set -l dir $commandline[1] + set -l fzf_query $commandline[2] + set -l prefix $commandline[3] + + test -n "$FZF_ALT_C_COMMAND"; or set -l FZF_ALT_C_COMMAND " + command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \ + -o -type d -print 2> /dev/null | sed 's@^\./@@'" + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + begin + set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" + eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)' +m --query "'$fzf_query'"' | read -l result + + if [ -n "$result" ] + cd $result + + # Remove last token from commandline. + commandline -t "" + commandline -it -- $prefix + end + end + + commandline -f repaint + end + + function __fzfcmd + test -n "$FZF_TMUX"; or set FZF_TMUX 0 + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + if [ -n "$FZF_TMUX_OPTS" ] + echo "fzf-tmux $FZF_TMUX_OPTS -- " + else if [ $FZF_TMUX -eq 1 ] + echo "fzf-tmux -d$FZF_TMUX_HEIGHT -- " + else + echo "fzf" + end + end + + bind \ct fzf-file-widget + bind \cr fzf-history-widget + bind \ec fzf-cd-widget + + if bind -M insert > /dev/null 2>&1 + bind -M insert \ct fzf-file-widget + bind -M insert --user \cr fzf-history-widget + bind -M insert \ec fzf-cd-widget + end + + function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath, fzf query, and optional -option= prefix' + set -l commandline (commandline -t) + + # strip -option= from token if present + set -l prefix (string match -r -- '^-[^\s=]+=' $commandline) + set commandline (string replace -- "$prefix" '' $commandline) + + # eval is used to do shell expansion on paths + eval set commandline $commandline + + if [ -z $commandline ] + # Default to current directory with no --query + set dir '.' + set fzf_query '' + else + set dir (__fzf_get_dir $commandline) + + if [ "$dir" = "." -a (string sub -l 1 -- $commandline) != '.' ] + # if $dir is "." but commandline is not a relative path, this means no file path found + set fzf_query $commandline + else + # Also remove trailing slash after dir, to "split" input properly + set fzf_query (string replace -r "^$dir/?" -- '' "$commandline") + end + end + + echo $dir + echo $fzf_query + echo $prefix + end + + function __fzf_get_dir -d 'Find the longest existing filepath from input string' + set dir $argv + + # Strip all trailing slashes. Ignore if $dir is root dir (/) + if [ (string length -- $dir) -gt 1 ] + set dir (string replace -r '/*$' -- '' $dir) + end + + # Iteratively check if dir exists and strip tail end of path + while [ ! -d "$dir" ] + # If path is absolute, this can keep going until ends up at / + # If path is relative, this can keep going until entire input is consumed, dirname returns "." + set dir (dirname -- "$dir") + end + + echo $dir + end + +end diff --git a/arch/git/.git-completion b/arch/git/.git-completion new file mode 100644 index 0000000..482ca84 --- /dev/null +++ b/arch/git/.git-completion @@ -0,0 +1,2742 @@ +# bash/zsh completion support for core Git. +# +# Copyright (C) 2006,2007 Shawn O. Pearce +# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). +# Distributed under the GNU General Public License, version 2.0. +# +# The contained completion routines provide support for completing: +# +# *) local and remote branch names +# *) local and remote tag names +# *) .git/remotes file names +# *) git 'subcommands' +# *) tree paths within 'ref:path/to/file' expressions +# *) file paths within current working directory and index +# *) common --long-options +# +# To use these routines: +# +# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). +# 2) Add the following line to your .bashrc/.zshrc: +# source ~/.git-completion.bash +# 3) Consider changing your PS1 to also show the current branch, +# see git-prompt.sh for details. +# +# If you use complex aliases of form '!f() { ... }; f', you can use the null +# command ':' as the first command in the function body to declare the desired +# completion style. For example '!f() { : git commit ; ... }; f' will +# tell the completion to use commit completion. This also works with aliases +# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". + +case "$COMP_WORDBREAKS" in +*:*) : great ;; +*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" +esac + +# __gitdir accepts 0 or 1 arguments (i.e., location) +# returns location of .git repo +__gitdir () +{ + if [ -z "${1-}" ]; then + if [ -n "${__git_dir-}" ]; then + echo "$__git_dir" + elif [ -n "${GIT_DIR-}" ]; then + test -d "${GIT_DIR-}" || return 1 + echo "$GIT_DIR" + elif [ -d .git ]; then + echo .git + else + git rev-parse --git-dir 2>/dev/null + fi + elif [ -d "$1/.git" ]; then + echo "$1/.git" + else + echo "$1" + fi +} + +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald +# © 2009-2010, Bash Completion Maintainers +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function can be used to access a tokenized list of words +# on the command line: +# +# __git_reassemble_comp_words_by_ref '=:' +# if test "${words_[cword_-1]}" = -w +# then +# ... +# fi +# +# The argument should be a collection of characters from the list of +# word completion separators (COMP_WORDBREAKS) to treat as ordinary +# characters. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude those characters. The intent is to +# make option types like --date= and : easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. +# +# Output: words_, cword_, cur_. + +__git_reassemble_comp_words_by_ref() +{ + local exclude i j first + # Which word separators to exclude? + exclude="${1//[^$COMP_WORDBREAKS]}" + cword_=$COMP_CWORD + if [ -z "$exclude" ]; then + words_=("${COMP_WORDS[@]}") + return + fi + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + return + fi + done + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + done +} + +if ! type _get_comp_words_by_ref >/dev/null 2>&1; then +_get_comp_words_by_ref () +{ + local exclude cur_ words_ cword_ + if [ "$1" = "-n" ]; then + exclude=$2 + shift 2 + fi + __git_reassemble_comp_words_by_ref "$exclude" + cur_=${words_[cword_]} + while [ $# -gt 0 ]; do + case "$1" in + cur) + cur=$cur_ + ;; + prev) + prev=${words_[$cword_-1]} + ;; + words) + words=("${words_[@]}") + ;; + cword) + cword=$cword_ + ;; + esac + shift + done +} +fi + +__gitcompappend () +{ + local x i=${#COMPREPLY[@]} + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +__gitcompadd () +{ + COMPREPLY=() + __gitcompappend "$@" +} + +# Generates completion reply, appending a space to possible completion words, +# if necessary. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp () +{ + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + *) + local c i=0 IFS=$' \t\n' + for c in $1; do + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; + esac +} + +# Variation of __gitcomp_nl () that appends to the existing list of +# completion candidates, COMPREPLY. +__gitcomp_nl_append () +{ + local IFS=$'\n' + __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words, separated by a single newline. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word instead of +# the default space (optional). If specified but empty, nothing is +# appended. +__gitcomp_nl () +{ + COMPREPLY=() + __gitcomp_nl_append "$@" +} + +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + __gitcompadd "$1" "${2-}" "${3-$cur}" "" + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ > /dev/null +} + +# Execute 'git ls-files', unless the --committable option is specified, in +# which case it runs 'git diff-index' to find out the files that can be +# committed. It return paths relative to the directory specified in the first +# argument, and using the options specified in the second argument. +__git_ls_files_helper () +{ + if [ "$2" == "--committable" ]; then + git -C "$1" diff-index --name-only --relative HEAD + else + # NOTE: $2 is not quoted in order to support multiple options + git -C "$1" ls-files --exclude-standard $2 + fi 2>/dev/null +} + + +# __git_index_files accepts 1 or 2 arguments: +# 1: Options to pass to ls-files (required). +# 2: A directory path (optional). +# If provided, only files within the specified directory are listed. +# Sub directories are never recursed. Path must have a trailing +# slash. +__git_index_files () +{ + local dir="$(__gitdir)" root="${2-.}" file + + if [ -d "$dir" ]; then + __git_ls_files_helper "$root" "$1" | + while read -r file; do + case "$file" in + ?*/*) echo "${file%%/*}" ;; + *) echo "$file" ;; + esac + done | sort | uniq + fi +} + +__git_heads () +{ + local dir="$(__gitdir)" + if [ -d "$dir" ]; then + git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + refs/heads + return + fi +} + +__git_tags () +{ + local dir="$(__gitdir)" + if [ -d "$dir" ]; then + git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + refs/tags + return + fi +} + +# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments +# presence of 2nd argument means use the guess heuristic employed +# by checkout for tracking branches +__git_refs () +{ + local i hash dir="$(__gitdir "${1-}")" track="${2-}" + local format refs + if [ -d "$dir" ]; then + case "$cur" in + refs|refs/*) + format="refname" + refs="${cur%/*}" + track="" + ;; + *) + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do + if [ -e "$dir/$i" ]; then echo $i; fi + done + format="refname:short" + refs="refs/tags refs/heads refs/remotes" + ;; + esac + git --git-dir="$dir" for-each-ref --format="%($format)" \ + $refs + if [ -n "$track" ]; then + # employ the heuristic used by git checkout + # Try to find a remote branch that matches the completion word + # but only output if the branch name is unique + local ref entry + git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \ + "refs/remotes/" | \ + while read -r entry; do + eval "$entry" + ref="${ref#*/}" + if [[ "$ref" == "$cur"* ]]; then + echo "$ref" + fi + done | sort | uniq -u + fi + return + fi + case "$cur" in + refs|refs/*) + git ls-remote "$dir" "$cur*" 2>/dev/null | \ + while read -r hash i; do + case "$i" in + *^{}) ;; + *) echo "$i" ;; + esac + done + ;; + *) + echo "HEAD" + git for-each-ref --format="%(refname:short)" -- \ + "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##" + ;; + esac +} + +# __git_refs2 requires 1 argument (to pass to __git_refs) +__git_refs2 () +{ + local i + for i in $(__git_refs "$1"); do + echo "$i:$i" + done +} + +# __git_refs_remotes requires 1 argument (to pass to ls-remote) +__git_refs_remotes () +{ + local i hash + git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \ + while read -r hash i; do + echo "$i:refs/remotes/$1/${i#refs/heads/}" + done +} + +__git_remotes () +{ + local d="$(__gitdir)" + test -d "$d/remotes" && ls -1 "$d/remotes" + git --git-dir="$d" remote +} + +__git_list_merge_strategies () +{ + git merge -s help 2>&1 | + sed -n -e '/[Aa]vailable strategies are: /,/^$/{ + s/\.$// + s/.*:// + s/^[ ]*// + s/[ ]*$// + p + }' +} + +__git_merge_strategies= +# 'git merge -s help' (and thus detection of the merge strategy +# list) fails, unfortunately, if run outside of any git working +# tree. __git_merge_strategies is set to the empty string in +# that case, and the detection will be repeated the next time it +# is needed. +__git_compute_merge_strategies () +{ + test -n "$__git_merge_strategies" || + __git_merge_strategies=$(__git_list_merge_strategies) +} + +__git_complete_revlist_file () +{ + local pfx ls ref cur_="$cur" + case "$cur_" in + *..?*:*) + return + ;; + ?*:*) + ref="${cur_%%:*}" + cur_="${cur_#*:}" + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + ls="$ref:$pfx" + pfx="$pfx/" + ;; + *) + ls="$ref" + ;; + esac + + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="$ref:$pfx" ;; + esac + + __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \ + | sed '/^100... blob /{ + s,^.* ,, + s,$, , + } + /^120000 blob /{ + s,^.* ,, + s,$, , + } + /^040000 tree /{ + s,^.* ,, + s,$,/, + } + s/^.* //')" \ + "$pfx" "$cur_" "" + ;; + *...*) + pfx="${cur_%...*}..." + cur_="${cur_#*...}" + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + ;; + *..*) + pfx="${cur_%..*}.." + cur_="${cur_#*..}" + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac +} + + +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local pfx="" cur_="$cur" + + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + pfx="${pfx}/" + ;; + esac + + __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" +} + +__git_complete_file () +{ + __git_complete_revlist_file +} + +__git_complete_revlist () +{ + __git_complete_revlist_file +} + +__git_complete_remote_or_refspec () +{ + local cur_="$cur" cmd="${words[1]}" + local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 + if [ "$cmd" = "remote" ]; then + ((c++)) + fi + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; + --all) + case "$cmd" in + push) no_complete_refspec=1 ;; + fetch) + return + ;; + *) ;; + esac + ;; + -*) ;; + *) remote="$i"; break ;; + esac + ((c++)) + done + if [ -z "$remote" ]; then + __gitcomp_nl "$(__git_remotes)" + return + fi + if [ $no_complete_refspec = 1 ]; then + return + fi + [ "$remote" = "." ] && remote= + case "$cur_" in + *:*) + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="${cur_%%:*}:" ;; + esac + cur_="${cur_#*:}" + lhs=0 + ;; + +*) + pfx="+" + cur_="${cur_#+}" + ;; + esac + case "$cmd" in + fetch) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + fi + ;; + pull|remote) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + fi + ;; + push) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" + fi + ;; + esac +} + +__git_complete_strategy () +{ + __git_compute_merge_strategies + case "$prev" in + -s|--strategy) + __gitcomp "$__git_merge_strategies" + return 0 + esac + case "$cur" in + --strategy=*) + __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" + return 0 + ;; + esac + return 1 +} + +__git_commands () { + if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}" + then + printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}" + else + git help -a|egrep '^ [a-zA-Z0-9]' + fi +} + +__git_list_all_commands () +{ + local i IFS=" "$'\n' + for i in $(__git_commands) + do + case $i in + *--*) : helper pattern;; + *) echo $i;; + esac + done +} + +__git_all_commands= +__git_compute_all_commands () +{ + test -n "$__git_all_commands" || + __git_all_commands=$(__git_list_all_commands) +} + +__git_list_porcelain_commands () +{ + local i IFS=" "$'\n' + __git_compute_all_commands + for i in $__git_all_commands + do + case $i in + *--*) : helper pattern;; + applymbox) : ask gittus;; + applypatch) : ask gittus;; + archimport) : import;; + cat-file) : plumbing;; + check-attr) : plumbing;; + check-ignore) : plumbing;; + check-mailmap) : plumbing;; + check-ref-format) : plumbing;; + checkout-index) : plumbing;; + commit-tree) : plumbing;; + count-objects) : infrequent;; + credential) : credentials;; + credential-*) : credentials helper;; + cvsexportcommit) : export;; + cvsimport) : import;; + cvsserver) : daemon;; + daemon) : daemon;; + diff-files) : plumbing;; + diff-index) : plumbing;; + diff-tree) : plumbing;; + fast-import) : import;; + fast-export) : export;; + fsck-objects) : plumbing;; + fetch-pack) : plumbing;; + fmt-merge-msg) : plumbing;; + for-each-ref) : plumbing;; + hash-object) : plumbing;; + http-*) : transport;; + index-pack) : plumbing;; + init-db) : deprecated;; + local-fetch) : plumbing;; + ls-files) : plumbing;; + ls-remote) : plumbing;; + ls-tree) : plumbing;; + mailinfo) : plumbing;; + mailsplit) : plumbing;; + merge-*) : plumbing;; + mktree) : plumbing;; + mktag) : plumbing;; + pack-objects) : plumbing;; + pack-redundant) : plumbing;; + pack-refs) : plumbing;; + parse-remote) : plumbing;; + patch-id) : plumbing;; + prune) : plumbing;; + prune-packed) : plumbing;; + quiltimport) : import;; + read-tree) : plumbing;; + receive-pack) : plumbing;; + remote-*) : transport;; + rerere) : plumbing;; + rev-list) : plumbing;; + rev-parse) : plumbing;; + runstatus) : plumbing;; + sh-setup) : internal;; + shell) : daemon;; + show-ref) : plumbing;; + send-pack) : plumbing;; + show-index) : plumbing;; + ssh-*) : transport;; + stripspace) : plumbing;; + symbolic-ref) : plumbing;; + unpack-file) : plumbing;; + unpack-objects) : plumbing;; + update-index) : plumbing;; + update-ref) : plumbing;; + update-server-info) : daemon;; + upload-archive) : plumbing;; + upload-pack) : plumbing;; + write-tree) : plumbing;; + var) : infrequent;; + verify-pack) : infrequent;; + verify-tag) : plumbing;; + *) echo $i;; + esac + done +} + +__git_porcelain_commands= +__git_compute_porcelain_commands () +{ + test -n "$__git_porcelain_commands" || + __git_porcelain_commands=$(__git_list_porcelain_commands) +} + +# Lists all set config variables starting with the given section prefix, +# with the prefix removed. +__git_get_config_variables () +{ + local section="$1" i IFS=$'\n' + for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do + echo "${i#$section.}" + done +} + +__git_pretty_aliases () +{ + __git_get_config_variables "pretty" +} + +__git_aliases () +{ + __git_get_config_variables "alias" +} + +# __git_aliased_command requires 1 argument +__git_aliased_command () +{ + local word cmdline=$(git --git-dir="$(__gitdir)" \ + config --get "alias.$1") + for word in $cmdline; do + case "$word" in + \!gitk|gitk) + echo "gitk" + return + ;; + \!*) : shell command alias ;; + -*) : option ;; + *=*) : setting env ;; + git) : git itself ;; + \(\)) : skip parens of shell function definition ;; + {) : skip start of shell helper function ;; + :) : skip null command ;; + \'*) : skip opening quote after sh -c ;; + *) + echo "$word" + return + esac + done +} + +# __git_find_on_cmdline requires 1 argument +__git_find_on_cmdline () +{ + local word subcommand c=1 + while [ $c -lt $cword ]; do + word="${words[c]}" + for subcommand in $1; do + if [ "$subcommand" = "$word" ]; then + echo "$subcommand" + return + fi + done + ((c++)) + done +} + +__git_has_doubledash () +{ + local c=1 + while [ $c -lt $cword ]; do + if [ "--" = "${words[c]}" ]; then + return 0 + fi + ((c++)) + done + return 1 +} + +# Try to count non option arguments passed on the command line for the +# specified git command. +# When options are used, it is necessary to use the special -- option to +# tell the implementation were non option arguments begin. +# XXX this can not be improved, since options can appear everywhere, as +# an example: +# git mv x -n y +# +# __git_count_arguments requires 1 argument: the git command executed. +__git_count_arguments () +{ + local word i c=0 + + # Skip "git" (first argument) + for ((i=1; i < ${#words[@]}; i++)); do + word="${words[i]}" + + case "$word" in + --) + # Good; we can assume that the following are only non + # option arguments. + ((c = 0)) + ;; + "$1") + # Skip the specified git command and discard git + # main options + ((c = 0)) + ;; + ?*) + ((c++)) + ;; + esac + done + + printf "%d" $c +} + +__git_whitespacelist="nowarn warn error error-all fix" + +_git_am () +{ + local dir="$(__gitdir)" + if [ -d "$dir"/rebase-apply ]; then + __gitcomp "--skip --continue --resolved --abort" + return + fi + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --3way --committer-date-is-author-date --ignore-date + --ignore-whitespace --ignore-space-change + --interactive --keep --no-utf8 --signoff --utf8 + --whitespace= --scissors + " + return + esac +} + +_git_apply () +{ + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --stat --numstat --summary --check --index + --cached --index-info --reverse --reject --unidiff-zero + --apply --no-add --exclude= + --ignore-whitespace --ignore-space-change + --whitespace= --inaccurate-eof --verbose + " + return + esac +} + +_git_add () +{ + case "$cur" in + --*) + __gitcomp " + --interactive --refresh --patch --update --dry-run + --ignore-errors --intent-to-add + " + return + esac + + # XXX should we check for --update and --all options ? + __git_complete_index_file "--others --modified --directory --no-empty-directory" +} + +_git_archive () +{ + case "$cur" in + --format=*) + __gitcomp "$(git archive --list)" "" "${cur##--format=}" + return + ;; + --remote=*) + __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}" + return + ;; + --*) + __gitcomp " + --format= --list --verbose + --prefix= --remote= --exec= + " + return + ;; + esac + __git_complete_file +} + +_git_bisect () +{ + __git_has_doubledash && return + + local subcommands="start bad good skip reset visualize replay log run" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + if [ -f "$(__gitdir)"/BISECT_START ]; then + __gitcomp "$subcommands" + else + __gitcomp "replay start" + fi + return + fi + + case "$subcommand" in + bad|good|reset|skip|start) + __gitcomp_nl "$(__git_refs)" + ;; + *) + ;; + esac +} + +_git_branch () +{ + local i c=1 only_local_ref="n" has_r="n" + + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -d|-m) only_local_ref="y" ;; + -r) has_r="y" ;; + esac + ((c++)) + done + + case "$cur" in + --set-upstream-to=*) + __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}" + ;; + --*) + __gitcomp " + --color --no-color --verbose --abbrev= --no-abbrev + --track --no-track --contains --merged --no-merged + --set-upstream-to= --edit-description --list + --unset-upstream + " + ;; + *) + if [ $only_local_ref = "y" -a $has_r = "n" ]; then + __gitcomp_nl "$(__git_heads)" + else + __gitcomp_nl "$(__git_refs)" + fi + ;; + esac +} + +_git_bundle () +{ + local cmd="${words[2]}" + case "$cword" in + 2) + __gitcomp "create list-heads verify unbundle" + ;; + 3) + # looking for a file + ;; + *) + case "$cmd" in + create) + __git_complete_revlist + ;; + esac + ;; + esac +} + +_git_checkout () +{ + __git_has_doubledash && return + + case "$cur" in + --conflict=*) + __gitcomp "diff3 merge" "" "${cur##--conflict=}" + ;; + --*) + __gitcomp " + --quiet --ours --theirs --track --no-track --merge + --conflict= --orphan --patch + " + ;; + *) + # check if --track, --no-track, or --no-guess was specified + # if so, disable DWIM mode + local flags="--track --no-track --no-guess" track=1 + if [ -n "$(__git_find_on_cmdline "$flags")" ]; then + track='' + fi + __gitcomp_nl "$(__git_refs '' $track)" + ;; + esac +} + +_git_cherry () +{ + __gitcomp_nl "$(__git_refs)" +} + +_git_cherry_pick () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/CHERRY_PICK_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi + case "$cur" in + --*) + __gitcomp "--edit --no-commit --signoff --strategy= --mainline" + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac +} + +_git_clean () +{ + case "$cur" in + --*) + __gitcomp "--dry-run --quiet" + return + ;; + esac + + # XXX should we check for -x option ? + __git_complete_index_file "--others --directory" +} + +_git_clone () +{ + case "$cur" in + --*) + __gitcomp " + --local + --no-hardlinks + --shared + --reference + --quiet + --no-checkout + --bare + --mirror + --origin + --upload-pack + --template= + --depth + --single-branch + --branch + " + return + ;; + esac +} + +_git_commit () +{ + case "$prev" in + -c|-C) + __gitcomp_nl "$(__git_refs)" "" "${cur}" + return + ;; + esac + + case "$cur" in + --cleanup=*) + __gitcomp "default scissors strip verbatim whitespace + " "" "${cur##--cleanup=}" + return + ;; + --reuse-message=*|--reedit-message=*|\ + --fixup=*|--squash=*) + __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" + return + ;; + --untracked-files=*) + __gitcomp "all no normal" "" "${cur##--untracked-files=}" + return + ;; + --*) + __gitcomp " + --all --author= --signoff --verify --no-verify + --edit --no-edit + --amend --include --only --interactive + --dry-run --reuse-message= --reedit-message= + --reset-author --file= --message= --template= + --cleanup= --untracked-files --untracked-files= + --verbose --quiet --fixup= --squash= + " + return + esac + + if git rev-parse --verify --quiet HEAD >/dev/null; then + __git_complete_index_file "--committable" + else + # This is the first commit + __git_complete_index_file "--cached" + fi +} + +_git_describe () +{ + case "$cur" in + --*) + __gitcomp " + --all --tags --contains --abbrev= --candidates= + --exact-match --debug --long --match --always + " + return + esac + __gitcomp_nl "$(__git_refs)" +} + +__git_diff_algorithms="myers minimal patience histogram" + +__git_diff_common_options="--stat --numstat --shortstat --summary + --patch-with-stat --name-only --name-status --color + --no-color --color-words --no-renames --check + --full-index --binary --abbrev --diff-filter= + --find-copies-harder + --text --ignore-space-at-eol --ignore-space-change + --ignore-all-space --ignore-blank-lines --exit-code + --quiet --ext-diff --no-ext-diff + --no-prefix --src-prefix= --dst-prefix= + --inter-hunk-context= + --patience --histogram --minimal + --raw --word-diff + --dirstat --dirstat= --dirstat-by-file + --dirstat-by-file= --cumulative + --diff-algorithm= +" + +_git_diff () +{ + __git_has_doubledash && return + + case "$cur" in + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --*) + __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs --no-index + $__git_diff_common_options + " + return + ;; + esac + __git_complete_revlist_file +} + +__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff + tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare +" + +_git_difftool () +{ + __git_has_doubledash && return + + case "$cur" in + --tool=*) + __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}" + return + ;; + --*) + __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs + --no-renames --diff-filter= --find-copies-harder + --relative --ignore-submodules + --tool=" + return + ;; + esac + __git_complete_revlist_file +} + +__git_fetch_recurse_submodules="yes on-demand no" + +__git_fetch_options=" + --quiet --verbose --append --upload-pack --force --keep --depth= + --tags --no-tags --all --prune --dry-run --recurse-submodules= +" + +_git_fetch () +{ + case "$cur" in + --recurse-submodules=*) + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --*) + __gitcomp "$__git_fetch_options" + return + ;; + esac + __git_complete_remote_or_refspec +} + +__git_format_patch_options=" + --stdout --attach --no-attach --thread --thread= --no-thread + --numbered --start-number --numbered-files --keep-subject --signoff + --signature --no-signature --in-reply-to= --cc= --full-index --binary + --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= + --inline --suffix= --ignore-if-in-upstream --subject-prefix= + --output-directory --reroll-count --to= --quiet --notes +" + +_git_format_patch () +{ + case "$cur" in + --thread=*) + __gitcomp " + deep shallow + " "" "${cur##--thread=}" + return + ;; + --*) + __gitcomp "$__git_format_patch_options" + return + ;; + esac + __git_complete_revlist +} + +_git_fsck () +{ + case "$cur" in + --*) + __gitcomp " + --tags --root --unreachable --cache --no-reflogs --full + --strict --verbose --lost-found + " + return + ;; + esac +} + +_git_gc () +{ + case "$cur" in + --*) + __gitcomp "--prune --aggressive" + return + ;; + esac +} + +_git_gitk () +{ + _gitk +} + +__git_match_ctag() { + awk "/^${1//\//\\/}/ { print \$1 }" "$2" +} + +_git_grep () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp " + --cached + --text --ignore-case --word-regexp --invert-match + --full-name --line-number + --extended-regexp --basic-regexp --fixed-strings + --perl-regexp + --files-with-matches --name-only + --files-without-match + --max-depth + --count + --and --or --not --all-match + " + return + ;; + esac + + case "$cword,$prev" in + 2,*|*,-*) + if test -r tags; then + __gitcomp_nl "$(__git_match_ctag "$cur" tags)" + return + fi + ;; + esac + + __gitcomp_nl "$(__git_refs)" +} + +_git_help () +{ + case "$cur" in + --*) + __gitcomp "--all --info --man --web" + return + ;; + esac + __git_compute_all_commands + __gitcomp "$__git_all_commands $(__git_aliases) + attributes cli core-tutorial cvs-migration + diffcore gitk glossary hooks ignore modules + namespaces repository-layout tutorial tutorial-2 + workflows + " +} + +_git_init () +{ + case "$cur" in + --shared=*) + __gitcomp " + false true umask group all world everybody + " "" "${cur##--shared=}" + return + ;; + --*) + __gitcomp "--quiet --bare --template= --shared --shared=" + return + ;; + esac +} + +_git_ls_files () +{ + case "$cur" in + --*) + __gitcomp "--cached --deleted --modified --others --ignored + --stage --directory --no-empty-directory --unmerged + --killed --exclude= --exclude-from= + --exclude-per-directory= --exclude-standard + --error-unmatch --with-tree= --full-name + --abbrev --ignored --exclude-per-directory + " + return + ;; + esac + + # XXX ignore options like --modified and always suggest all cached + # files. + __git_complete_index_file "--cached" +} + +_git_ls_remote () +{ + __gitcomp_nl "$(__git_remotes)" +} + +_git_ls_tree () +{ + __git_complete_file +} + +# Options that go well for log, shortlog and gitk +__git_log_common_options=" + --not --all + --branches --tags --remotes + --first-parent --merges --no-merges + --max-count= + --max-age= --since= --after= + --min-age= --until= --before= + --min-parents= --max-parents= + --no-min-parents --no-max-parents +" +# Options that go well for log and gitk (not shortlog) +__git_log_gitk_options=" + --dense --sparse --full-history + --simplify-merges --simplify-by-decoration + --left-right --notes --no-notes +" +# Options that go well for log and shortlog (not gitk) +__git_log_shortlog_options=" + --author= --committer= --grep= + --all-match --invert-grep +" + +__git_log_pretty_formats="oneline short medium full fuller email raw format:" +__git_log_date_formats="relative iso8601 rfc2822 short local default raw" + +_git_log () +{ + __git_has_doubledash && return + + local g="$(git rev-parse --git-dir 2>/dev/null)" + local merge="" + if [ -f "$g/MERGE_HEAD" ]; then + merge="--merge" + fi + case "$cur" in + --pretty=*|--format=*) + __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) + " "" "${cur#*=}" + return + ;; + --date=*) + __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" + return + ;; + --decorate=*) + __gitcomp "full short no" "" "${cur##--decorate=}" + return + ;; + --*) + __gitcomp " + $__git_log_common_options + $__git_log_shortlog_options + $__git_log_gitk_options + --root --topo-order --date-order --reverse + --follow --full-diff + --abbrev-commit --abbrev= + --relative-date --date= + --pretty= --format= --oneline + --show-signature + --cherry-pick + --graph + --decorate --decorate= + --walk-reflogs + --parents --children + $merge + $__git_diff_common_options + --pickaxe-all --pickaxe-regex + " + return + ;; + esac + __git_complete_revlist +} + +# Common merge options shared by git-merge(1) and git-pull(1). +__git_merge_options=" + --no-commit --no-stat --log --no-log --squash --strategy + --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit + --verify-signatures --no-verify-signatures --gpg-sign + --quiet --verbose --progress --no-progress +" + +_git_merge () +{ + __git_complete_strategy && return + + case "$cur" in + --*) + __gitcomp "$__git_merge_options + --rerere-autoupdate --no-rerere-autoupdate --abort" + return + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_mergetool () +{ + case "$cur" in + --tool=*) + __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}" + return + ;; + --*) + __gitcomp "--tool=" + return + ;; + esac +} + +_git_merge_base () +{ + case "$cur" in + --*) + __gitcomp "--octopus --independent --is-ancestor --fork-point" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_mv () +{ + case "$cur" in + --*) + __gitcomp "--dry-run" + return + ;; + esac + + if [ $(__git_count_arguments "mv") -gt 0 ]; then + # We need to show both cached and untracked files (including + # empty directories) since this may not be the last argument. + __git_complete_index_file "--cached --others --directory" + else + __git_complete_index_file "--cached" + fi +} + +_git_name_rev () +{ + __gitcomp "--tags --all --stdin" +} + +_git_notes () +{ + local subcommands='add append copy edit list prune remove show' + local subcommand="$(__git_find_on_cmdline "$subcommands")" + + case "$subcommand,$cur" in + ,--*) + __gitcomp '--ref' + ;; + ,*) + case "$prev" in + --ref) + __gitcomp_nl "$(__git_refs)" + ;; + *) + __gitcomp "$subcommands --ref" + ;; + esac + ;; + add,--reuse-message=*|append,--reuse-message=*|\ + add,--reedit-message=*|append,--reedit-message=*) + __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" + ;; + add,--*|append,--*) + __gitcomp '--file= --message= --reedit-message= + --reuse-message=' + ;; + copy,--*) + __gitcomp '--stdin' + ;; + prune,--*) + __gitcomp '--dry-run --verbose' + ;; + prune,*) + ;; + *) + case "$prev" in + -m|-F) + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac + ;; + esac +} + +_git_pull () +{ + __git_complete_strategy && return + + case "$cur" in + --recurse-submodules=*) + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --*) + __gitcomp " + --rebase --no-rebase + $__git_merge_options + $__git_fetch_options + " + return + ;; + esac + __git_complete_remote_or_refspec +} + +__git_push_recurse_submodules="check on-demand" + +__git_complete_force_with_lease () +{ + local cur_=$1 + + case "$cur_" in + --*=) + ;; + *:*) + __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" + ;; + *) + __gitcomp_nl "$(__git_refs)" "" "$cur_" + ;; + esac +} + +_git_push () +{ + case "$prev" in + --repo) + __gitcomp_nl "$(__git_remotes)" + return + ;; + --recurse-submodules) + __gitcomp "$__git_push_recurse_submodules" + return + ;; + esac + case "$cur" in + --repo=*) + __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}" + return + ;; + --recurse-submodules=*) + __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --force-with-lease=*) + __git_complete_force_with_lease "${cur##--force-with-lease=}" + return + ;; + --*) + __gitcomp " + --all --mirror --tags --dry-run --force --verbose + --quiet --prune --delete --follow-tags + --receive-pack= --repo= --set-upstream + --force-with-lease --force-with-lease= --recurse-submodules= + " + return + ;; + esac + __git_complete_remote_or_refspec +} + +_git_rebase () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/rebase-merge/interactive ]; then + __gitcomp "--continue --skip --abort --edit-todo" + return + elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then + __gitcomp "--continue --skip --abort" + return + fi + __git_complete_strategy && return + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --onto --merge --strategy --interactive + --preserve-merges --stat --no-stat + --committer-date-is-author-date --ignore-date + --ignore-whitespace --whitespace= + --autosquash --fork-point --no-fork-point + --autostash + " + + return + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_reflog () +{ + local subcommands="show delete expire" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + else + __gitcomp_nl "$(__git_refs)" + fi +} + +__git_send_email_confirm_options="always never auto cc compose" +__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" + +_git_send_email () +{ + case "$cur" in + --confirm=*) + __gitcomp " + $__git_send_email_confirm_options + " "" "${cur##--confirm=}" + return + ;; + --suppress-cc=*) + __gitcomp " + $__git_send_email_suppresscc_options + " "" "${cur##--suppress-cc=}" + + return + ;; + --smtp-encryption=*) + __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}" + return + ;; + --thread=*) + __gitcomp " + deep shallow + " "" "${cur##--thread=}" + return + ;; + --*) + __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to + --compose --confirm= --dry-run --envelope-sender + --from --identity + --in-reply-to --no-chain-reply-to --no-signed-off-by-cc + --no-suppress-from --no-thread --quiet + --signed-off-by-cc --smtp-pass --smtp-server + --smtp-server-port --smtp-encryption= --smtp-user + --subject --suppress-cc= --suppress-from --thread --to + --validate --no-validate + $__git_format_patch_options" + return + ;; + esac + __git_complete_revlist +} + +_git_stage () +{ + _git_add +} + +__git_config_get_set_variables () +{ + local prevword word config_file= c=$cword + while [ $c -gt 1 ]; do + word="${words[c]}" + case "$word" in + --system|--global|--local|--file=*) + config_file="$word" + break + ;; + -f|--file) + config_file="$word $prevword" + break + ;; + esac + prevword=$word + c=$((--c)) + done + + git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null +} + +_git_config () +{ + case "$prev" in + branch.*.remote|branch.*.pushremote) + __gitcomp_nl "$(__git_remotes)" + return + ;; + branch.*.merge) + __gitcomp_nl "$(__git_refs)" + return + ;; + branch.*.rebase) + __gitcomp "false true" + return + ;; + remote.pushdefault) + __gitcomp_nl "$(__git_remotes)" + return + ;; + remote.*.fetch) + local remote="${prev#remote.}" + remote="${remote%.fetch}" + if [ -z "$cur" ]; then + __gitcomp_nl "refs/heads/" "" "" "" + return + fi + __gitcomp_nl "$(__git_refs_remotes "$remote")" + return + ;; + remote.*.push) + local remote="${prev#remote.}" + remote="${remote%.push}" + __gitcomp_nl "$(git --git-dir="$(__gitdir)" \ + for-each-ref --format='%(refname):%(refname)' \ + refs/heads)" + return + ;; + pull.twohead|pull.octopus) + __git_compute_merge_strategies + __gitcomp "$__git_merge_strategies" + return + ;; + color.branch|color.diff|color.interactive|\ + color.showbranch|color.status|color.ui) + __gitcomp "always never auto" + return + ;; + color.pager) + __gitcomp "false true" + return + ;; + color.*.*) + __gitcomp " + normal black red green yellow blue magenta cyan white + bold dim ul blink reverse + " + return + ;; + diff.submodule) + __gitcomp "log short" + return + ;; + help.format) + __gitcomp "man info web html" + return + ;; + log.date) + __gitcomp "$__git_log_date_formats" + return + ;; + sendemail.aliasesfiletype) + __gitcomp "mutt mailrc pine elm gnus" + return + ;; + sendemail.confirm) + __gitcomp "$__git_send_email_confirm_options" + return + ;; + sendemail.suppresscc) + __gitcomp "$__git_send_email_suppresscc_options" + return + ;; + sendemail.transferencoding) + __gitcomp "7bit 8bit quoted-printable base64" + return + ;; + --get|--get-all|--unset|--unset-all) + __gitcomp_nl "$(__git_config_get_set_variables)" + return + ;; + *.*) + return + ;; + esac + case "$cur" in + --*) + __gitcomp " + --system --global --local --file= + --list --replace-all + --get --get-all --get-regexp + --add --unset --unset-all + --remove-section --rename-section + --name-only + " + return + ;; + branch.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" + return + ;; + branch.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "." + __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_" + return + ;; + guitool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp " + argprompt cmd confirm needsfile noconsole norescan + prompt revprompt revunmerged title + " "$pfx" "$cur_" + return + ;; + difftool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path" "$pfx" "$cur_" + return + ;; + man.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path" "$pfx" "$cur_" + return + ;; + mergetool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" + return + ;; + pager.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __git_compute_all_commands + __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" + return + ;; + remote.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp " + url proxy fetch push mirror skipDefaultUpdate + receivepack uploadpack tagopt pushurl + " "$pfx" "$cur_" + return + ;; + remote.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." + __gitcomp_nl_append "pushdefault" "$pfx" "$cur_" + return + ;; + url.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" + return + ;; + esac + __gitcomp " + add.ignoreErrors + advice.commitBeforeMerge + advice.detachedHead + advice.implicitIdentity + advice.pushNonFastForward + advice.resolveConflict + advice.statusHints + alias. + am.keepcr + apply.ignorewhitespace + apply.whitespace + branch.autosetupmerge + branch.autosetuprebase + browser. + clean.requireForce + color.branch + color.branch.current + color.branch.local + color.branch.plain + color.branch.remote + color.decorate.HEAD + color.decorate.branch + color.decorate.remoteBranch + color.decorate.stash + color.decorate.tag + color.diff + color.diff.commit + color.diff.frag + color.diff.func + color.diff.meta + color.diff.new + color.diff.old + color.diff.plain + color.diff.whitespace + color.grep + color.grep.context + color.grep.filename + color.grep.function + color.grep.linenumber + color.grep.match + color.grep.selected + color.grep.separator + color.interactive + color.interactive.error + color.interactive.header + color.interactive.help + color.interactive.prompt + color.pager + color.showbranch + color.status + color.status.added + color.status.changed + color.status.header + color.status.nobranch + color.status.unmerged + color.status.untracked + color.status.updated + color.ui + commit.status + commit.template + core.abbrev + core.askpass + core.attributesfile + core.autocrlf + core.bare + core.bigFileThreshold + core.compression + core.createObject + core.deltaBaseCacheLimit + core.editor + core.eol + core.excludesfile + core.fileMode + core.fsyncobjectfiles + core.gitProxy + core.ignoreStat + core.ignorecase + core.logAllRefUpdates + core.loosecompression + core.notesRef + core.packedGitLimit + core.packedGitWindowSize + core.pager + core.preferSymlinkRefs + core.preloadindex + core.quotepath + core.repositoryFormatVersion + core.safecrlf + core.sharedRepository + core.sparseCheckout + core.symlinks + core.trustctime + core.warnAmbiguousRefs + core.whitespace + core.worktree + diff.autorefreshindex + diff.external + diff.ignoreSubmodules + diff.mnemonicprefix + diff.noprefix + diff.renameLimit + diff.renames + diff.statGraphWidth + diff.submodule + diff.suppressBlankEmpty + diff.tool + diff.wordRegex + diff.algorithm + difftool. + difftool.prompt + fetch.recurseSubmodules + fetch.unpackLimit + format.attach + format.cc + format.coverLetter + format.headers + format.numbered + format.pretty + format.signature + format.signoff + format.subjectprefix + format.suffix + format.thread + format.to + gc. + gc.aggressiveWindow + gc.auto + gc.autopacklimit + gc.packrefs + gc.pruneexpire + gc.reflogexpire + gc.reflogexpireunreachable + gc.rerereresolved + gc.rerereunresolved + gitcvs.allbinary + gitcvs.commitmsgannotation + gitcvs.dbTableNamePrefix + gitcvs.dbdriver + gitcvs.dbname + gitcvs.dbpass + gitcvs.dbuser + gitcvs.enabled + gitcvs.logfile + gitcvs.usecrlfattr + guitool. + gui.blamehistoryctx + gui.commitmsgwidth + gui.copyblamethreshold + gui.diffcontext + gui.encoding + gui.fastcopyblame + gui.matchtrackingbranch + gui.newbranchtemplate + gui.pruneduringfetch + gui.spellingdictionary + gui.trustmtime + help.autocorrect + help.browser + help.format + http.lowSpeedLimit + http.lowSpeedTime + http.maxRequests + http.minSessions + http.noEPSV + http.postBuffer + http.proxy + http.sslCipherList + http.sslVersion + http.sslCAInfo + http.sslCAPath + http.sslCert + http.sslCertPasswordProtected + http.sslKey + http.sslVerify + http.useragent + i18n.commitEncoding + i18n.logOutputEncoding + imap.authMethod + imap.folder + imap.host + imap.pass + imap.port + imap.preformattedHTML + imap.sslverify + imap.tunnel + imap.user + init.templatedir + instaweb.browser + instaweb.httpd + instaweb.local + instaweb.modulepath + instaweb.port + interactive.singlekey + log.date + log.decorate + log.showroot + mailmap.file + man. + man.viewer + merge. + merge.conflictstyle + merge.log + merge.renameLimit + merge.renormalize + merge.stat + merge.tool + merge.verbosity + mergetool. + mergetool.keepBackup + mergetool.keepTemporaries + mergetool.prompt + notes.displayRef + notes.rewrite. + notes.rewrite.amend + notes.rewrite.rebase + notes.rewriteMode + notes.rewriteRef + pack.compression + pack.deltaCacheLimit + pack.deltaCacheSize + pack.depth + pack.indexVersion + pack.packSizeLimit + pack.threads + pack.window + pack.windowMemory + pager. + pretty. + pull.octopus + pull.twohead + push.default + push.followTags + rebase.autosquash + rebase.stat + receive.autogc + receive.denyCurrentBranch + receive.denyDeleteCurrent + receive.denyDeletes + receive.denyNonFastForwards + receive.fsckObjects + receive.unpackLimit + receive.updateserverinfo + remote.pushdefault + remotes. + repack.usedeltabaseoffset + rerere.autoupdate + rerere.enabled + sendemail. + sendemail.aliasesfile + sendemail.aliasfiletype + sendemail.bcc + sendemail.cc + sendemail.cccmd + sendemail.chainreplyto + sendemail.confirm + sendemail.envelopesender + sendemail.from + sendemail.identity + sendemail.multiedit + sendemail.signedoffbycc + sendemail.smtpdomain + sendemail.smtpencryption + sendemail.smtppass + sendemail.smtpserver + sendemail.smtpserveroption + sendemail.smtpserverport + sendemail.smtpuser + sendemail.suppresscc + sendemail.suppressfrom + sendemail.thread + sendemail.to + sendemail.validate + showbranch.default + status.relativePaths + status.showUntrackedFiles + status.submodulesummary + submodule. + tar.umask + transfer.unpackLimit + url. + user.email + user.name + user.signingkey + web.browser + branch. remote. + " +} + +_git_remote () +{ + local subcommands="add rename remove set-head set-branches set-url show prune update" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + return + fi + + case "$subcommand" in + rename|remove|set-url|show|prune) + __gitcomp_nl "$(__git_remotes)" + ;; + set-head|set-branches) + __git_complete_remote_or_refspec + ;; + update) + __gitcomp "$(__git_get_config_variables "remotes")" + ;; + *) + ;; + esac +} + +_git_replace () +{ + __gitcomp_nl "$(__git_refs)" +} + +_git_reset () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp "--merge --mixed --hard --soft --patch" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_revert () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/REVERT_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi + case "$cur" in + --*) + __gitcomp "--edit --mainline --no-edit --no-commit --signoff" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_rm () +{ + case "$cur" in + --*) + __gitcomp "--cached --dry-run --ignore-unmatch --quiet" + return + ;; + esac + + __git_complete_index_file "--cached" +} + +_git_shortlog () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp " + $__git_log_common_options + $__git_log_shortlog_options + --numbered --summary + " + return + ;; + esac + __git_complete_revlist +} + +_git_show () +{ + __git_has_doubledash && return + + case "$cur" in + --pretty=*|--format=*) + __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) + " "" "${cur#*=}" + return + ;; + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --*) + __gitcomp "--pretty= --format= --abbrev-commit --oneline + --show-signature + $__git_diff_common_options + " + return + ;; + esac + __git_complete_revlist_file +} + +_git_show_branch () +{ + case "$cur" in + --*) + __gitcomp " + --all --remotes --topo-order --current --more= + --list --independent --merge-base --no-name + --color --no-color + --sha1-name --sparse --topics --reflog + " + return + ;; + esac + __git_complete_revlist +} + +_git_stash () +{ + local save_opts='--keep-index --no-keep-index --quiet --patch' + local subcommands='save list show apply clear drop pop create branch' + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + case "$cur" in + --*) + __gitcomp "$save_opts" + ;; + *) + if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then + __gitcomp "$subcommands" + fi + ;; + esac + else + case "$subcommand,$cur" in + save,--*) + __gitcomp "$save_opts" + ;; + apply,--*|pop,--*) + __gitcomp "--index --quiet" + ;; + show,--*|drop,--*|branch,--*) + ;; + show,*|apply,*|drop,*|pop,*|branch,*) + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ + | sed -n -e 's/:.*//p')" + ;; + *) + ;; + esac + fi +} + +_git_submodule () +{ + __git_has_doubledash && return + + local subcommands="add status init deinit update summary foreach sync" + if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then + case "$cur" in + --*) + __gitcomp "--quiet --cached" + ;; + *) + __gitcomp "$subcommands" + ;; + esac + return + fi +} + +_git_svn () +{ + local subcommands=" + init fetch clone rebase dcommit log find-rev + set-tree commit-diff info create-ignore propget + proplist show-ignore show-externals branch tag blame + migrate mkdirs reset gc + " + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + else + local remote_opts="--username= --config-dir= --no-auth-cache" + local fc_opts=" + --follow-parent --authors-file= --repack= + --no-metadata --use-svm-props --use-svnsync-props + --log-window-size= --no-checkout --quiet + --repack-flags --use-log-author --localtime + --ignore-paths= --include-paths= $remote_opts + " + local init_opts=" + --template= --shared= --trunk= --tags= + --branches= --stdlayout --minimize-url + --no-metadata --use-svm-props --use-svnsync-props + --rewrite-root= --prefix= --use-log-author + --add-author-from $remote_opts + " + local cmt_opts=" + --edit --rmdir --find-copies-harder --copy-similarity= + " + + case "$subcommand,$cur" in + fetch,--*) + __gitcomp "--revision= --fetch-all $fc_opts" + ;; + clone,--*) + __gitcomp "--revision= $fc_opts $init_opts" + ;; + init,--*) + __gitcomp "$init_opts" + ;; + dcommit,--*) + __gitcomp " + --merge --strategy= --verbose --dry-run + --fetch-all --no-rebase --commit-url + --revision --interactive $cmt_opts $fc_opts + " + ;; + set-tree,--*) + __gitcomp "--stdin $cmt_opts $fc_opts" + ;; + create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ + show-externals,--*|mkdirs,--*) + __gitcomp "--revision=" + ;; + log,--*) + __gitcomp " + --limit= --revision= --verbose --incremental + --oneline --show-commit --non-recursive + --authors-file= --color + " + ;; + rebase,--*) + __gitcomp " + --merge --verbose --strategy= --local + --fetch-all --dry-run $fc_opts + " + ;; + commit-diff,--*) + __gitcomp "--message= --file= --revision= $cmt_opts" + ;; + info,--*) + __gitcomp "--url" + ;; + branch,--*) + __gitcomp "--dry-run --message --tag" + ;; + tag,--*) + __gitcomp "--dry-run --message" + ;; + blame,--*) + __gitcomp "--git-format" + ;; + migrate,--*) + __gitcomp " + --config-dir= --ignore-paths= --minimize + --no-auth-cache --username= + " + ;; + reset,--*) + __gitcomp "--revision= --parent" + ;; + *) + ;; + esac + fi +} + +_git_tag () +{ + local i c=1 f=0 + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -d|-v) + __gitcomp_nl "$(__git_tags)" + return + ;; + -f) + f=1 + ;; + esac + ((c++)) + done + + case "$prev" in + -m|-F) + ;; + -*|tag) + if [ $f = 1 ]; then + __gitcomp_nl "$(__git_tags)" + fi + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac + + case "$cur" in + --*) + __gitcomp " + --list --delete --verify --annotate --message --file + --sign --cleanup --local-user --force --column --sort + --contains --points-at + " + ;; + esac +} + +_git_whatchanged () +{ + _git_log +} + +__git_main () +{ + local i c=1 command __git_dir + + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + --git-dir=*) __git_dir="${i#--git-dir=}" ;; + --git-dir) ((c++)) ; __git_dir="${words[c]}" ;; + --bare) __git_dir="." ;; + --help) command="help"; break ;; + -c|--work-tree|--namespace) ((c++)) ;; + -*) ;; + *) command="$i"; break ;; + esac + ((c++)) + done + + if [ -z "$command" ]; then + case "$cur" in + --*) __gitcomp " + --paginate + --no-pager + --git-dir= + --bare + --version + --exec-path + --exec-path= + --html-path + --man-path + --info-path + --work-tree= + --namespace= + --no-replace-objects + --help + " + ;; + *) __git_compute_porcelain_commands + __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; + esac + return + fi + + local completion_func="_git_${command//-/_}" + declare -f $completion_func >/dev/null && $completion_func && return + + local expansion=$(__git_aliased_command "$command") + if [ -n "$expansion" ]; then + words[1]=$expansion + completion_func="_git_${expansion//-/_}" + declare -f $completion_func >/dev/null && $completion_func + fi +} + +__gitk_main () +{ + __git_has_doubledash && return + + local g="$(__gitdir)" + local merge="" + if [ -f "$g/MERGE_HEAD" ]; then + merge="--merge" + fi + case "$cur" in + --*) + __gitcomp " + $__git_log_common_options + $__git_log_gitk_options + $merge + " + return + ;; + esac + __git_complete_revlist +} + +if [[ -n ${ZSH_VERSION-} ]]; then + echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 + + autoload -U +X compinit && compinit + + __gitcomp () + { + emulate -L zsh + + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + *) + local c IFS=$' \t\n' + local -a array + for c in ${=1}; do + c="$c${4-}" + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + array[${#array[@]}+1]="$c" + done + compset -P '*[=:]' + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 + ;; + esac + } + + __gitcomp_nl () + { + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + } + + __gitcomp_file () + { + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 + } + + _git () + { + local _ret=1 cur cword prev + cur=${words[CURRENT]} + prev=${words[CURRENT-1]} + let cword=CURRENT-1 + emulate ksh -c __${service}_main + let _ret && _default && _ret=0 + return _ret + } + + compdef _git git gitk + return +fi + +__git_func_wrap () +{ + local cur words cword prev + _get_comp_words_by_ref -n =: cur words cword prev + $1 +} + +# Setup completion for certain functions defined above by setting common +# variables and workarounds. +# This is NOT a public function; use at your own risk. +__git_complete () +{ + local wrapper="__git_wrap${2}" + eval "$wrapper () { __git_func_wrap $2 ; }" + complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \ + || complete -o default -o nospace -F $wrapper $1 +} + +# wrapper for backwards compatibility +_git () +{ + __git_wrap__git_main +} + +# wrapper for backwards compatibility +_gitk () +{ + __git_wrap__gitk_main +} + +__git_complete git __git_main +__git_complete gitk __gitk_main + +# The following are necessary only for Cygwin, and only are needed +# when the user has tab-completed the executable name and consequently +# included the '.exe' suffix. +# +if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then +__git_complete git.exe __git_main +fi diff --git a/arch/git/.gitconfig b/arch/git/.gitconfig new file mode 100644 index 0000000..da62c87 --- /dev/null +++ b/arch/git/.gitconfig @@ -0,0 +1,20 @@ +[user] + name = Adam Cooper + email = adam@theadamcooper.com + +[core] + pager = delta + +[interactive] + diffFilter = delta --color-only + +[delta] + features = side-by-side line-numbers decorations + whitespace-error-style = 22 reverse + +[delta "decorations"] + commit-decoration-style = bold yellow box ul + file-style = bold yellow ul + file-decoration-style = none +[init] + defaultBranch = main diff --git a/arch/install.sh b/arch/install.sh new file mode 100755 index 0000000..1b47dfc --- /dev/null +++ b/arch/install.sh @@ -0,0 +1,51 @@ +#!/bin/bash +echo "Upgrading packages**" +sudo pacman -Syu +echo "**Installing packages: vim, tmux, python3, cmake, stow, fonts-powerline, snapd, etc.**" +sudo pacman -S --no-confirm git curl zsh gvim tmux python python-pip cmake stow lastpass-cli rust +echo "source $HOME/.cargo/env" >> ./zsh/.zshrc +echo "**Installing powerline and tmuxp**" +# pip3 install powerline-status +pip3 install --user tmuxp +echo "**Installing plug.vim**" +curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +echo "**Installing diff-so-fancy**" +curl -fsSL -o ~/.local/bin/diff-so-fancy https://raw.githubusercontent.com/so-fancy/diff-so-fancy/master/third_party/build_fatpack/diff-so-fancy +sudo chmod 755 ~/.local/bin/diff-so-fancy +echo "**Backing up config files**" +[[ -f ~/.zshrc ]] && mv -v ~/.zshrc ~/.zshrc.bak +[[ -f ~/.vimrc ]] && mv -v ~/.vimrc ~/.vimrc.bak +[[ -f ~/.tmux.conf ]] && mv -v ~/.tmux.conf ~/.tmux.conf.bak +[[ -f ~/.git-completion ]] && mv -v ~/.git-completion ~/.git-completion.bak +[[ -f ~/.gitconfig ]] && mv -v ~/.gitconfig ~/.gitconfig.bak +[[ -f ~/.oysttyerrc ]] && mv -v ~/.oysttyerrc ~/.oysttyerrc.bak +[[ -f ~/.oysttyerkey ]] && mv -v ~/.oysttyerkey ~/.oysttyerkey.bak +[[ -f ~/.egrc ]] && mv -v ~/.egrc ~/.egrc.bak +[[ -f /usr/local/bin/consolidate-path ]] && mv -v /usr/local/bin/consolidate-path /usr/local/bin/consolidate-path.bak +echo "**Installing new config files**" +stow -t ~ zsh +stow -t ~ vim +stow -t ~ tmux +stow -t ~ git +stow -t ~ newsboat +stow -t ~ eg +stow -t ~ oysttyer +stow -t /usr/local/bin bin +# echo "**Installing ddgr**" +# pip3 install ddgr +echo "**Installing NVM**" +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash +# echo "**Installing Yarn**" +# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +# sudo apt-get update && sudo apt-get install --no-install-recommends yarn +# echo "**Installing Oh My Zsh**" +# git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh +# echo "**Installing zsh-nvm**" +# git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm +echo "**Switching to zsh**" +chsh -s /bin/zsh +echo "[TODO] **Download and install bat cb eg exa fd newsboat consolidate-path**" +echo "**Please restart the system and run ~/dotfiles/post-install.sh**" +/bin/zsh + diff --git a/arch/newsboat/.newsboat/config b/arch/newsboat/.newsboat/config new file mode 100644 index 0000000..a193f9b --- /dev/null +++ b/arch/newsboat/.newsboat/config @@ -0,0 +1,27 @@ +bind-key G end +bind-key g home +bind-key j down +bind-key k up +browser "w3m %u" +# Color key https://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html +# color22 green +# color199 magenta +# color255 light grey +color listfocus color255 color199 +color listfocus_unread color255 color199 bold +color info color255 color22 +color title color255 color22 bold +color hint-key color255 color22 bold +color hint-separator color255 color22 bold +confirm-exit yes +define-filter "nitter feeds" "tags !# \"nitter_personal\" and tags !# \"nitter_institutional\" and tags !# \"nitter_noise\"" +feed-sort-order firsttag +keep-articles-days 45 +max-items 4096 +notify-program "/usr/bin/notify-send" +urls-source "ttrss" +ttrss-url "https://rss.theadamcooper.com/" +ttrss-login "adam" +ttrss-passwordeval "secret-tool lookup service ttrss" +ttrss-flag-star "s" +ttrss-flag-publish "p" diff --git a/arch/newsboat/.newsboat/history.search b/arch/newsboat/.newsboat/history.search new file mode 100644 index 0000000..397a651 --- /dev/null +++ b/arch/newsboat/.newsboat/history.search @@ -0,0 +1,4 @@ +Guardian +pool +rss +deeplinks diff --git a/arch/newsboat/.newsboat/urls b/arch/newsboat/.newsboat/urls new file mode 100644 index 0000000..57223e7 --- /dev/null +++ b/arch/newsboat/.newsboat/urls @@ -0,0 +1,7 @@ +"query:miscellany Articles:tags # \"miscellany\"" +"query:nitter_personal Articles:tags # \"nitter_personal\"" +"query:nitter_institutional Articles:tags # \"nitter_institutional\"" +"query:nitter_noise Articles:tags # \"nitter_noise\"" +"query:nuggets Articles:tags # \"nuggets\"" +"query:release_notes Articles:tags # \"release_notes\"" +"query:tech Articles:tags # \"tech\"" diff --git a/arch/oysttyer/.oysttyerkey b/arch/oysttyer/.oysttyerkey new file mode 100644 index 0000000..d9874d0 --- /dev/null +++ b/arch/oysttyer/.oysttyerkey @@ -0,0 +1 @@ +ck=X&cs=X&at=14814274-sTXAoAlc9gpgjRR451UsnG0ZLRodvDD6rfeOmJGHZ&ats=V8MtTSuNb5HKy1JGFC2q3T3DhdpfGbjdRKCCFeo0zc9Z8 diff --git a/arch/oysttyer/.oysttyerrc b/arch/oysttyer/.oysttyerrc new file mode 100644 index 0000000..151e005 --- /dev/null +++ b/arch/oysttyer/.oysttyerrc @@ -0,0 +1,11 @@ +# keyf=/Users/adamcooper/.oysttyerkey +oauthkey=17N3a4JBR8jJsbBBdwxfAqM5a +oauthsecret=pIuaI8sDqwMH7eqthVpqTAA1zY37pB3MY4EfrVFHnSLOpElg0T +ansi=1 +separator= * * * * * * * * * * * +doublespace=1 +vcheck=1 +urlopen=surf-open.sh %U +synch=1 +mentions=1 +verify=1 diff --git a/arch/post-install.sh b/arch/post-install.sh new file mode 100755 index 0000000..e65aecc --- /dev/null +++ b/arch/post-install.sh @@ -0,0 +1,16 @@ +# Post-install script +echo "**Installing Node and NPM with NVM**" +echo "source $HOME/.nvm/nvm.sh" >> ./zsh/.zshrc +stow -t ~ -R zsh +nvm install lts/dubnium +nvm use default +echo "**Installing Typescript**" +npm install -g typescript +echo "**Installing some essentials**" +sudo pacman -S bat cb fzf ripgrep +echo "" +echo "All that\'s left is the vim plugins. Install them by running:" +echo " $ vim -c \":PlugInstall\"" +echo "and then compile YouCompleteMe: " +echo " $ python ~/.vim/plugged/YouCompleteMe/install.py --ts-completer --rust-completer" +echo "and you're off to the races." diff --git a/arch/tmux/.tmux.conf b/arch/tmux/.tmux.conf new file mode 100644 index 0000000..3397ee8 --- /dev/null +++ b/arch/tmux/.tmux.conf @@ -0,0 +1,82 @@ +# 256 colors for vim +set -g default-terminal "screen-256color" + +# Set default shell to zsh +set-option -g default-shell /bin/zsh + +# Tmuxline +if-shell "test -f ~/.tmuxline_theme_snapshot" "source ~/.tmuxline_theme_snapshot" + +# Start window numbering at 1 +set-option -g base-index 1 +set-window-option -g pane-base-index 1 + +# Change prefix to C-sp +unbind-key C-b +set-option -g prefix C-Space +bind-key C-Space send-prefix + +# Cycle panes with C-b C-b +# unbind ^B +# bind ^B select-pane -t :.+ + +# Reload config wtih a key +bind-key r source-file ~/.tmux.conf \; display "Config reloaded!" + +# Mouse works as expected +set -g mouse on +# set -g mode-mouse on +# set -g mouse-select-pane on +# set -g mouse-resize-pane on +# set -g mouse-select-window on + +# Scrolling works as expected +set -g terminal-overrides 'xterm*:smcup@:rmcup@' + +# Use the system clipboard +# set-option -g default-command "reattach-to-user-namespace -l zsh" + +# Clear the pane and its history +bind -n C-k send-keys C-l \; clear-history + +# Smart pane switching with awareness of vim splits +# From github.com/christoomey/vim-tmux-navigator +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind-key -n C-\\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" +bind-key -T copy-mode-vi C-h select-pane -L +bind-key -T copy-mode-vi C-j select-pane -D +bind-key -T copy-mode-vi C-k select-pane -U +bind-key -T copy-mode-vi C-l select-pane -R +bind-key -T copy-mode-vi C-\\ select-pane -l + +# C-l is taken oer by vim style pane navigation (not sure where this comes from or whether I still need it) +bind C-l send-keys 'C-l' + +# Use vim keybindings in copy mode +setw -g mode-keys vi + +# Setup 'v' to begin selection as in Vim +# The next line throws a syntax error. +# bind-key -t vi-copy v begin-selection +# bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace cb" + +# Update default binding of `Enter` to also use copy-pipe +# unbind -t vi-copy Enter +# bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace cb" + +# tmux-weather +run-shell /home/adam/code/tmux-weather/tmux-weather.tmux + +# tmux-battery +run-shell /home/adam/code/tmux-battery/battery.tmux + +# tmux-cpu +run-shell /home/adam/code/tmux-cpu/cpu.tmux + +# tmux-protonvpn +run-shell /home/adam/code/tmux-protonvpn/protonvpn.tmux diff --git a/arch/tmux/.tmuxline_theme_snapshot b/arch/tmux/.tmuxline_theme_snapshot new file mode 100644 index 0000000..c7e1288 --- /dev/null +++ b/arch/tmux/.tmuxline_theme_snapshot @@ -0,0 +1,30 @@ +# This tmux statusbar config was created by tmuxline.vim on Tue, 14 Jul 2020 +# (and then tweaked later with weather, battery status, CPU stats) + +set -g status-interval 5 +set -g status-justify "left" +set -g status "on" +set -g status-left-style "none" +set -g message-command-style "fg=colour52,bg=colour214" +set -g status-right-style "none" +set -g pane-active-border-style "fg=colour202" +set -g status-style "none,bg=colour228" +set -g message-style "fg=colour52,bg=colour214" +set -g pane-border-style "fg=colour214" +set -g status-right-length "100" +set -g status-left-length "100" +set-option -g @tmux-weather-location "Atlantic Beach, New York, United States" +set-option -g @tmux-weather-format "%c+%20+%t+%w" +set-option -g @tmux-weather-units "u" +set-option -g @batt_remain_short 'true' +set-option -g @protonvpn_disconnected_text "🖧 " +set-option -g @protonvpn_connecting_text "…" +set-option -g @protonvpn_connecting_fg_color "colour166" +set-option -g @protonvpn_connected_text "⚛️ " +setw -g window-status-activity-style "none" +setw -g window-status-separator "" +setw -g window-status-style "none,fg=colour166,bg=colour228" +set -g status-left "#[fg=colour255,bg=colour202] #S #[fg=colour202,bg=colour228,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=colour166,bg=colour228,nobold,nounderscore,noitalics]#(pactl list sinks | grep Mute | sed -e 's/Mute: //' | sed -e 's/no/🔊/' | sed -e 's/yes/🔇/') #{protonvpn_status_color} #{protonvpn_status} #{cpu_fg_color}#{cpu_icon} #[fg=colour166] #{battery_status_bg} #{battery_icon} #{battery_percentage} #{battery_remain}  #{weather}  %m-%d %a %H:%M #[fg=colour202,bg=colour228,nobold,nounderscore,noitalics]#[fg=colour255,bg=colour202] #h " +setw -g window-status-format "#[fg=colour166,bg=colour228] #I #[fg=colour166,bg=colour228] #W " +setw -g window-status-current-format "#[fg=colour228,bg=colour214,nobold,nounderscore,noitalics]#[fg=colour52,bg=colour214] #I #[fg=colour52,bg=colour214] #W #F #[fg=colour214,bg=colour228,nobold,nounderscore,noitalics]" diff --git a/arch/tmux/.tmuxp/acorn.json b/arch/tmux/.tmuxp/acorn.json new file mode 100644 index 0000000..cf0f746 --- /dev/null +++ b/arch/tmux/.tmuxp/acorn.json @@ -0,0 +1,25 @@ +{ + "session_name": "acorn", + "windows": [{ + "window_name": "ide", + "panes": [ + "vim -R package.json", + "ls", + "git status" + ], + "layout": "main-horizontal", + "start_directory": "~/code/acorn-glen" + }, { + "window_name": "servers", + "start_directory": "~/code/acorn-glen", + "layout": "main-horizontal", + "panes": [{ + "shell_command": [ "cd ~/code/acorn-glen", "echo 'yarn dev'" ] + }, { + "shell_command": [ "sleep 4", "echo 'yarn relay --watch'" ] + }, { + "shell_command": [ "sleep 4", "echo 'yarn start'" ] + }] + }] +} + diff --git a/arch/tmux/.tmuxp/general.json b/arch/tmux/.tmuxp/general.json new file mode 100644 index 0000000..6301794 --- /dev/null +++ b/arch/tmux/.tmuxp/general.json @@ -0,0 +1,8 @@ +{ + "session_name": "general", + "windows": [{ + "panes": ["/etc/update-motd.d/90-custom"] + }], + "start_directory": "~" +} + diff --git a/arch/tmux/.tmuxp/morning.json b/arch/tmux/.tmuxp/morning.json new file mode 100644 index 0000000..4b9492e --- /dev/null +++ b/arch/tmux/.tmuxp/morning.json @@ -0,0 +1,18 @@ +{ + "session_name": "morning", + "windows": [{ + "window_name": "btm", + "panes": ["btm --color default-light"] + }, { + "window_name": "newsboat", + "panes": ["newsboat"] + }, { + "window_name": "ddgr", + "panes": ["ddgr --colors=ecdgxy 'Subcomandante Marcos'"] + }, { + "window_name": "general", + "panes": ["date"] + }], + "start_directory": "~" +} + diff --git a/arch/vim/.vimrc b/arch/vim/.vimrc new file mode 100644 index 0000000..dc29633 --- /dev/null +++ b/arch/vim/.vimrc @@ -0,0 +1,105 @@ +" Make backspace behave in a sane manner. +set backspace=indent,eol,start + +" Spaces indentation +set expandtab +set tabstop=2 +" set softtabstop=2 +set shiftwidth=2 +" Consider installing the Smart Tabs plugin + +" Show whitespace +set listchars=eol:¬,tab:>-,trail:~,extends:>,precedes:<,space:· + +" Show line numbers +set number + +" Default: split right +set splitright + +" Allow hidden buffers, don't limit to one file per window/split +set hidden + +" Sane vim split naviagation (via Gaslight blog) +nnoremap j +nnoremap k +nnoremap h +nnoremap l + +" Disable filetype detection +filetype off + +" Adjust cursor style to mode +" Normal: block; Insert: beam; Replace: underscore +" all blinking +let &t_EI = "\[1 q" +let &t_SI = "\[5 q" +let &t_SR = "\[3 q" +" reset the cursor on start +augroup CursorReset +au! +autocmd VimEnter * silent !echo -ne "\e[2 q" +augroup END + +" vim-plug +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +call plug#begin('~/.vim/plugged') +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'edkolev/tmuxline.vim' +Plug 'christoomey/vim-tmux-navigator' +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'dense-analysis/ale' +Plug 'Valloric/YouCompleteMe' +Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } +Plug 'pangloss/vim-javascript' +Plug 'MaxMEllon/vim-jsx-pretty' +Plug 'leafgarland/typescript-vim' +Plug 'HerringtonDarkholme/yats.vim' +Plug 'Quramy/tsuquyomi' +Plug 'rust-lang/rust.vim' +Plug 'neovimhaskell/haskell-vim' +Plug 'severij/vadelma' +Plug 'tpope/vim-surround' +call plug#end() + +" Tsuquyomi +autocmd filetype typescript nmap t : echo tsuquyomi#hint() + +" Airline +let g:airline_powerline_fonts = 1 +let g:airline_theme = 'light' +let g:airline#extensions#tmuxline#enabled = 0 + +" ALE +let g:ale_linters = {'haskell': ['hlint', 'hdevtools']} + +" YouCompleteMe +noremap :YcmCompleter GoTo + +" YouCompleteMe <> TypeScript +if !exists("g:ycm_semantic_triggers") + let g:ycm_semantic_triggers = {} +endif +let g:ycm_semantic_triggers['typescript'] = ['.'] + +" Enable file type detection and do language-dependent indenting +filetype plugin indent on + +" Switch syntax highlighting on +syntax enable + +" Set color scheme +set background=light +colorscheme vadelma + +" Temporary file locations +set backupdir=.backup/,~/.backup/,/tmp// +set directory=.swp/,~/.swp/,/tmp// +set undodir=.undo/,~/.undo/,/tmp// diff --git a/arch/xmobar/.xmobarrc b/arch/xmobar/.xmobarrc new file mode 100644 index 0000000..281e86d --- /dev/null +++ b/arch/xmobar/.xmobarrc @@ -0,0 +1,46 @@ +Config { overrideRedirect = False + , font = "xft:InconsolataGo Nerd Font Mono:size=8" + , additionalFonts = ["xft:JoyPixels:size=8"] + , bgColor = "#ffff99" + , fgColor = "#191970" + , position = TopW L 90 + , commands = [ Run WeatherX "KLGA" + [ ("clear", "🌣") + , ("sunny", "🌣") + , ("mostly clear", "🌤") + , ("mostly sunny", "🌤") + , ("partly sunny", "⛅") + , ("fair", "🌑") + , ("cloudy","☁") + , ("overcast","☁") + , ("partly cloudy", "⛅") + , ("mostly cloudy", "🌧") + , ("considerable cloudiness", "⛈")] + [ "--template", " °F" + , "-L", "0" + , "-H", "25" + , "--low" , "blue" + , "--normal", "#f8f8f2" + , "--high" , "red" + ] 36000 + , Run Cpu + [ "-L", "3" + , "-H", "50" + , "--high" , "red" + , "--normal", "darkgreen" + ] 10 + , Run Alsa "default" "Master" + [ "--template", "" + , "--suffix" , "True" + , "--" + , "--on", "" + ] + , Run Memory ["--template", "Mem: %"] 10 + , Run Swap [] 10 + , Run Date "%a %Y-%m-%d %H:%M" "date" 10 + , Run StdinReader + ] + , sepChar = "%" + , alignSep = "}{" + , template = "%StdinReader% }{ %alsa:default:Master% | %cpu% | %memory% * %swap% | %KLGA% | %date% " + } diff --git a/arch/xmonad/autostart.sh b/arch/xmonad/autostart.sh new file mode 100755 index 0000000..701e15b --- /dev/null +++ b/arch/xmonad/autostart.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +/usr/sbin/keepassxc & +sleep 16 + +# /usr/sbin/qutebrowser --restore home & sleep 5 && sh -c "wmctrl -r qutebrowser -t 2" +/usr/sbin/qutebrowser & sleep 5 && sh -c "wmctrl -r qutebrowser -t 2" +/usr/sbin/xterm -fa 'Fantasque Sans Mono:size=8' -e btm --battery --color gruvbox-light & sleep 5 && sh -c "wmctrl -r btm -t 1" +# /usr/sbin/xterm -e newsboat & sleep 5 && sh -c "wmctrl -r newsboat -t 4" +# /usr/sbin/xterm -e joplin & sleep 5 && sh -c "wmctrl -r joplin -t 5" +/usr/sbin/cbatticon & +/usr/sbin/nextcloud & +/usr/sbin/xterm -e neomutt & sleep 5 && sh -c "wmctrl -r neomutt -t 3" +# /usr/sbin/xterm -e aerc & sleep 5 && sh -c "wmctrl -r aerc -t 3" diff --git a/arch/xmonad/xmonad.hs b/arch/xmonad/xmonad.hs new file mode 100644 index 0000000..dd50751 --- /dev/null +++ b/arch/xmonad/xmonad.hs @@ -0,0 +1,42 @@ +import XMonad + +import XMonad.Hooks.DynamicLog +import XMonad.Hooks.EwmhDesktops +import XMonad.Util.EZConfig +import XMonad.Util.Loggers +import XMonad.Util.Ungrab + +main :: IO () +main = xmonad + . ewmh + =<< statusBar "xmobar" myXmobarPP toggleStrutsKey myConfig + where + toggleStrutsKey :: XConfig Layout -> (KeyMask, KeySym) + toggleStrutsKey XConfig{ modMask = m } = (m, xK_b) + +myConfig = def + { borderWidth = 4 + , terminal = "xterm" + , modMask = mod4Mask + , focusedBorderColor = "#ff00ff" + } + +myXmobarPP :: PP +myXmobarPP = def + { ppSep = magenta " • " + , ppTitle = shorten 32 + , ppTitleSanitize = xmobarStrip + , ppCurrent = wrap (mediumblue "[") (mediumblue "]") + , ppHidden = midnightblue . wrap " " "" + , ppHiddenNoWindows = teal . wrap " " "" + , ppUrgent = red . wrap (red "!") (red "!") + } + where + midnightblue, mediumblue, magenta, red, white, yellow, teal :: String -> String + midnightblue = xmobarColor "#191970" "" + mediumblue = xmobarColor "#0000cd" "" + magenta = xmobarColor "#ff79c6" "" + white = xmobarColor "#f8f8f2" "" + yellow = xmobarColor "#f1fa8c" "" + red = xmobarColor "#ff5555" "" + teal = xmobarColor "#008080" "" diff --git a/arch/zsh/.zsh/_keep b/arch/zsh/.zsh/_keep new file mode 100644 index 0000000..d58632f --- /dev/null +++ b/arch/zsh/.zsh/_keep @@ -0,0 +1,53 @@ +#compdef _keep keep + +function _keep { + local -a commands + + _arguments -C \ + "-v[Enables verbose mode]:" \ + "--verbose[Enables verbose mode]:" \ + "--help[Show the help message and exit]:" \ + "1: :->cmnds" \ + "*::arg:->args" + case $state in + cmnds) + commands=( + "edit:Edit a saved command." + "github_token:Register a GitHub Token to use GitHub Gists as a backup." + "grep:Searches for a saved command." + "init:Initializes the CLI." + "list:Shows the saved commands." + "new:Saves a new command." + "pull:Pull commands from saved GitHub gist." + "push:Push commands to a secret GitHub gist." + "rm:Deletes a saved command." + "run:Executes a saved command." + "update:Check for an update of Keep." + ) + _describe "command" commands + ;; + esac + + case "$words[1]" in + edit) + _keep_edit + ;; + rm) + _keep_commands + ;; + run) + _keep_commands + ;; + esac +} + +function _keep_edit { + _arguments \ + "--editor[Editor to use]" +} + +function _keep_commands { + local -a commands + commands=("${(@f)$(keep completion --zsh)}") + _describe "command" commands +} diff --git a/arch/zsh/.zshenv b/arch/zsh/.zshenv new file mode 100644 index 0000000..b65a83c --- /dev/null +++ b/arch/zsh/.zshenv @@ -0,0 +1,49 @@ +## XDG +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.config/local/share" +export XDG_CACHE_HOME="$HOME/.config/cache" +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" + +export HISTSIZE=9998 +export SAVEHIST=10000 + +export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.cargo/env:$HOME/code/go/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/go/bin:/usr/sbin:/usr/bin:/sbin:/bin:$HOME/.rbenv:$PATH" + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi + +export EDITOR="vim" +export VISUAL="vim" + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# FZF +export FZF_DEFAULT_COMMAND="fd --no-ignore --hidden --type f" # Includes hidden files +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" + +# bat theme +export BAT_THEME=OneHalfLight + +# exa colors +export LS_COLORS="rs=0:fi=35:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*.md=36" + +# ddgr +export BROWSER=w3m +export DDGR_COLORS="MBdexy" + +# navi +export NAVI_TAG_COLOR=6 +export NAVI_COMMENT_COLOR=3 + +# Consolidate PATH +export PATH="$(consolidate-path "$PATH")" diff --git a/arch/zsh/.zshrc b/arch/zsh/.zshrc new file mode 100644 index 0000000..8386b6d --- /dev/null +++ b/arch/zsh/.zshrc @@ -0,0 +1,132 @@ +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH + +HISTFILE=$ZDOTDIR/.zsh_history + +# terminal colors +export COLORTERM=24bit + +# Setting some opts +# setopt correct_all +setopt auto_pushd +setopt pushd_ignore_dups +setopt pushdminus +setopt extended_history # record timestamp of command in HISTFILE +setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE +setopt hist_ignore_dups # ignore duplicated commands history list +setopt hist_ignore_space # ignore commands that start with space +setopt hist_verify # show command with history expansion to user before running it +setopt share_history # share command history data +setopt long_list_jobs +setopt interactivecomments + +# Initialize the completion system +# fpath=(~/config/zsh/.zsh $fpath) +autoload -U compinit ; compinit + +## Vi keybindings for the shell ## +bindkey -v + +autoload -Uz edit-command-line +zle -N edit-command-line +bindkey -M vicmd v edit-command-line + +## History navigation by search pattern +autoload history-search-end +zle -N history-beginning-search-backward-end \ + history-search-end +zle -N history-beginning-search-forward-end \ + history-search-end +bindkey '^[[A' history-beginning-search-backward-end +bindkey '^[[B' history-beginning-search-forward-end + +## Aliases +source ~/.config/zsh/aliases.zsh + +source ~/.config/zsh/completion.zsh +source ~/.config/zsh/termsupport.zsh +source ~/.config/zsh/theme-and-appearance.zsh + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# Add pwd to history +# This version should strip any existing pwd from the command before adding the +# current pwd. This eliminates the pileup of these pwd comments when reusing +# old commands (e.g., with up-arrow). +function zshaddhistory() { + history_item="${${1%%$'\n'}%%$' ###'*} ### ${PWD}" + print -sr ${(z)history_item} + fc -p + return 1 +} + +# Starship +eval "$(starship init zsh)" + +## FZF ## +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh +source ~/.vim/plugged/fzf/shell/completion.zsh +source ~/.vim/plugged/fzf/shell/key-bindings.zsh + +# Use fd (https://github.com/sharkdp/fd) instead of the default find +# command for listing path candidates. +# - The first argument to the function ($1) is the base path to start traversal +# - See the source code (completion.{bash,zsh}) for the details. +_fzf_compgen_path() { + fd --no-ignore --hidden --follow --exclude ".git" . "$1" +} + +# Use fd to generate the list for directory completion +_fzf_compgen_dir() { + fd --no-ignore --type d --hidden --follow --exclude ".git" . "$1" +} + +# Block and beam cursors for vim mode +cursor_mode() { + # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes + cursor_block='\e[2 q' + cursor_beam='\e[6 q' + + function zle-keymap-select { + if [[ ${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + echo -ne $cursor_block + elif [[ ${KEYMAP} == main ]] || + [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || + [[ $1 = 'beam' ]]; then + echo -ne $cursor_beam + fi + } + + zle-line-init() { + echo -ne $cursor_beam + } + + zle -N zle-keymap-select + zle -N zle-line-init +} + +cursor_mode + +## zoxide ## +eval "$(zoxide init zsh)" + +# navi # +eval "$(navi widget zsh)" + +# tmuxp completion +eval "$(_TMUXP_COMPLETE=source_zsh tmuxp)" + +source /home/adam/.cargo/env +source /usr/share/nvm/init-nvm.sh + +# rbenv +eval "$(rbenv init -)" + +# broot +source /home/adam/.config/broot/launcher/bash/br + +# tea +PROG=tea _CLI_ZSH_AUTOCOMPLETE_HACK=1 source "/home/adam/.config/tea/autocomplete.zsh" diff --git a/arch/zsh/aliases.zsh b/arch/zsh/aliases.zsh new file mode 100644 index 0000000..236b3b5 --- /dev/null +++ b/arch/zsh/aliases.zsh @@ -0,0 +1,2 @@ +alias exi='exa --icons --group -al' +alias qb='QT_SCALE_FACTOR=1.5 /usr/bin/qutebrowser &' diff --git a/arch/zsh/completion.zsh b/arch/zsh/completion.zsh new file mode 100644 index 0000000..ebaab08 --- /dev/null +++ b/arch/zsh/completion.zsh @@ -0,0 +1,75 @@ +# fixme - the load process here seems a bit bizarre +zmodload -i zsh/complist + +WORDCHARS='' + +unsetopt menu_complete # do not autoselect the first completion entry +unsetopt flowcontrol +setopt auto_menu # show completion menu on successive tab press +setopt complete_in_word +setopt always_to_end + +# should this be in keybindings? +bindkey -M menuselect '^o' accept-and-infer-next-history +zstyle ':completion:*:*:*:*:*' menu select + +# case insensitive (all), partial-word and substring completion +if [[ "$CASE_SENSITIVE" = true ]]; then + zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' +else + if [[ "$HYPHEN_INSENSITIVE" = true ]]; then + zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' + else + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' + fi +fi +unset CASE_SENSITIVE HYPHEN_INSENSITIVE + +# Complete . and .. special directories +zstyle ':completion:*' special-dirs true + +zstyle ':completion:*' list-colors '' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' + +if [[ "$OSTYPE" = solaris* ]]; then + zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm" +else + zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w" +fi + +# disable named-directories autocompletion +zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories + +# Use caching so that commands like apt and dpkg complete are useable +zstyle ':completion:*' use-cache yes +zstyle ':completion:*' cache-path $ZSH_CACHE_DIR + +# Don't complete uninteresting users +zstyle ':completion:*:*:*:users' ignored-patterns \ + adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \ + clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \ + gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \ + ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \ + named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ + operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ + rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ + usbmux uucp vcsa wwwrun xfs '_*' + +# ... unless we really want to. +zstyle '*' single-ignored show + +if [[ $COMPLETION_WAITING_DOTS = true ]]; then + expand-or-complete-with-dots() { + print -Pn "%F{red}…%f" + zle expand-or-complete + zle redisplay + } + zle -N expand-or-complete-with-dots + # Set the function as the default tab completion widget + bindkey -M emacs "^I" expand-or-complete-with-dots + bindkey -M viins "^I" expand-or-complete-with-dots + bindkey -M vicmd "^I" expand-or-complete-with-dots +fi + +# automatically load bash completion functions +autoload -U +X bashcompinit && bashcompinit diff --git a/arch/zsh/termsupport.zsh b/arch/zsh/termsupport.zsh new file mode 100644 index 0000000..33451ef --- /dev/null +++ b/arch/zsh/termsupport.zsh @@ -0,0 +1,137 @@ +# 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, iterm, and probably most modern xterm and rxvt +# (In screen, only short_tab_title is used) +# Limited support for Apple Terminal (Terminal can't set window and tab separately) +function title { + emulate -L zsh + setopt prompt_subst + + [[ "$INSIDE_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 + cygwin|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 + ;; + *) + if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then + print -Pn "\e]2;${2:q}\a" # set window name + print -Pn "\e]1;${1:q}\a" # set tab name + else + # 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 + fi + ;; + esac +} + +ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD +ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~" +# Avoid duplication of directory in terminals with independent dir display +if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then + ZSH_THEME_TERM_TITLE_IDLE="%n@%m" +fi + +# Runs before showing the prompt +function omz_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 omz_termsupport_preexec { + [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return + + emulate -L zsh + setopt extended_glob + + # split command into array of arguments + local -a cmdargs + cmdargs=("${(z)2}") + # 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 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* + job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;; + *) # %string argument: + # use $jobtexts to match for a job whose command *starts with* + 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 omz_termsupport_precmd +add-zsh-hook preexec omz_termsupport_preexec + + +# Keep Apple Terminal.app's current working directory updated +# Based on this answer: https://superuser.com/a/315029 +# With extra fixes to handle multibyte chars and non-UTF-8 locales + +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then + # Emits the control sequence to notify Terminal.app of the cwd + # Identifies the directory using a file: URI scheme, including + # the host name to disambiguate local vs. remote paths. + function update_terminalapp_cwd() { + emulate -L zsh + + # Percent-encode the host and path names. + local URL_HOST URL_PATH + URL_HOST="$(omz_urlencode -P $HOST)" || return 1 + URL_PATH="$(omz_urlencode -P $PWD)" || return 1 + + # Undocumented Terminal.app-specific control sequence + printf '\e]7;%s\a' "file://$URL_HOST$URL_PATH" + } + + # Use a precmd hook instead of a chpwd hook to avoid contaminating output + add-zsh-hook precmd update_terminalapp_cwd + # Run once to get initial cwd set + update_terminalapp_cwd +fi diff --git a/arch/zsh/theme-and-appearance.zsh b/arch/zsh/theme-and-appearance.zsh new file mode 100644 index 0000000..01250a8 --- /dev/null +++ b/arch/zsh/theme-and-appearance.zsh @@ -0,0 +1,55 @@ +# ls colors +autoload -U colors && colors + +# Enable ls colors +export LSCOLORS="Gxfxcxdxbxegedabagacad" + +# TODO organise this chaotic logic + +if [[ "$DISABLE_LS_COLORS" != "true" ]]; then + # Find the option for using colors in ls, depending on the version + if [[ "$OSTYPE" == netbsd* ]]; then + # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); + # otherwise, leave ls as is, because NetBSD's ls doesn't support -G + gls --color -d . &>/dev/null && alias ls='gls --color=tty' + elif [[ "$OSTYPE" == openbsd* ]]; then + # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, + # with color and multibyte support) are available from ports. "colorls" + # will be installed on purpose and can't be pulled in by installing + # coreutils, so prefer it to "gls". + gls --color -d . &>/dev/null && alias ls='gls --color=tty' + colorls -G -d . &>/dev/null && alias ls='colorls -G' + elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then + # this is a good alias, it works by default just using $LSCOLORS + ls -G . &>/dev/null && alias ls='ls -G' + + # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file) + # otherwise, gls will use the default color scheme which is ugly af + [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty' + else + # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. + if [[ -z "$LS_COLORS" ]]; then + (( $+commands[dircolors] )) && eval "$(dircolors -b)" + fi + + ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' } + + # Take advantage of $LS_COLORS for completion as well. + zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" + fi +fi + +# enable diff color if possible. +if command diff --color . . &>/dev/null; then + alias diff='diff --color' +fi + +# GTK3 scaling +# These variables used to be set. Not sure why I unset them. They fix text and +# icon sizes on the HiDPI monitor. +export GDK_SCALE=2 +export GDK_DPI_SCALE=0.5 + +setopt auto_cd +setopt multios +setopt prompt_subst diff --git a/m/README.md b/m/README.md new file mode 100644 index 0000000..d4019f4 --- /dev/null +++ b/m/README.md @@ -0,0 +1,21 @@ +- FIXED The both method of installing fzf has left me without the `:Files` func- + tionality. +- FIXED diff-so-fancy +- FIXED What's really not working is nvm. If you install it with bash, zsh can't see + it. +- add source $HOME/.cargo/env - does this persist or must I add it to .zshrc? +- chsh not working? + +- N.B. .bashrc Linux, .bash_profile Mac +- FIXED After the install script runs, the user needs to install the vim plugins by +opening vim and running :PlugInstall - how do you get the pid of the latest +process or a particular process? +- FIXED tmux powerline doesn't work out of the box +- FIXED? nvm - not working right? Time to add the filigree! +- FIXED Maybe we need a post-install script for nvm install lts/dubnium and nvm + use lts/dubnium, and then npm install -g typescript, and then exhort the user + to run vim and ycm. +- FIXED make aptitude install vim et al automatically accept without user input +- FIXED same with rust +- FIXED do existence tests before mv + diff --git a/m/bin/consolidate-path b/m/bin/consolidate-path new file mode 100755 index 0000000..d302afd --- /dev/null +++ b/m/bin/consolidate-path @@ -0,0 +1,13 @@ +#!/bin/bash +# Usage: PATH="$(consolidate-path "$PATH")" +# +# Remove duplicate entries from PATH. + +result=":" +IFS=: +for p in $1; do + [[ "$result" == *:"$p":* ]] || result="${result}${p}:" +done + +result="${result#:}" +echo "${result%:}" diff --git a/m/eg/.eg_custom/README.md b/m/eg/.eg_custom/README.md new file mode 100644 index 0000000..5ad85e8 --- /dev/null +++ b/m/eg/.eg_custom/README.md @@ -0,0 +1,61 @@ +Cheat Sheets +============ + +> **NOTE**: This repo is best used by placing a bookmark in your address bar. + +This is a collection of cheat sheets that I have compiled over the years that I +put together while learning various tools. They contain some good information +and a few gems that I have learned along the way. Feel free to contribute. + +## Contents + +- [Bash] +- [Git] +- [GnuPG] +- [irssi] +- [JIRA] +- [mutt] +- [nmap] +- [openssl] +- [tmux] +- [uml] +- [vim] +- [zsh] +- [other] + +## License + +
Cheat Sheets +by Joshua Estes is +licensed under a Creative Commons +Attribution-ShareAlike 4.0 International License. Based on a work at https://github.com/JoshuaEstes/CheatSheets. +Permissions beyond the scope of this license may be available at https://github.com/JoshuaEstes/CheatSheets/blob/master/LICENSE. + +See [LICENSE] for full license. + + +[Bash]: https://github.com/JoshuaEstes/CheatSheets/blob/master/bash.md +[Git]: https://github.com/JoshuaEstes/CheatSheets/blob/master/git.md +[GnuPG]: https://github.com/JoshuaEstes/CheatSheets/blob/master/gnupg.md +[irssi]: https://github.com/JoshuaEstes/CheatSheets/blob/master/irssi.md +[JIRA]: https://github.com/JoshuaEstes/CheatSheets/blob/master/jira.md +[mutt]: https://github.com/JoshuaEstes/CheatSheets/blob/master/mutt.md +[nmap]: https://github.com/JoshuaEstes/CheatSheets/blob/master/nmap.md +[openssl]: https://github.com/JoshuaEstes/CheatSheets/blob/master/openssl.md +[tmux]: https://github.com/JoshuaEstes/CheatSheets/blob/master/tmux.md +[uml]: https://github.com/JoshuaEstes/CheatSheets/blob/master/uml.md +[vim]: https://github.com/JoshuaEstes/CheatSheets/blob/master/vim.md +[zsh]: https://github.com/JoshuaEstes/CheatSheets/blob/master/zsh.md +[other]: https://github.com/JoshuaEstes/CheatSheets/blob/master/other.md +[LICENSE]: https://github.com/JoshuaEstes/CheatSheets/blob/master/LICENSE diff --git a/m/eg/.eg_custom/ack.md b/m/eg/.eg_custom/ack.md new file mode 100644 index 0000000..e69de29 diff --git a/m/eg/.eg_custom/bash.md b/m/eg/.eg_custom/bash.md new file mode 100644 index 0000000..3144e29 --- /dev/null +++ b/m/eg/.eg_custom/bash.md @@ -0,0 +1,75 @@ +Bash Cheat Sheet +================ + +## Moving + +| command | description | +|----------|--------------------------------| +| ctrl + a | Goto BEGINNING of command line | +| ctrl + e | Goto END of command line | +| ctrl + b | move back one character | +| ctrl + f | move forward one character | +| alt + f | move cursor FORWARD one word | +| alt + b | move cursor BACK one word | + +## Other + +| command | description | +|----------|--------------------------------| +| ctrl + d | Delete the character under the cursor | +| ctrl + l | Clear the screen (same as clear command) | +| ctrl + p | Fetch the previous command from the history list, moving back in the list (same as up arrow) | +| ctrl + n | Fetch the next command from the history list, moving forward in the list (same as down arrow) | +| ctrl + u | Clear all BEFORE cursor | +| ctrl + k | Clear all AFTER cursor | +| ctrl + r | Search backward starting at the current line and moving 'up' through the history as necessary | +| crtl + s | Search forward starting at the current line and moving 'down' through the history as necessary | +| ctrl + c | kill whatever is running | +| ctrl + d | Exit shell (same as exit command) | +| ctrl + w | delete the word BEFORE the cursor | +| ctrl + t | swap the last two characters before the cursor | +| ctrl + y | paste (if you used a previous command to delete) | +| ctrl + z | Place current process in background | +| ctrl + _ | undo | +| esc + t | Swap last two words before the cursor | +| esc + . | | +| esc + _ | | +| alt + [Backspace] | delete PREVIOUS word | +| alt + < | Move to the first line in the history | +| alt + > | Move to the end of the input history, i.e., the line currently being entered | +| alt + ? | | +| alt + * | | +| alt + . | print the LAST ARGUMENT (ie "vim file1.txt file2.txt" will yield "file2.txt") | +| alt + c | | +| alt + d | | +| alt + l | | +| alt + n | | +| alt + p | | +| alt + r | | +| alt + t | | +| alt + u | | +| ~[TAB][TAB] | List all users | +| $[TAB][TAB] | List all system variables | +| @[TAB][TAB] | List all entries in your /etc/hosts file | +| [TAB] | Auto complete | +| !! | Run PREVIOUS command (ie `sudo !!`) | +| !vi | Run PREVIOUS command that BEGINS with vi | +| cd - | change to PREVIOUS working directory | + +# Kill a job + +n = job number, to list jobs, run `jobs` + +```bash +kill %n +``` + +Example: + +```bash +kill %1 +``` + +## References + +1. http://cnswww.cns.cwru.edu/php/chet/readline/readline.html diff --git a/m/eg/.eg_custom/csrutil.md b/m/eg/.eg_custom/csrutil.md new file mode 100644 index 0000000..a81e838 --- /dev/null +++ b/m/eg/.eg_custom/csrutil.md @@ -0,0 +1,8 @@ +Disable/enable System Integrity Protection + +* Restart the computer +* Hold down `Command-R` to reboot into Recovery Mode +* Click `Utilities` +* Select `Terminal` +* Enter `csrutil [ disable | enable ]` +* Restart the computer into Standard Mode \ No newline at end of file diff --git a/m/eg/.eg_custom/curl.md b/m/eg/.eg_custom/curl.md new file mode 100644 index 0000000..cc8ce6c --- /dev/null +++ b/m/eg/.eg_custom/curl.md @@ -0,0 +1,9 @@ +cURL Cheat Sheet +================ + +## Basics +### Get request + +```bash +curl https://domain.com +``` \ No newline at end of file diff --git a/m/eg/.eg_custom/defaults.md b/m/eg/.eg_custom/defaults.md new file mode 100644 index 0000000..e473d80 --- /dev/null +++ b/m/eg/.eg_custom/defaults.md @@ -0,0 +1,5 @@ +# defaults + +Change the default location of screenshots: + + defaults write com.apple.screencapture location && killall SystemUIServer \ No newline at end of file diff --git a/m/eg/.eg_custom/git.md b/m/eg/.eg_custom/git.md new file mode 100644 index 0000000..e7181dd --- /dev/null +++ b/m/eg/.eg_custom/git.md @@ -0,0 +1,152 @@ +Git Cheat Sheet +=============== + +## Subtree Example + +### Add sub-project as remote + +```bash +git remote add -f RemoteName RemoteUrl +``` + +### Run `git subtree` command + +```bash +git subtree add --prefix Path/To/Put/Code NameOfRemote master --squash +``` + +#### Pull subtree as needed + +```bash +git fetch NameOfRemote master +git subtree pull --prefix Path/To/Put/Code NameOfRemote master --squash +``` + +### Reference + +* http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree + +## Create a branch without a parent + +Very useful when you are updating a project that you are rewriting. For example, +say you are using semantic versioning and are wanting to start a new major +version. + +```bash +git checkout --orphan BRANCH +``` + +## Delete All Branches that have been merged + +Great for cleaning up local branches that aren't being used any more. + +```bash +git checkout master +git branch --merged | grep -v "\*" | xargs -n 1 git branch -d +``` + +## Ignore changes to a file that is being tracked + +### Ignore + +```bash +git update-index --assume-unchanged [directory|file] +``` + +### Unignore + +```bash +git update-index --no-assume-unchanged [directory|file] +``` + +## How to ignore dirty submodules + +Edit your ``.git/config`` and add ``ignore = dirty``. + +```text +[submodule "path/to/submodule"] + path = path/to/submodule + url = git://github.com/username/repo.git + ignore = dirty +``` + +## Clone a repo and give name other than origin + +```bash +git clone -o upstream https://repo.git +``` + +## Ignore Files for Repository without using `.gitignore` + +Add the file `.git/info/exclude` and fill it with the contents you want to ignore. This will ONLY apply to the +repository and will not be tracked by git. + +## Squash Commits + +```bash +git log +``` + +Count the number of commits that you have made, let's say the previous 5 are your commits. + +```bash +git rebase -i HEAD~5 +``` + +The first commit leave as `pick` the rest will need to be changed to `squash`. After that you will be able to +leave a new commit message or just leave as is to keep the commit messages from all previous commits. + +## Search for a specific line of code/file in the history + +```bash +git log -S[search term] +``` + +Example: + +```bash +git log -SThatOneFile.php +``` + +## Copy file from one branch to current branch + +Copy a file from `branch` and put into staging. + +```bash +git checkout BRANCH path/to/file.ext + +# Real Life Examples +git checkout origin/featureBranch web/js/random.js +# Pulls into your current branch web/js/random.js from +# origin/featureBranch +``` + +## Git Grepping for fun and profit! + +```shell +# Basic grep (case sensitive) +$ git grep 'search term' + +# Case Insensitive search +$ git grep -i 'search term' + +# Search within a directory +$ git grep 'search term' src/ + +# Search only files with `php` extension +$ git grep 'search term' -- '*.php' + +# Grep in the 'src/` directory, only yml files +$ git grep 'search term' -- 'src/**.yml' +``` + +## Push Branch to Remote Repository to a different branch name + +```shell +git push origin localBranchName:remoteBranchName +``` + +Use Case: I will often use rebase, I will cut a branch off the branch I want to rebase and +do the rebase on the newly created branch. Once I am done, I will check the diff and see if +I screwed up. If it's all good, `git push -f` **NOTICE**: DO NOT `git push -f` unless you know +what you are doing. diff --git a/m/eg/.eg_custom/gnupg.md b/m/eg/.eg_custom/gnupg.md new file mode 100644 index 0000000..0b740ca --- /dev/null +++ b/m/eg/.eg_custom/gnupg.md @@ -0,0 +1,64 @@ +GnuPG Cheat Sheet +================= + +## Listing Key Pairs + +```bash +gpg --list-keys +``` + +For listing keys with the fingerprint, run + +```bash +gpg --fingerprint +``` + +## Generate New Key Pair + +```bash +gpg --gen-key +``` + +## Encrypt a message on command line + +```bash +echo "Put message here" | gpg --armor --encrypt --recipient Joshua > FILE.gpg +``` + +This will put the encrypted text into `FILE.gpg` which you can send to someone or keep for +later use. For decrypting the message, see the next section. + +## Decrypt a message from the command line + +```bash +cat FILE.gpg | gpg +``` + +Displays the decrypted text on the command line. + +## Only display user X's key information + +```bash +gpg --fingerprint Joshua +``` + +## Signing Messages + +```bash +echo "This is a top secret message" | gpg --clearsign +``` + +## Signing Text Files + +```bash +gpg --clearsign example.txt +``` + +This will create `example.txt.asc` file. + +## Verify Signatures + +```bash +gpg --verifiy example.txt.asc +``` + diff --git a/m/eg/.eg_custom/grep.md b/m/eg/.eg_custom/grep.md new file mode 100644 index 0000000..5a603fc --- /dev/null +++ b/m/eg/.eg_custom/grep.md @@ -0,0 +1,8 @@ +Grep +==== + +## Ignore case + +```shell +grep -i pattern +``` diff --git a/m/eg/.eg_custom/irssi.md b/m/eg/.eg_custom/irssi.md new file mode 100644 index 0000000..d59a218 --- /dev/null +++ b/m/eg/.eg_custom/irssi.md @@ -0,0 +1,11 @@ +Irssi Cheat Sheet +================= + +M = Meta Key, meta key is either the left alt or esc key. + +| command | description | +|----------|-------------| +| M + p | Scroll up in window +| M + n | Scroll down in window +| ctrl + p | Previous window +| ctrl + n | Next window diff --git a/m/eg/.eg_custom/jira.md b/m/eg/.eg_custom/jira.md new file mode 100644 index 0000000..2c957f2 --- /dev/null +++ b/m/eg/.eg_custom/jira.md @@ -0,0 +1,8 @@ +Jira Cheat Sheet +================ + +## Find by Mentions of current user within the past 7 days + +```sql +comment ~ currentUser() AND updatedDate >= -7d +``` diff --git a/m/eg/.eg_custom/ln.md b/m/eg/.eg_custom/ln.md new file mode 100644 index 0000000..0abc4aa --- /dev/null +++ b/m/eg/.eg_custom/ln.md @@ -0,0 +1,39 @@ +# ln + +make a symlink to `foo.txt` + + ln -s foo.txt link-to-foo.txt + + + +# Basic Usage + +Make anchor a link to target: + + ln -s + + + +# Symbolic Links (symlinks) + +Make it symbolic with the `-s` flag: + + $ ln -s foo.txt link-to-foo.txt + $ ls -lF + total 8 + -rw-r--r-- 1 tyrion group 0 Feb 3 14:13 foo.txt + lrwxr-xr-x 1 tyrion group 7 Feb 3 14:14 link-to-foo.txt@ -> foo.txt + + + +# Hard Links + +Omit the `-s` flag: + + $ ln foo.txt hard-link-to-foo.txt + $ ls -lF + total 0 + -rw-r--r-- 2 tyrion group 0B Feb 3 14:13 foo.txt + -rw-r--r-- 2 tyrion group 0B Feb 3 14:13 hard-link-to-foo.txt + + diff --git a/m/eg/.eg_custom/lsof.md b/m/eg/.eg_custom/lsof.md new file mode 100644 index 0000000..cc5bd09 --- /dev/null +++ b/m/eg/.eg_custom/lsof.md @@ -0,0 +1,5 @@ +# lsof + +Examine the process using a specified `port`: + + lsof -i:3000 | grep LISTEN diff --git a/m/eg/.eg_custom/mutt.md b/m/eg/.eg_custom/mutt.md new file mode 100644 index 0000000..b27270f --- /dev/null +++ b/m/eg/.eg_custom/mutt.md @@ -0,0 +1,226 @@ +Mutt Cheat Sheet +================ + +## General + +These key bindings will work on almost any menu you are in. + +| command | description | +|------------|-------------| +| * | Move to last entry +| = | Move to first entry +| : | Enter muttrc command +| > | Scroll down one line +| < | Scroll up one line +| [ | Scroll up half a page +| ] | Scroll down half a page +| ? | Help +| ; | Apply next function to tagged messages only +| ! | Invoke command in subshell +| return | Select the current entry +| esc + / | Search up +| / | Search down +| H | Move to top of page +| j | Move to next entry +| k | Move to previous entry +| ctrl + l | Redraw screen +| L | Move to bottom of page +| M | Move to middle of page +| n | Move to next match of search +| q | Exit menu +| t | Tag current entry +| z | Move to next page +| Z | Move to previous page + +## Index Menu + +When you first open mutt you are in the index menu. + +| command | description | +|---------------|-------------| +| & | Link tagged message to current one +| # | Break the thread in two +| % | Toggle whether mailbox will be rewritten +| . | List mailboxes with new mail +| $ | Save changes to mailbox +| @ | Display full address of sender +| | | Pipe message to a shell command +| esc + tab | Jump to previous new or unread message +| return | Display message +| tab | Jump to next new or unread message +| a | Create alias from message sender +| b | Remail message to another user +| esc + c | Open a different folder (Read Only) +| c | Open a different folder +| esc + C | Make text/plain copy +| C | Copy message to another file/mailbox +| esc + d | Delete all messages in subthread +| d | Delete current message +| ctrl + D | Delete all messages in thread +| D | Delete messages matching a pattern +| esc + e | Use the current message as a template for a new one +| e | Edit the raw message +| ctrl + E | Edit attachment content type +| f | Forward message with comments +| ctrl + F | Wipe passphrase from memory +| F | Toggle the important flag for message +| g | Reply to all +| G | Retrive mail from POP server +| h | Display message and toggle header weeding +| j | Move to next undeleted message +| esc + k | Mail a PGP key +| k | Move to previous undeleted message +| ctrl + K | Extract supported public keys +| esc + l | Show current limit pattern +| l | Only show messages matching a pattern +| L | Reply to specific mailing list +| m | Compose new message +| esc + n | Jump to next subthread +| ctrl + N | Jump to next thread +| N | Toggle new flag +| o | Sort messages +| O | Sort messages in reverse order +| Q | Query external program for addresses +| q | Save changes to mailbox and quit +| r | Reply to message +| ctrl + P | Jump to previous thread +| esc + p | Jump to previous subthread +| p | Print current message +| esc + P | Check for classic PGP +| P | Jump to parent message in thread +| ctrl + R | Mark current thread as read +| R | Recall a postponed message +| esc + r | Mark current subthread as read +| esc + s | Save text/plain copy and delete +| s | Save message/attachment to mailbox/file +| esc + t | Tag current thread +| ctrl + T | Untag messages matching a pattern +| T | Tag messages matching pattern +| esc + u | Undelete all messages in subthread +| u | Undelete current entry +| ctrl + U | Undelete all messages in thread +| U | Undelete messages matching pattern +| esc + v | Collapse/uncollapse current thread +| v | Show mime attachments +| esc + V | Collapse/uncollapse all threads +| V | Show mutt version number and date +| w | Set a status flag +| W | Clear status flags from message + +## Pager Menu + +| command | description | +|---------|-------------| +| # | | +| a | | +| b | | +| c | | +| esc + c | | +| C | | +| esc + C | | +| d | | +| ctrl + D | | +| esc + d | | +| w | | +| W | | +| e | | +| ctrl + E | | +| f | | +| F | | +| g | | +| h | | +| j | | +| J | | +| k | | +| K | | +| & | | +| L | | +| ctrl + L | | +| m | | +| n | | +| N | | +| ctrl + N | | +| esc + n | | +| o | | +| O | | +| p | | +| ctrl + P | | +| esc + p | | +| Q | | +| q | | +| r | | +| R | | +| ctrl + R | | +| esc + r | | +| esc + e | | +| s | | +| S | | +| esc + s | | +| t | | +| T | | +| u | | +| esc + u | | +| ctrl + U | | +| v | | +| V | | +| \\ | | +| @ | | +| | | | +| ? | | +| space | | +| - | | +| ^ | | +| $ | | +| ! | | +| : | | +| . | | +| / | | +| esc + / | | +| return | | +| P | | +| esc + P | | +| esc + k | | +| ctrl + K | | +| ctrl + F | | + +## Useful key remaps + +These need to be placed in your `muttrc` file. I use vim and so I want to use some of the +same commands to manage my mail. + +```muttrc +# Does not replace and currently mapped keys and acts like the vim command gg and takes +# you to the top of the page +bind index gg first-entry + +# Replaces the retrieval of mail from a POP server. This will take you to the bottom of +# the page, just like it does in vim +bind index G last-entry +``` + +## Flags + +When viewing messages in the index menu, you will see various flags such as `N` which mean +the messages is new and `D` which means that the message is to be deleted. This is a short +list of those flags. + +| flag | description | +|------|-------------| +| ! | Message is flagged +| * | Message is tagged +| + | Message is To: you and only you +| C | Message is Cc: to you +| d | Message has attachments marked for deletion +| D | Marked for deletion +| F | Message is From: you +| K | Contains PGP key +| L | Message is sent to a subscribed mailing list +| n | Thread contains new messages (Only when thread is collapsed) +| N | Message is new +| o | Thread contains old messages (Only when thread is collapsed) +| O | Message is old +| P | Message is PGP encrypted +| r | Message has been replied to +| s | Message is signed +| S | Message is signed and verified +| T | Message is to you and has others in To: or Cc: diff --git a/m/eg/.eg_custom/nmap.md b/m/eg/.eg_custom/nmap.md new file mode 100644 index 0000000..2035224 --- /dev/null +++ b/m/eg/.eg_custom/nmap.md @@ -0,0 +1,8 @@ +Nmap Cheat Sheet +================ + +## Scan a Port + +```bash +nmap -p 80 google.com +``` diff --git a/m/eg/.eg_custom/openssl.md b/m/eg/.eg_custom/openssl.md new file mode 100644 index 0000000..b363060 --- /dev/null +++ b/m/eg/.eg_custom/openssl.md @@ -0,0 +1,25 @@ +OpenSSL Cheat Sheet +=================== + +## Generate Self-Signed Certificate and Private Key + +```shell +openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && openssl rsa -passin pass:x -in server.pass.key -out server.key && openssl req -new -key server.key -out server.csr +openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt +``` + +- Use `server.crt` and `server.key` + +### Encypt/Decrypt file + +``` +# Encrypt +openssl aes-128-cbc -a -e -pass pass:test -in vars -out vars.enc +# Puts encrypted data into vars.enc file + +# Decrypt +openssl aes-128-cbc -a -d -pass pass:test -in vars.enc +# Outputs decrypted data to STDOUT +``` + +NOTE: See `openssl passpharse arguments` for information on using the password on the commandline. It can be changed to a file or an environment variable. diff --git a/m/eg/.eg_custom/other.md b/m/eg/.eg_custom/other.md new file mode 100644 index 0000000..5ced564 --- /dev/null +++ b/m/eg/.eg_custom/other.md @@ -0,0 +1,28 @@ +Other Cheat Sheets +================== + +## Using `less` instead of tail + +```shell +less +F -R /path/to/logfile.log +``` + +* To scroll up and down, press `+c` +* Return to tail mode, press `F` + +The `+F` says to follow? The `-R` will process any ANSII color codes. + +## SSH Config File + +``` +# ~/.ssh/config +Host test + HostName testing.example.com + Port 22222 + User joshua + IdentityFile ~/.ssh/test.example.com.key +``` + +Next, all you need to do to ssh into the server is `ssh test` and that's it. + +> **NOTE** `HostName` may be an IP Address instead of a domain name diff --git a/m/eg/.eg_custom/pdftk.md b/m/eg/.eg_custom/pdftk.md new file mode 100644 index 0000000..904620d --- /dev/null +++ b/m/eg/.eg_custom/pdftk.md @@ -0,0 +1,10 @@ +# pdftk + +join a bunch of pdfs + + pdftk file01.pdf file02.pdf file03.pdf cat output combined_file.pdf + + +Add a password to a pdf + + pdftk file.pdf output file_pw.pdf user_pw Passw0rd! diff --git a/m/eg/.eg_custom/rename.md b/m/eg/.eg_custom/rename.md new file mode 100644 index 0000000..ab3d9d1 --- /dev/null +++ b/m/eg/.eg_custom/rename.md @@ -0,0 +1,6 @@ +# rename (concept, not command) + +rename `index.jsx` to `index.tsx` one level down + + for i in **/index.jsx; do mv -v $i ${i/jsx/tsx}; done + diff --git a/m/eg/.eg_custom/sed.md b/m/eg/.eg_custom/sed.md new file mode 100644 index 0000000..e69de29 diff --git a/m/eg/.eg_custom/tar.md b/m/eg/.eg_custom/tar.md new file mode 100644 index 0000000..73c3e2a --- /dev/null +++ b/m/eg/.eg_custom/tar.md @@ -0,0 +1,111 @@ +# tar + +extract .tar file + + tar vfx archive.tar + + +unzip and extract .tar.gz or .tgz file + + tar vfxz g_zipped_archive.tar.gz + + +turn directory into a .tar file + + tar vfc tarred_directory.tar directory + + +turn directory into g-zipped directory + + tar vfcz z_zipped_directory.tar.gz directory + + + +# Basic Usage + +`vf` means verbosely list files (`v`) and use a file (`f`), not `stdin`. +These appear in most commands. + +Untar a file: + + tar vfx + + +Create a tar file from a directory: + + tar vfc + + + +# Remembering the Flags + +`tar` is very finicky. Flags don't need to be prepended by a hyphen, but are +instead bundled into the first word on the command line. A leading hyphen will +break some implementations or require an order. For example, `tar vfx` might +work while with a hyphen it would require `tar -xvf`, with the `x` flag first. +You can get maximum portability is you never use the hyphens, so examples here +are shown without the hyphen. + +You'll almost always want `vf`. `v` verbosely lists files as they are +manipulated, and `f` means you're reading from a file, not `stdin`. You can +remember `vf` if you remember that `tar` is Very Finicky: `vf`. + +Extract things from a tar file with `x` for extraction. Compress things to a +tar file with `c` for compress. + +And you'll have to just remember that g-zipping is `z` and b-zipping is `j`. + + + +# Tarring + +Compress directory (`c`) into g-zipped (`z`) directory: + + tar vfcz z_zipped_directory.tar.gz directory + + +Compress directory (`c`) into b-zipped (`j`) directory: + + tar vfcj b_zipped_directory.tar.bz2 directory + + +Compress directory (`c`) into xz-zipped (`J`) directory: + + tar vfcJ xz_zipped_directory.tar.xz directory + + + +# Untarring + +Untar (`x`) and unzip a g-zipped (`z`) file: + + tar vfxz g_zipped_archive.tar.gz + + +Untar (`x`) and unzip a b-zipped (`j`) file: + + tar vfxj b_zipped_archive.tar.bz2 + + +Untar (`x`) and unzip an xz-zipped (`J`) file: + + tar vfxJ xz_zipped_archive.tar.xz + + + +## Partial Untarring + +Extract only part of the contents (`directory/foo.txt`) from a .tar file: + + tar vfx archived_directory.tar directory/foo.txt + + + +# Display Contents + +List (`t`) the contents of a tar file without untarring it: + + $ tar vft tarred_directory.tar + drwxr-xr-x 0 tyrion group 0 Feb 4 14:54 directory/ + -rw-r--r-- 0 tyrion group 0 Feb 4 14:54 directory/bar.txt + -rw-r--r-- 0 tyrion group 0 Feb 4 14:54 directory/foo.txt diff --git a/m/eg/.eg_custom/tmux.md b/m/eg/.eg_custom/tmux.md new file mode 100644 index 0000000..0569971 --- /dev/null +++ b/m/eg/.eg_custom/tmux.md @@ -0,0 +1,92 @@ +Tmux Cheat Sheet +================ + +`ctrl + b` is default to enter before you enter the commands. `M` = Left Alt key +or ESC key + +## Windows + +| command | description | +|---------|-------------| +| c | Create a new window. +| & | Kill the current window. +| n | Change to the next window. +| p | Change to the previous window. +| , | Rename the current window. +| w | Choose the current window interactively. +| M-n | Move to the next window with a bell or activity marker. +| M-p | Move to the previous window with a bell or activity marker. + +## Panes + +| command | description | +|---------|------------ | +| " | Split the current pane into two, top and bottom. +| % | Split the current pane into two, left and right. +| x | Kill the current pane. +| ; | Move to the previously active pane. +| o | Select the next pane in the current window. +| ! | Break the current pane out of the window. +| q | Briefly display pane indexes. + +## Other + +| command | description | +|---------|-------------| +| d | Detach the current client. +| $ | Rename the current session. +| [ | Enter copy mode to copy text or view the history. +| f | Prompt to search for text in open windows. +| r | Force redraw of the attached client. +| L | Switch the attached client back to the last session. +| : | Enter the tmux command prompt +| ? | List all key bindings +| f | Search window titles and goto that window +| i | Briefly display window information +| r | Force redraw of the attached client. +| s | Select a new session for the attached client interactively. +| t | Show the time. +| = | Choose which buffer to paste interactively from a list. +| ] | Paste the most recently copied buffer of text. +| . | Move window + +## Create a new session + +Any of these will work. + +```bash +tmux +tmux new +tmux new-session +``` + +## Reattach to a session + +Any of these commands will work. + +```bash +tmux at +tmux attach +tmux attach-session +``` + +## List sessions + +Any of these commands will work. + +```bash +tmux ls +tmux list-sessions +``` + +## How to copy and paste + +1. Enter copy-mode `C-b [` +2. Move to text, press `Space` to select text, move cursor to highlight text +3. Press `Enter` +4. Back at the command prompt, press `C-b ]` and the text you selected is pasted + +## References + +* http://man.openbsd.org/OpenBSD-current/man1/tmux.1 + diff --git a/m/eg/.eg_custom/uml.md b/m/eg/.eg_custom/uml.md new file mode 100644 index 0000000..d8ab0d3 --- /dev/null +++ b/m/eg/.eg_custom/uml.md @@ -0,0 +1,50 @@ +UML Cheat Sheet +=============== + + +``` +<> +<> +<> + +- private +# protected ++ public + +name : type = default value +``` + +Examples: + +``` +<> +Name\Space\To\ClassAbstract +--- +- $privateAttribute : string = '' +# $protected : integer = 1 ++ $public : string = 'DefaultValue' +--- ++ getPrivateAttribute() : string ++ getValueForKey($key : string) : mixed ++ get($key : string, $default : mixed = null) : mixed +``` + +``` +Class A "uses" Class B +[Class A]- - - ->[Class B] +``` + +``` +Class A "has a" Class B +[Class A]---->[Class B] +``` + +``` +Company "owns" Employee +[Company]⃟----[Employee] +``` + +``` +Ford "is a" Car +[Car]◁----[Ford] +``` diff --git a/m/eg/.eg_custom/vim.md b/m/eg/.eg_custom/vim.md new file mode 100644 index 0000000..ac55b89 --- /dev/null +++ b/m/eg/.eg_custom/vim.md @@ -0,0 +1,5 @@ +# vim + +paste from clipboard into vim + + "*yy OR "+yy (clarify this) diff --git a/m/eg/.eg_custom/youtube-dl.md b/m/eg/.eg_custom/youtube-dl.md new file mode 100644 index 0000000..4a28b2f --- /dev/null +++ b/m/eg/.eg_custom/youtube-dl.md @@ -0,0 +1,5 @@ +# youtube-dl + +Download a video and convert it to MP4 + + youtube-dl -v -o '%(title)s.%(ext)s' --restrict-filenames --recode-video mp4 qXYh8DmBZek diff --git a/m/eg/.eg_custom/zsh.md b/m/eg/.eg_custom/zsh.md new file mode 100644 index 0000000..0a236f8 --- /dev/null +++ b/m/eg/.eg_custom/zsh.md @@ -0,0 +1,4 @@ +Zsh Cheat Sheet +=============== + +Still haven't got around to digging in a reading the man pages for this yet. diff --git a/m/eg/.egrc b/m/eg/.egrc new file mode 100644 index 0000000..ece0afe --- /dev/null +++ b/m/eg/.egrc @@ -0,0 +1,3 @@ +[eg-config] +examples-dir = ~/builds/eg/eg/examples +custom-dir = ~/.eg_custom diff --git a/m/git/.git-completion b/m/git/.git-completion new file mode 100644 index 0000000..482ca84 --- /dev/null +++ b/m/git/.git-completion @@ -0,0 +1,2742 @@ +# bash/zsh completion support for core Git. +# +# Copyright (C) 2006,2007 Shawn O. Pearce +# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). +# Distributed under the GNU General Public License, version 2.0. +# +# The contained completion routines provide support for completing: +# +# *) local and remote branch names +# *) local and remote tag names +# *) .git/remotes file names +# *) git 'subcommands' +# *) tree paths within 'ref:path/to/file' expressions +# *) file paths within current working directory and index +# *) common --long-options +# +# To use these routines: +# +# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). +# 2) Add the following line to your .bashrc/.zshrc: +# source ~/.git-completion.bash +# 3) Consider changing your PS1 to also show the current branch, +# see git-prompt.sh for details. +# +# If you use complex aliases of form '!f() { ... }; f', you can use the null +# command ':' as the first command in the function body to declare the desired +# completion style. For example '!f() { : git commit ; ... }; f' will +# tell the completion to use commit completion. This also works with aliases +# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". + +case "$COMP_WORDBREAKS" in +*:*) : great ;; +*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" +esac + +# __gitdir accepts 0 or 1 arguments (i.e., location) +# returns location of .git repo +__gitdir () +{ + if [ -z "${1-}" ]; then + if [ -n "${__git_dir-}" ]; then + echo "$__git_dir" + elif [ -n "${GIT_DIR-}" ]; then + test -d "${GIT_DIR-}" || return 1 + echo "$GIT_DIR" + elif [ -d .git ]; then + echo .git + else + git rev-parse --git-dir 2>/dev/null + fi + elif [ -d "$1/.git" ]; then + echo "$1/.git" + else + echo "$1" + fi +} + +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald +# © 2009-2010, Bash Completion Maintainers +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function can be used to access a tokenized list of words +# on the command line: +# +# __git_reassemble_comp_words_by_ref '=:' +# if test "${words_[cword_-1]}" = -w +# then +# ... +# fi +# +# The argument should be a collection of characters from the list of +# word completion separators (COMP_WORDBREAKS) to treat as ordinary +# characters. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude those characters. The intent is to +# make option types like --date= and : easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. +# +# Output: words_, cword_, cur_. + +__git_reassemble_comp_words_by_ref() +{ + local exclude i j first + # Which word separators to exclude? + exclude="${1//[^$COMP_WORDBREAKS]}" + cword_=$COMP_CWORD + if [ -z "$exclude" ]; then + words_=("${COMP_WORDS[@]}") + return + fi + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + return + fi + done + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + done +} + +if ! type _get_comp_words_by_ref >/dev/null 2>&1; then +_get_comp_words_by_ref () +{ + local exclude cur_ words_ cword_ + if [ "$1" = "-n" ]; then + exclude=$2 + shift 2 + fi + __git_reassemble_comp_words_by_ref "$exclude" + cur_=${words_[cword_]} + while [ $# -gt 0 ]; do + case "$1" in + cur) + cur=$cur_ + ;; + prev) + prev=${words_[$cword_-1]} + ;; + words) + words=("${words_[@]}") + ;; + cword) + cword=$cword_ + ;; + esac + shift + done +} +fi + +__gitcompappend () +{ + local x i=${#COMPREPLY[@]} + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +__gitcompadd () +{ + COMPREPLY=() + __gitcompappend "$@" +} + +# Generates completion reply, appending a space to possible completion words, +# if necessary. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp () +{ + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + *) + local c i=0 IFS=$' \t\n' + for c in $1; do + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; + esac +} + +# Variation of __gitcomp_nl () that appends to the existing list of +# completion candidates, COMPREPLY. +__gitcomp_nl_append () +{ + local IFS=$'\n' + __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words, separated by a single newline. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word instead of +# the default space (optional). If specified but empty, nothing is +# appended. +__gitcomp_nl () +{ + COMPREPLY=() + __gitcomp_nl_append "$@" +} + +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + __gitcompadd "$1" "${2-}" "${3-$cur}" "" + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ > /dev/null +} + +# Execute 'git ls-files', unless the --committable option is specified, in +# which case it runs 'git diff-index' to find out the files that can be +# committed. It return paths relative to the directory specified in the first +# argument, and using the options specified in the second argument. +__git_ls_files_helper () +{ + if [ "$2" == "--committable" ]; then + git -C "$1" diff-index --name-only --relative HEAD + else + # NOTE: $2 is not quoted in order to support multiple options + git -C "$1" ls-files --exclude-standard $2 + fi 2>/dev/null +} + + +# __git_index_files accepts 1 or 2 arguments: +# 1: Options to pass to ls-files (required). +# 2: A directory path (optional). +# If provided, only files within the specified directory are listed. +# Sub directories are never recursed. Path must have a trailing +# slash. +__git_index_files () +{ + local dir="$(__gitdir)" root="${2-.}" file + + if [ -d "$dir" ]; then + __git_ls_files_helper "$root" "$1" | + while read -r file; do + case "$file" in + ?*/*) echo "${file%%/*}" ;; + *) echo "$file" ;; + esac + done | sort | uniq + fi +} + +__git_heads () +{ + local dir="$(__gitdir)" + if [ -d "$dir" ]; then + git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + refs/heads + return + fi +} + +__git_tags () +{ + local dir="$(__gitdir)" + if [ -d "$dir" ]; then + git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + refs/tags + return + fi +} + +# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments +# presence of 2nd argument means use the guess heuristic employed +# by checkout for tracking branches +__git_refs () +{ + local i hash dir="$(__gitdir "${1-}")" track="${2-}" + local format refs + if [ -d "$dir" ]; then + case "$cur" in + refs|refs/*) + format="refname" + refs="${cur%/*}" + track="" + ;; + *) + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do + if [ -e "$dir/$i" ]; then echo $i; fi + done + format="refname:short" + refs="refs/tags refs/heads refs/remotes" + ;; + esac + git --git-dir="$dir" for-each-ref --format="%($format)" \ + $refs + if [ -n "$track" ]; then + # employ the heuristic used by git checkout + # Try to find a remote branch that matches the completion word + # but only output if the branch name is unique + local ref entry + git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \ + "refs/remotes/" | \ + while read -r entry; do + eval "$entry" + ref="${ref#*/}" + if [[ "$ref" == "$cur"* ]]; then + echo "$ref" + fi + done | sort | uniq -u + fi + return + fi + case "$cur" in + refs|refs/*) + git ls-remote "$dir" "$cur*" 2>/dev/null | \ + while read -r hash i; do + case "$i" in + *^{}) ;; + *) echo "$i" ;; + esac + done + ;; + *) + echo "HEAD" + git for-each-ref --format="%(refname:short)" -- \ + "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##" + ;; + esac +} + +# __git_refs2 requires 1 argument (to pass to __git_refs) +__git_refs2 () +{ + local i + for i in $(__git_refs "$1"); do + echo "$i:$i" + done +} + +# __git_refs_remotes requires 1 argument (to pass to ls-remote) +__git_refs_remotes () +{ + local i hash + git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \ + while read -r hash i; do + echo "$i:refs/remotes/$1/${i#refs/heads/}" + done +} + +__git_remotes () +{ + local d="$(__gitdir)" + test -d "$d/remotes" && ls -1 "$d/remotes" + git --git-dir="$d" remote +} + +__git_list_merge_strategies () +{ + git merge -s help 2>&1 | + sed -n -e '/[Aa]vailable strategies are: /,/^$/{ + s/\.$// + s/.*:// + s/^[ ]*// + s/[ ]*$// + p + }' +} + +__git_merge_strategies= +# 'git merge -s help' (and thus detection of the merge strategy +# list) fails, unfortunately, if run outside of any git working +# tree. __git_merge_strategies is set to the empty string in +# that case, and the detection will be repeated the next time it +# is needed. +__git_compute_merge_strategies () +{ + test -n "$__git_merge_strategies" || + __git_merge_strategies=$(__git_list_merge_strategies) +} + +__git_complete_revlist_file () +{ + local pfx ls ref cur_="$cur" + case "$cur_" in + *..?*:*) + return + ;; + ?*:*) + ref="${cur_%%:*}" + cur_="${cur_#*:}" + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + ls="$ref:$pfx" + pfx="$pfx/" + ;; + *) + ls="$ref" + ;; + esac + + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="$ref:$pfx" ;; + esac + + __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \ + | sed '/^100... blob /{ + s,^.* ,, + s,$, , + } + /^120000 blob /{ + s,^.* ,, + s,$, , + } + /^040000 tree /{ + s,^.* ,, + s,$,/, + } + s/^.* //')" \ + "$pfx" "$cur_" "" + ;; + *...*) + pfx="${cur_%...*}..." + cur_="${cur_#*...}" + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + ;; + *..*) + pfx="${cur_%..*}.." + cur_="${cur_#*..}" + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac +} + + +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local pfx="" cur_="$cur" + + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + pfx="${pfx}/" + ;; + esac + + __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" +} + +__git_complete_file () +{ + __git_complete_revlist_file +} + +__git_complete_revlist () +{ + __git_complete_revlist_file +} + +__git_complete_remote_or_refspec () +{ + local cur_="$cur" cmd="${words[1]}" + local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 + if [ "$cmd" = "remote" ]; then + ((c++)) + fi + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; + --all) + case "$cmd" in + push) no_complete_refspec=1 ;; + fetch) + return + ;; + *) ;; + esac + ;; + -*) ;; + *) remote="$i"; break ;; + esac + ((c++)) + done + if [ -z "$remote" ]; then + __gitcomp_nl "$(__git_remotes)" + return + fi + if [ $no_complete_refspec = 1 ]; then + return + fi + [ "$remote" = "." ] && remote= + case "$cur_" in + *:*) + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="${cur_%%:*}:" ;; + esac + cur_="${cur_#*:}" + lhs=0 + ;; + +*) + pfx="+" + cur_="${cur_#+}" + ;; + esac + case "$cmd" in + fetch) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + fi + ;; + pull|remote) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + fi + ;; + push) + if [ $lhs = 1 ]; then + __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" + else + __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" + fi + ;; + esac +} + +__git_complete_strategy () +{ + __git_compute_merge_strategies + case "$prev" in + -s|--strategy) + __gitcomp "$__git_merge_strategies" + return 0 + esac + case "$cur" in + --strategy=*) + __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" + return 0 + ;; + esac + return 1 +} + +__git_commands () { + if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}" + then + printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}" + else + git help -a|egrep '^ [a-zA-Z0-9]' + fi +} + +__git_list_all_commands () +{ + local i IFS=" "$'\n' + for i in $(__git_commands) + do + case $i in + *--*) : helper pattern;; + *) echo $i;; + esac + done +} + +__git_all_commands= +__git_compute_all_commands () +{ + test -n "$__git_all_commands" || + __git_all_commands=$(__git_list_all_commands) +} + +__git_list_porcelain_commands () +{ + local i IFS=" "$'\n' + __git_compute_all_commands + for i in $__git_all_commands + do + case $i in + *--*) : helper pattern;; + applymbox) : ask gittus;; + applypatch) : ask gittus;; + archimport) : import;; + cat-file) : plumbing;; + check-attr) : plumbing;; + check-ignore) : plumbing;; + check-mailmap) : plumbing;; + check-ref-format) : plumbing;; + checkout-index) : plumbing;; + commit-tree) : plumbing;; + count-objects) : infrequent;; + credential) : credentials;; + credential-*) : credentials helper;; + cvsexportcommit) : export;; + cvsimport) : import;; + cvsserver) : daemon;; + daemon) : daemon;; + diff-files) : plumbing;; + diff-index) : plumbing;; + diff-tree) : plumbing;; + fast-import) : import;; + fast-export) : export;; + fsck-objects) : plumbing;; + fetch-pack) : plumbing;; + fmt-merge-msg) : plumbing;; + for-each-ref) : plumbing;; + hash-object) : plumbing;; + http-*) : transport;; + index-pack) : plumbing;; + init-db) : deprecated;; + local-fetch) : plumbing;; + ls-files) : plumbing;; + ls-remote) : plumbing;; + ls-tree) : plumbing;; + mailinfo) : plumbing;; + mailsplit) : plumbing;; + merge-*) : plumbing;; + mktree) : plumbing;; + mktag) : plumbing;; + pack-objects) : plumbing;; + pack-redundant) : plumbing;; + pack-refs) : plumbing;; + parse-remote) : plumbing;; + patch-id) : plumbing;; + prune) : plumbing;; + prune-packed) : plumbing;; + quiltimport) : import;; + read-tree) : plumbing;; + receive-pack) : plumbing;; + remote-*) : transport;; + rerere) : plumbing;; + rev-list) : plumbing;; + rev-parse) : plumbing;; + runstatus) : plumbing;; + sh-setup) : internal;; + shell) : daemon;; + show-ref) : plumbing;; + send-pack) : plumbing;; + show-index) : plumbing;; + ssh-*) : transport;; + stripspace) : plumbing;; + symbolic-ref) : plumbing;; + unpack-file) : plumbing;; + unpack-objects) : plumbing;; + update-index) : plumbing;; + update-ref) : plumbing;; + update-server-info) : daemon;; + upload-archive) : plumbing;; + upload-pack) : plumbing;; + write-tree) : plumbing;; + var) : infrequent;; + verify-pack) : infrequent;; + verify-tag) : plumbing;; + *) echo $i;; + esac + done +} + +__git_porcelain_commands= +__git_compute_porcelain_commands () +{ + test -n "$__git_porcelain_commands" || + __git_porcelain_commands=$(__git_list_porcelain_commands) +} + +# Lists all set config variables starting with the given section prefix, +# with the prefix removed. +__git_get_config_variables () +{ + local section="$1" i IFS=$'\n' + for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do + echo "${i#$section.}" + done +} + +__git_pretty_aliases () +{ + __git_get_config_variables "pretty" +} + +__git_aliases () +{ + __git_get_config_variables "alias" +} + +# __git_aliased_command requires 1 argument +__git_aliased_command () +{ + local word cmdline=$(git --git-dir="$(__gitdir)" \ + config --get "alias.$1") + for word in $cmdline; do + case "$word" in + \!gitk|gitk) + echo "gitk" + return + ;; + \!*) : shell command alias ;; + -*) : option ;; + *=*) : setting env ;; + git) : git itself ;; + \(\)) : skip parens of shell function definition ;; + {) : skip start of shell helper function ;; + :) : skip null command ;; + \'*) : skip opening quote after sh -c ;; + *) + echo "$word" + return + esac + done +} + +# __git_find_on_cmdline requires 1 argument +__git_find_on_cmdline () +{ + local word subcommand c=1 + while [ $c -lt $cword ]; do + word="${words[c]}" + for subcommand in $1; do + if [ "$subcommand" = "$word" ]; then + echo "$subcommand" + return + fi + done + ((c++)) + done +} + +__git_has_doubledash () +{ + local c=1 + while [ $c -lt $cword ]; do + if [ "--" = "${words[c]}" ]; then + return 0 + fi + ((c++)) + done + return 1 +} + +# Try to count non option arguments passed on the command line for the +# specified git command. +# When options are used, it is necessary to use the special -- option to +# tell the implementation were non option arguments begin. +# XXX this can not be improved, since options can appear everywhere, as +# an example: +# git mv x -n y +# +# __git_count_arguments requires 1 argument: the git command executed. +__git_count_arguments () +{ + local word i c=0 + + # Skip "git" (first argument) + for ((i=1; i < ${#words[@]}; i++)); do + word="${words[i]}" + + case "$word" in + --) + # Good; we can assume that the following are only non + # option arguments. + ((c = 0)) + ;; + "$1") + # Skip the specified git command and discard git + # main options + ((c = 0)) + ;; + ?*) + ((c++)) + ;; + esac + done + + printf "%d" $c +} + +__git_whitespacelist="nowarn warn error error-all fix" + +_git_am () +{ + local dir="$(__gitdir)" + if [ -d "$dir"/rebase-apply ]; then + __gitcomp "--skip --continue --resolved --abort" + return + fi + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --3way --committer-date-is-author-date --ignore-date + --ignore-whitespace --ignore-space-change + --interactive --keep --no-utf8 --signoff --utf8 + --whitespace= --scissors + " + return + esac +} + +_git_apply () +{ + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --stat --numstat --summary --check --index + --cached --index-info --reverse --reject --unidiff-zero + --apply --no-add --exclude= + --ignore-whitespace --ignore-space-change + --whitespace= --inaccurate-eof --verbose + " + return + esac +} + +_git_add () +{ + case "$cur" in + --*) + __gitcomp " + --interactive --refresh --patch --update --dry-run + --ignore-errors --intent-to-add + " + return + esac + + # XXX should we check for --update and --all options ? + __git_complete_index_file "--others --modified --directory --no-empty-directory" +} + +_git_archive () +{ + case "$cur" in + --format=*) + __gitcomp "$(git archive --list)" "" "${cur##--format=}" + return + ;; + --remote=*) + __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}" + return + ;; + --*) + __gitcomp " + --format= --list --verbose + --prefix= --remote= --exec= + " + return + ;; + esac + __git_complete_file +} + +_git_bisect () +{ + __git_has_doubledash && return + + local subcommands="start bad good skip reset visualize replay log run" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + if [ -f "$(__gitdir)"/BISECT_START ]; then + __gitcomp "$subcommands" + else + __gitcomp "replay start" + fi + return + fi + + case "$subcommand" in + bad|good|reset|skip|start) + __gitcomp_nl "$(__git_refs)" + ;; + *) + ;; + esac +} + +_git_branch () +{ + local i c=1 only_local_ref="n" has_r="n" + + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -d|-m) only_local_ref="y" ;; + -r) has_r="y" ;; + esac + ((c++)) + done + + case "$cur" in + --set-upstream-to=*) + __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}" + ;; + --*) + __gitcomp " + --color --no-color --verbose --abbrev= --no-abbrev + --track --no-track --contains --merged --no-merged + --set-upstream-to= --edit-description --list + --unset-upstream + " + ;; + *) + if [ $only_local_ref = "y" -a $has_r = "n" ]; then + __gitcomp_nl "$(__git_heads)" + else + __gitcomp_nl "$(__git_refs)" + fi + ;; + esac +} + +_git_bundle () +{ + local cmd="${words[2]}" + case "$cword" in + 2) + __gitcomp "create list-heads verify unbundle" + ;; + 3) + # looking for a file + ;; + *) + case "$cmd" in + create) + __git_complete_revlist + ;; + esac + ;; + esac +} + +_git_checkout () +{ + __git_has_doubledash && return + + case "$cur" in + --conflict=*) + __gitcomp "diff3 merge" "" "${cur##--conflict=}" + ;; + --*) + __gitcomp " + --quiet --ours --theirs --track --no-track --merge + --conflict= --orphan --patch + " + ;; + *) + # check if --track, --no-track, or --no-guess was specified + # if so, disable DWIM mode + local flags="--track --no-track --no-guess" track=1 + if [ -n "$(__git_find_on_cmdline "$flags")" ]; then + track='' + fi + __gitcomp_nl "$(__git_refs '' $track)" + ;; + esac +} + +_git_cherry () +{ + __gitcomp_nl "$(__git_refs)" +} + +_git_cherry_pick () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/CHERRY_PICK_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi + case "$cur" in + --*) + __gitcomp "--edit --no-commit --signoff --strategy= --mainline" + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac +} + +_git_clean () +{ + case "$cur" in + --*) + __gitcomp "--dry-run --quiet" + return + ;; + esac + + # XXX should we check for -x option ? + __git_complete_index_file "--others --directory" +} + +_git_clone () +{ + case "$cur" in + --*) + __gitcomp " + --local + --no-hardlinks + --shared + --reference + --quiet + --no-checkout + --bare + --mirror + --origin + --upload-pack + --template= + --depth + --single-branch + --branch + " + return + ;; + esac +} + +_git_commit () +{ + case "$prev" in + -c|-C) + __gitcomp_nl "$(__git_refs)" "" "${cur}" + return + ;; + esac + + case "$cur" in + --cleanup=*) + __gitcomp "default scissors strip verbatim whitespace + " "" "${cur##--cleanup=}" + return + ;; + --reuse-message=*|--reedit-message=*|\ + --fixup=*|--squash=*) + __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" + return + ;; + --untracked-files=*) + __gitcomp "all no normal" "" "${cur##--untracked-files=}" + return + ;; + --*) + __gitcomp " + --all --author= --signoff --verify --no-verify + --edit --no-edit + --amend --include --only --interactive + --dry-run --reuse-message= --reedit-message= + --reset-author --file= --message= --template= + --cleanup= --untracked-files --untracked-files= + --verbose --quiet --fixup= --squash= + " + return + esac + + if git rev-parse --verify --quiet HEAD >/dev/null; then + __git_complete_index_file "--committable" + else + # This is the first commit + __git_complete_index_file "--cached" + fi +} + +_git_describe () +{ + case "$cur" in + --*) + __gitcomp " + --all --tags --contains --abbrev= --candidates= + --exact-match --debug --long --match --always + " + return + esac + __gitcomp_nl "$(__git_refs)" +} + +__git_diff_algorithms="myers minimal patience histogram" + +__git_diff_common_options="--stat --numstat --shortstat --summary + --patch-with-stat --name-only --name-status --color + --no-color --color-words --no-renames --check + --full-index --binary --abbrev --diff-filter= + --find-copies-harder + --text --ignore-space-at-eol --ignore-space-change + --ignore-all-space --ignore-blank-lines --exit-code + --quiet --ext-diff --no-ext-diff + --no-prefix --src-prefix= --dst-prefix= + --inter-hunk-context= + --patience --histogram --minimal + --raw --word-diff + --dirstat --dirstat= --dirstat-by-file + --dirstat-by-file= --cumulative + --diff-algorithm= +" + +_git_diff () +{ + __git_has_doubledash && return + + case "$cur" in + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --*) + __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs --no-index + $__git_diff_common_options + " + return + ;; + esac + __git_complete_revlist_file +} + +__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff + tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare +" + +_git_difftool () +{ + __git_has_doubledash && return + + case "$cur" in + --tool=*) + __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}" + return + ;; + --*) + __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs + --no-renames --diff-filter= --find-copies-harder + --relative --ignore-submodules + --tool=" + return + ;; + esac + __git_complete_revlist_file +} + +__git_fetch_recurse_submodules="yes on-demand no" + +__git_fetch_options=" + --quiet --verbose --append --upload-pack --force --keep --depth= + --tags --no-tags --all --prune --dry-run --recurse-submodules= +" + +_git_fetch () +{ + case "$cur" in + --recurse-submodules=*) + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --*) + __gitcomp "$__git_fetch_options" + return + ;; + esac + __git_complete_remote_or_refspec +} + +__git_format_patch_options=" + --stdout --attach --no-attach --thread --thread= --no-thread + --numbered --start-number --numbered-files --keep-subject --signoff + --signature --no-signature --in-reply-to= --cc= --full-index --binary + --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= + --inline --suffix= --ignore-if-in-upstream --subject-prefix= + --output-directory --reroll-count --to= --quiet --notes +" + +_git_format_patch () +{ + case "$cur" in + --thread=*) + __gitcomp " + deep shallow + " "" "${cur##--thread=}" + return + ;; + --*) + __gitcomp "$__git_format_patch_options" + return + ;; + esac + __git_complete_revlist +} + +_git_fsck () +{ + case "$cur" in + --*) + __gitcomp " + --tags --root --unreachable --cache --no-reflogs --full + --strict --verbose --lost-found + " + return + ;; + esac +} + +_git_gc () +{ + case "$cur" in + --*) + __gitcomp "--prune --aggressive" + return + ;; + esac +} + +_git_gitk () +{ + _gitk +} + +__git_match_ctag() { + awk "/^${1//\//\\/}/ { print \$1 }" "$2" +} + +_git_grep () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp " + --cached + --text --ignore-case --word-regexp --invert-match + --full-name --line-number + --extended-regexp --basic-regexp --fixed-strings + --perl-regexp + --files-with-matches --name-only + --files-without-match + --max-depth + --count + --and --or --not --all-match + " + return + ;; + esac + + case "$cword,$prev" in + 2,*|*,-*) + if test -r tags; then + __gitcomp_nl "$(__git_match_ctag "$cur" tags)" + return + fi + ;; + esac + + __gitcomp_nl "$(__git_refs)" +} + +_git_help () +{ + case "$cur" in + --*) + __gitcomp "--all --info --man --web" + return + ;; + esac + __git_compute_all_commands + __gitcomp "$__git_all_commands $(__git_aliases) + attributes cli core-tutorial cvs-migration + diffcore gitk glossary hooks ignore modules + namespaces repository-layout tutorial tutorial-2 + workflows + " +} + +_git_init () +{ + case "$cur" in + --shared=*) + __gitcomp " + false true umask group all world everybody + " "" "${cur##--shared=}" + return + ;; + --*) + __gitcomp "--quiet --bare --template= --shared --shared=" + return + ;; + esac +} + +_git_ls_files () +{ + case "$cur" in + --*) + __gitcomp "--cached --deleted --modified --others --ignored + --stage --directory --no-empty-directory --unmerged + --killed --exclude= --exclude-from= + --exclude-per-directory= --exclude-standard + --error-unmatch --with-tree= --full-name + --abbrev --ignored --exclude-per-directory + " + return + ;; + esac + + # XXX ignore options like --modified and always suggest all cached + # files. + __git_complete_index_file "--cached" +} + +_git_ls_remote () +{ + __gitcomp_nl "$(__git_remotes)" +} + +_git_ls_tree () +{ + __git_complete_file +} + +# Options that go well for log, shortlog and gitk +__git_log_common_options=" + --not --all + --branches --tags --remotes + --first-parent --merges --no-merges + --max-count= + --max-age= --since= --after= + --min-age= --until= --before= + --min-parents= --max-parents= + --no-min-parents --no-max-parents +" +# Options that go well for log and gitk (not shortlog) +__git_log_gitk_options=" + --dense --sparse --full-history + --simplify-merges --simplify-by-decoration + --left-right --notes --no-notes +" +# Options that go well for log and shortlog (not gitk) +__git_log_shortlog_options=" + --author= --committer= --grep= + --all-match --invert-grep +" + +__git_log_pretty_formats="oneline short medium full fuller email raw format:" +__git_log_date_formats="relative iso8601 rfc2822 short local default raw" + +_git_log () +{ + __git_has_doubledash && return + + local g="$(git rev-parse --git-dir 2>/dev/null)" + local merge="" + if [ -f "$g/MERGE_HEAD" ]; then + merge="--merge" + fi + case "$cur" in + --pretty=*|--format=*) + __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) + " "" "${cur#*=}" + return + ;; + --date=*) + __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" + return + ;; + --decorate=*) + __gitcomp "full short no" "" "${cur##--decorate=}" + return + ;; + --*) + __gitcomp " + $__git_log_common_options + $__git_log_shortlog_options + $__git_log_gitk_options + --root --topo-order --date-order --reverse + --follow --full-diff + --abbrev-commit --abbrev= + --relative-date --date= + --pretty= --format= --oneline + --show-signature + --cherry-pick + --graph + --decorate --decorate= + --walk-reflogs + --parents --children + $merge + $__git_diff_common_options + --pickaxe-all --pickaxe-regex + " + return + ;; + esac + __git_complete_revlist +} + +# Common merge options shared by git-merge(1) and git-pull(1). +__git_merge_options=" + --no-commit --no-stat --log --no-log --squash --strategy + --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit + --verify-signatures --no-verify-signatures --gpg-sign + --quiet --verbose --progress --no-progress +" + +_git_merge () +{ + __git_complete_strategy && return + + case "$cur" in + --*) + __gitcomp "$__git_merge_options + --rerere-autoupdate --no-rerere-autoupdate --abort" + return + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_mergetool () +{ + case "$cur" in + --tool=*) + __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}" + return + ;; + --*) + __gitcomp "--tool=" + return + ;; + esac +} + +_git_merge_base () +{ + case "$cur" in + --*) + __gitcomp "--octopus --independent --is-ancestor --fork-point" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_mv () +{ + case "$cur" in + --*) + __gitcomp "--dry-run" + return + ;; + esac + + if [ $(__git_count_arguments "mv") -gt 0 ]; then + # We need to show both cached and untracked files (including + # empty directories) since this may not be the last argument. + __git_complete_index_file "--cached --others --directory" + else + __git_complete_index_file "--cached" + fi +} + +_git_name_rev () +{ + __gitcomp "--tags --all --stdin" +} + +_git_notes () +{ + local subcommands='add append copy edit list prune remove show' + local subcommand="$(__git_find_on_cmdline "$subcommands")" + + case "$subcommand,$cur" in + ,--*) + __gitcomp '--ref' + ;; + ,*) + case "$prev" in + --ref) + __gitcomp_nl "$(__git_refs)" + ;; + *) + __gitcomp "$subcommands --ref" + ;; + esac + ;; + add,--reuse-message=*|append,--reuse-message=*|\ + add,--reedit-message=*|append,--reedit-message=*) + __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" + ;; + add,--*|append,--*) + __gitcomp '--file= --message= --reedit-message= + --reuse-message=' + ;; + copy,--*) + __gitcomp '--stdin' + ;; + prune,--*) + __gitcomp '--dry-run --verbose' + ;; + prune,*) + ;; + *) + case "$prev" in + -m|-F) + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac + ;; + esac +} + +_git_pull () +{ + __git_complete_strategy && return + + case "$cur" in + --recurse-submodules=*) + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --*) + __gitcomp " + --rebase --no-rebase + $__git_merge_options + $__git_fetch_options + " + return + ;; + esac + __git_complete_remote_or_refspec +} + +__git_push_recurse_submodules="check on-demand" + +__git_complete_force_with_lease () +{ + local cur_=$1 + + case "$cur_" in + --*=) + ;; + *:*) + __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" + ;; + *) + __gitcomp_nl "$(__git_refs)" "" "$cur_" + ;; + esac +} + +_git_push () +{ + case "$prev" in + --repo) + __gitcomp_nl "$(__git_remotes)" + return + ;; + --recurse-submodules) + __gitcomp "$__git_push_recurse_submodules" + return + ;; + esac + case "$cur" in + --repo=*) + __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}" + return + ;; + --recurse-submodules=*) + __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}" + return + ;; + --force-with-lease=*) + __git_complete_force_with_lease "${cur##--force-with-lease=}" + return + ;; + --*) + __gitcomp " + --all --mirror --tags --dry-run --force --verbose + --quiet --prune --delete --follow-tags + --receive-pack= --repo= --set-upstream + --force-with-lease --force-with-lease= --recurse-submodules= + " + return + ;; + esac + __git_complete_remote_or_refspec +} + +_git_rebase () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/rebase-merge/interactive ]; then + __gitcomp "--continue --skip --abort --edit-todo" + return + elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then + __gitcomp "--continue --skip --abort" + return + fi + __git_complete_strategy && return + case "$cur" in + --whitespace=*) + __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" + return + ;; + --*) + __gitcomp " + --onto --merge --strategy --interactive + --preserve-merges --stat --no-stat + --committer-date-is-author-date --ignore-date + --ignore-whitespace --whitespace= + --autosquash --fork-point --no-fork-point + --autostash + " + + return + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_reflog () +{ + local subcommands="show delete expire" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + else + __gitcomp_nl "$(__git_refs)" + fi +} + +__git_send_email_confirm_options="always never auto cc compose" +__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" + +_git_send_email () +{ + case "$cur" in + --confirm=*) + __gitcomp " + $__git_send_email_confirm_options + " "" "${cur##--confirm=}" + return + ;; + --suppress-cc=*) + __gitcomp " + $__git_send_email_suppresscc_options + " "" "${cur##--suppress-cc=}" + + return + ;; + --smtp-encryption=*) + __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}" + return + ;; + --thread=*) + __gitcomp " + deep shallow + " "" "${cur##--thread=}" + return + ;; + --*) + __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to + --compose --confirm= --dry-run --envelope-sender + --from --identity + --in-reply-to --no-chain-reply-to --no-signed-off-by-cc + --no-suppress-from --no-thread --quiet + --signed-off-by-cc --smtp-pass --smtp-server + --smtp-server-port --smtp-encryption= --smtp-user + --subject --suppress-cc= --suppress-from --thread --to + --validate --no-validate + $__git_format_patch_options" + return + ;; + esac + __git_complete_revlist +} + +_git_stage () +{ + _git_add +} + +__git_config_get_set_variables () +{ + local prevword word config_file= c=$cword + while [ $c -gt 1 ]; do + word="${words[c]}" + case "$word" in + --system|--global|--local|--file=*) + config_file="$word" + break + ;; + -f|--file) + config_file="$word $prevword" + break + ;; + esac + prevword=$word + c=$((--c)) + done + + git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null +} + +_git_config () +{ + case "$prev" in + branch.*.remote|branch.*.pushremote) + __gitcomp_nl "$(__git_remotes)" + return + ;; + branch.*.merge) + __gitcomp_nl "$(__git_refs)" + return + ;; + branch.*.rebase) + __gitcomp "false true" + return + ;; + remote.pushdefault) + __gitcomp_nl "$(__git_remotes)" + return + ;; + remote.*.fetch) + local remote="${prev#remote.}" + remote="${remote%.fetch}" + if [ -z "$cur" ]; then + __gitcomp_nl "refs/heads/" "" "" "" + return + fi + __gitcomp_nl "$(__git_refs_remotes "$remote")" + return + ;; + remote.*.push) + local remote="${prev#remote.}" + remote="${remote%.push}" + __gitcomp_nl "$(git --git-dir="$(__gitdir)" \ + for-each-ref --format='%(refname):%(refname)' \ + refs/heads)" + return + ;; + pull.twohead|pull.octopus) + __git_compute_merge_strategies + __gitcomp "$__git_merge_strategies" + return + ;; + color.branch|color.diff|color.interactive|\ + color.showbranch|color.status|color.ui) + __gitcomp "always never auto" + return + ;; + color.pager) + __gitcomp "false true" + return + ;; + color.*.*) + __gitcomp " + normal black red green yellow blue magenta cyan white + bold dim ul blink reverse + " + return + ;; + diff.submodule) + __gitcomp "log short" + return + ;; + help.format) + __gitcomp "man info web html" + return + ;; + log.date) + __gitcomp "$__git_log_date_formats" + return + ;; + sendemail.aliasesfiletype) + __gitcomp "mutt mailrc pine elm gnus" + return + ;; + sendemail.confirm) + __gitcomp "$__git_send_email_confirm_options" + return + ;; + sendemail.suppresscc) + __gitcomp "$__git_send_email_suppresscc_options" + return + ;; + sendemail.transferencoding) + __gitcomp "7bit 8bit quoted-printable base64" + return + ;; + --get|--get-all|--unset|--unset-all) + __gitcomp_nl "$(__git_config_get_set_variables)" + return + ;; + *.*) + return + ;; + esac + case "$cur" in + --*) + __gitcomp " + --system --global --local --file= + --list --replace-all + --get --get-all --get-regexp + --add --unset --unset-all + --remove-section --rename-section + --name-only + " + return + ;; + branch.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" + return + ;; + branch.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "." + __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_" + return + ;; + guitool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp " + argprompt cmd confirm needsfile noconsole norescan + prompt revprompt revunmerged title + " "$pfx" "$cur_" + return + ;; + difftool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path" "$pfx" "$cur_" + return + ;; + man.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path" "$pfx" "$cur_" + return + ;; + mergetool.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" + return + ;; + pager.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __git_compute_all_commands + __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" + return + ;; + remote.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp " + url proxy fetch push mirror skipDefaultUpdate + receivepack uploadpack tagopt pushurl + " "$pfx" "$cur_" + return + ;; + remote.*) + local pfx="${cur%.*}." cur_="${cur#*.}" + __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." + __gitcomp_nl_append "pushdefault" "$pfx" "$cur_" + return + ;; + url.*.*) + local pfx="${cur%.*}." cur_="${cur##*.}" + __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" + return + ;; + esac + __gitcomp " + add.ignoreErrors + advice.commitBeforeMerge + advice.detachedHead + advice.implicitIdentity + advice.pushNonFastForward + advice.resolveConflict + advice.statusHints + alias. + am.keepcr + apply.ignorewhitespace + apply.whitespace + branch.autosetupmerge + branch.autosetuprebase + browser. + clean.requireForce + color.branch + color.branch.current + color.branch.local + color.branch.plain + color.branch.remote + color.decorate.HEAD + color.decorate.branch + color.decorate.remoteBranch + color.decorate.stash + color.decorate.tag + color.diff + color.diff.commit + color.diff.frag + color.diff.func + color.diff.meta + color.diff.new + color.diff.old + color.diff.plain + color.diff.whitespace + color.grep + color.grep.context + color.grep.filename + color.grep.function + color.grep.linenumber + color.grep.match + color.grep.selected + color.grep.separator + color.interactive + color.interactive.error + color.interactive.header + color.interactive.help + color.interactive.prompt + color.pager + color.showbranch + color.status + color.status.added + color.status.changed + color.status.header + color.status.nobranch + color.status.unmerged + color.status.untracked + color.status.updated + color.ui + commit.status + commit.template + core.abbrev + core.askpass + core.attributesfile + core.autocrlf + core.bare + core.bigFileThreshold + core.compression + core.createObject + core.deltaBaseCacheLimit + core.editor + core.eol + core.excludesfile + core.fileMode + core.fsyncobjectfiles + core.gitProxy + core.ignoreStat + core.ignorecase + core.logAllRefUpdates + core.loosecompression + core.notesRef + core.packedGitLimit + core.packedGitWindowSize + core.pager + core.preferSymlinkRefs + core.preloadindex + core.quotepath + core.repositoryFormatVersion + core.safecrlf + core.sharedRepository + core.sparseCheckout + core.symlinks + core.trustctime + core.warnAmbiguousRefs + core.whitespace + core.worktree + diff.autorefreshindex + diff.external + diff.ignoreSubmodules + diff.mnemonicprefix + diff.noprefix + diff.renameLimit + diff.renames + diff.statGraphWidth + diff.submodule + diff.suppressBlankEmpty + diff.tool + diff.wordRegex + diff.algorithm + difftool. + difftool.prompt + fetch.recurseSubmodules + fetch.unpackLimit + format.attach + format.cc + format.coverLetter + format.headers + format.numbered + format.pretty + format.signature + format.signoff + format.subjectprefix + format.suffix + format.thread + format.to + gc. + gc.aggressiveWindow + gc.auto + gc.autopacklimit + gc.packrefs + gc.pruneexpire + gc.reflogexpire + gc.reflogexpireunreachable + gc.rerereresolved + gc.rerereunresolved + gitcvs.allbinary + gitcvs.commitmsgannotation + gitcvs.dbTableNamePrefix + gitcvs.dbdriver + gitcvs.dbname + gitcvs.dbpass + gitcvs.dbuser + gitcvs.enabled + gitcvs.logfile + gitcvs.usecrlfattr + guitool. + gui.blamehistoryctx + gui.commitmsgwidth + gui.copyblamethreshold + gui.diffcontext + gui.encoding + gui.fastcopyblame + gui.matchtrackingbranch + gui.newbranchtemplate + gui.pruneduringfetch + gui.spellingdictionary + gui.trustmtime + help.autocorrect + help.browser + help.format + http.lowSpeedLimit + http.lowSpeedTime + http.maxRequests + http.minSessions + http.noEPSV + http.postBuffer + http.proxy + http.sslCipherList + http.sslVersion + http.sslCAInfo + http.sslCAPath + http.sslCert + http.sslCertPasswordProtected + http.sslKey + http.sslVerify + http.useragent + i18n.commitEncoding + i18n.logOutputEncoding + imap.authMethod + imap.folder + imap.host + imap.pass + imap.port + imap.preformattedHTML + imap.sslverify + imap.tunnel + imap.user + init.templatedir + instaweb.browser + instaweb.httpd + instaweb.local + instaweb.modulepath + instaweb.port + interactive.singlekey + log.date + log.decorate + log.showroot + mailmap.file + man. + man.viewer + merge. + merge.conflictstyle + merge.log + merge.renameLimit + merge.renormalize + merge.stat + merge.tool + merge.verbosity + mergetool. + mergetool.keepBackup + mergetool.keepTemporaries + mergetool.prompt + notes.displayRef + notes.rewrite. + notes.rewrite.amend + notes.rewrite.rebase + notes.rewriteMode + notes.rewriteRef + pack.compression + pack.deltaCacheLimit + pack.deltaCacheSize + pack.depth + pack.indexVersion + pack.packSizeLimit + pack.threads + pack.window + pack.windowMemory + pager. + pretty. + pull.octopus + pull.twohead + push.default + push.followTags + rebase.autosquash + rebase.stat + receive.autogc + receive.denyCurrentBranch + receive.denyDeleteCurrent + receive.denyDeletes + receive.denyNonFastForwards + receive.fsckObjects + receive.unpackLimit + receive.updateserverinfo + remote.pushdefault + remotes. + repack.usedeltabaseoffset + rerere.autoupdate + rerere.enabled + sendemail. + sendemail.aliasesfile + sendemail.aliasfiletype + sendemail.bcc + sendemail.cc + sendemail.cccmd + sendemail.chainreplyto + sendemail.confirm + sendemail.envelopesender + sendemail.from + sendemail.identity + sendemail.multiedit + sendemail.signedoffbycc + sendemail.smtpdomain + sendemail.smtpencryption + sendemail.smtppass + sendemail.smtpserver + sendemail.smtpserveroption + sendemail.smtpserverport + sendemail.smtpuser + sendemail.suppresscc + sendemail.suppressfrom + sendemail.thread + sendemail.to + sendemail.validate + showbranch.default + status.relativePaths + status.showUntrackedFiles + status.submodulesummary + submodule. + tar.umask + transfer.unpackLimit + url. + user.email + user.name + user.signingkey + web.browser + branch. remote. + " +} + +_git_remote () +{ + local subcommands="add rename remove set-head set-branches set-url show prune update" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + return + fi + + case "$subcommand" in + rename|remove|set-url|show|prune) + __gitcomp_nl "$(__git_remotes)" + ;; + set-head|set-branches) + __git_complete_remote_or_refspec + ;; + update) + __gitcomp "$(__git_get_config_variables "remotes")" + ;; + *) + ;; + esac +} + +_git_replace () +{ + __gitcomp_nl "$(__git_refs)" +} + +_git_reset () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp "--merge --mixed --hard --soft --patch" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_revert () +{ + local dir="$(__gitdir)" + if [ -f "$dir"/REVERT_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi + case "$cur" in + --*) + __gitcomp "--edit --mainline --no-edit --no-commit --signoff" + return + ;; + esac + __gitcomp_nl "$(__git_refs)" +} + +_git_rm () +{ + case "$cur" in + --*) + __gitcomp "--cached --dry-run --ignore-unmatch --quiet" + return + ;; + esac + + __git_complete_index_file "--cached" +} + +_git_shortlog () +{ + __git_has_doubledash && return + + case "$cur" in + --*) + __gitcomp " + $__git_log_common_options + $__git_log_shortlog_options + --numbered --summary + " + return + ;; + esac + __git_complete_revlist +} + +_git_show () +{ + __git_has_doubledash && return + + case "$cur" in + --pretty=*|--format=*) + __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) + " "" "${cur#*=}" + return + ;; + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --*) + __gitcomp "--pretty= --format= --abbrev-commit --oneline + --show-signature + $__git_diff_common_options + " + return + ;; + esac + __git_complete_revlist_file +} + +_git_show_branch () +{ + case "$cur" in + --*) + __gitcomp " + --all --remotes --topo-order --current --more= + --list --independent --merge-base --no-name + --color --no-color + --sha1-name --sparse --topics --reflog + " + return + ;; + esac + __git_complete_revlist +} + +_git_stash () +{ + local save_opts='--keep-index --no-keep-index --quiet --patch' + local subcommands='save list show apply clear drop pop create branch' + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + case "$cur" in + --*) + __gitcomp "$save_opts" + ;; + *) + if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then + __gitcomp "$subcommands" + fi + ;; + esac + else + case "$subcommand,$cur" in + save,--*) + __gitcomp "$save_opts" + ;; + apply,--*|pop,--*) + __gitcomp "--index --quiet" + ;; + show,--*|drop,--*|branch,--*) + ;; + show,*|apply,*|drop,*|pop,*|branch,*) + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ + | sed -n -e 's/:.*//p')" + ;; + *) + ;; + esac + fi +} + +_git_submodule () +{ + __git_has_doubledash && return + + local subcommands="add status init deinit update summary foreach sync" + if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then + case "$cur" in + --*) + __gitcomp "--quiet --cached" + ;; + *) + __gitcomp "$subcommands" + ;; + esac + return + fi +} + +_git_svn () +{ + local subcommands=" + init fetch clone rebase dcommit log find-rev + set-tree commit-diff info create-ignore propget + proplist show-ignore show-externals branch tag blame + migrate mkdirs reset gc + " + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + else + local remote_opts="--username= --config-dir= --no-auth-cache" + local fc_opts=" + --follow-parent --authors-file= --repack= + --no-metadata --use-svm-props --use-svnsync-props + --log-window-size= --no-checkout --quiet + --repack-flags --use-log-author --localtime + --ignore-paths= --include-paths= $remote_opts + " + local init_opts=" + --template= --shared= --trunk= --tags= + --branches= --stdlayout --minimize-url + --no-metadata --use-svm-props --use-svnsync-props + --rewrite-root= --prefix= --use-log-author + --add-author-from $remote_opts + " + local cmt_opts=" + --edit --rmdir --find-copies-harder --copy-similarity= + " + + case "$subcommand,$cur" in + fetch,--*) + __gitcomp "--revision= --fetch-all $fc_opts" + ;; + clone,--*) + __gitcomp "--revision= $fc_opts $init_opts" + ;; + init,--*) + __gitcomp "$init_opts" + ;; + dcommit,--*) + __gitcomp " + --merge --strategy= --verbose --dry-run + --fetch-all --no-rebase --commit-url + --revision --interactive $cmt_opts $fc_opts + " + ;; + set-tree,--*) + __gitcomp "--stdin $cmt_opts $fc_opts" + ;; + create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ + show-externals,--*|mkdirs,--*) + __gitcomp "--revision=" + ;; + log,--*) + __gitcomp " + --limit= --revision= --verbose --incremental + --oneline --show-commit --non-recursive + --authors-file= --color + " + ;; + rebase,--*) + __gitcomp " + --merge --verbose --strategy= --local + --fetch-all --dry-run $fc_opts + " + ;; + commit-diff,--*) + __gitcomp "--message= --file= --revision= $cmt_opts" + ;; + info,--*) + __gitcomp "--url" + ;; + branch,--*) + __gitcomp "--dry-run --message --tag" + ;; + tag,--*) + __gitcomp "--dry-run --message" + ;; + blame,--*) + __gitcomp "--git-format" + ;; + migrate,--*) + __gitcomp " + --config-dir= --ignore-paths= --minimize + --no-auth-cache --username= + " + ;; + reset,--*) + __gitcomp "--revision= --parent" + ;; + *) + ;; + esac + fi +} + +_git_tag () +{ + local i c=1 f=0 + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -d|-v) + __gitcomp_nl "$(__git_tags)" + return + ;; + -f) + f=1 + ;; + esac + ((c++)) + done + + case "$prev" in + -m|-F) + ;; + -*|tag) + if [ $f = 1 ]; then + __gitcomp_nl "$(__git_tags)" + fi + ;; + *) + __gitcomp_nl "$(__git_refs)" + ;; + esac + + case "$cur" in + --*) + __gitcomp " + --list --delete --verify --annotate --message --file + --sign --cleanup --local-user --force --column --sort + --contains --points-at + " + ;; + esac +} + +_git_whatchanged () +{ + _git_log +} + +__git_main () +{ + local i c=1 command __git_dir + + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + --git-dir=*) __git_dir="${i#--git-dir=}" ;; + --git-dir) ((c++)) ; __git_dir="${words[c]}" ;; + --bare) __git_dir="." ;; + --help) command="help"; break ;; + -c|--work-tree|--namespace) ((c++)) ;; + -*) ;; + *) command="$i"; break ;; + esac + ((c++)) + done + + if [ -z "$command" ]; then + case "$cur" in + --*) __gitcomp " + --paginate + --no-pager + --git-dir= + --bare + --version + --exec-path + --exec-path= + --html-path + --man-path + --info-path + --work-tree= + --namespace= + --no-replace-objects + --help + " + ;; + *) __git_compute_porcelain_commands + __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; + esac + return + fi + + local completion_func="_git_${command//-/_}" + declare -f $completion_func >/dev/null && $completion_func && return + + local expansion=$(__git_aliased_command "$command") + if [ -n "$expansion" ]; then + words[1]=$expansion + completion_func="_git_${expansion//-/_}" + declare -f $completion_func >/dev/null && $completion_func + fi +} + +__gitk_main () +{ + __git_has_doubledash && return + + local g="$(__gitdir)" + local merge="" + if [ -f "$g/MERGE_HEAD" ]; then + merge="--merge" + fi + case "$cur" in + --*) + __gitcomp " + $__git_log_common_options + $__git_log_gitk_options + $merge + " + return + ;; + esac + __git_complete_revlist +} + +if [[ -n ${ZSH_VERSION-} ]]; then + echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 + + autoload -U +X compinit && compinit + + __gitcomp () + { + emulate -L zsh + + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + *) + local c IFS=$' \t\n' + local -a array + for c in ${=1}; do + c="$c${4-}" + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + array[${#array[@]}+1]="$c" + done + compset -P '*[=:]' + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 + ;; + esac + } + + __gitcomp_nl () + { + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + } + + __gitcomp_file () + { + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 + } + + _git () + { + local _ret=1 cur cword prev + cur=${words[CURRENT]} + prev=${words[CURRENT-1]} + let cword=CURRENT-1 + emulate ksh -c __${service}_main + let _ret && _default && _ret=0 + return _ret + } + + compdef _git git gitk + return +fi + +__git_func_wrap () +{ + local cur words cword prev + _get_comp_words_by_ref -n =: cur words cword prev + $1 +} + +# Setup completion for certain functions defined above by setting common +# variables and workarounds. +# This is NOT a public function; use at your own risk. +__git_complete () +{ + local wrapper="__git_wrap${2}" + eval "$wrapper () { __git_func_wrap $2 ; }" + complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \ + || complete -o default -o nospace -F $wrapper $1 +} + +# wrapper for backwards compatibility +_git () +{ + __git_wrap__git_main +} + +# wrapper for backwards compatibility +_gitk () +{ + __git_wrap__gitk_main +} + +__git_complete git __git_main +__git_complete gitk __gitk_main + +# The following are necessary only for Cygwin, and only are needed +# when the user has tab-completed the executable name and consequently +# included the '.exe' suffix. +# +if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then +__git_complete git.exe __git_main +fi diff --git a/m/git/.gitconfig b/m/git/.gitconfig new file mode 100644 index 0000000..bb7bc97 --- /dev/null +++ b/m/git/.gitconfig @@ -0,0 +1,5 @@ +[user] + name = Adam Cooper + email = amcooper@gmail.com +[core] + pager = diff-so-fancy | less --tabs=4 -RFX diff --git a/m/install.sh b/m/install.sh new file mode 100755 index 0000000..dea99c8 --- /dev/null +++ b/m/install.sh @@ -0,0 +1,58 @@ +#!/bin/bash +echo "Upgrading packages**" +sudo aptitude update +sudo aptitude upgrade --assume-yes +echo "**Installing packages: vim, tmux, python3, cmake, stow, fonts-powerline, snapd, etc.**" +sudo aptitude install --assume-yes git curl zsh vim tmux python3 python3-pip build-essential python3-dev python3-setuptools python3-wheel cmake stow fonts-powerline snapd lastpass-cli +echo "**Installing powerline and tmuxp**" +pip3 install powerline-status +pip3 install --user tmuxp +echo "**Installing plug.vim**" +curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +echo "**Installing diff-so-fancy**" +curl -fsSL -o ~/.local/bin/diff-so-fancy https://raw.githubusercontent.com/so-fancy/diff-so-fancy/master/third_party/build_fatpack/diff-so-fancy +sudo chmod 755 ~/.local/bin/diff-so-fancy +echo "**Installing Rust**" +curl https://sh.rustup.rs -sSf | sh -s -- -v -y +echo "source $HOME/.cargo/env" >> ./zsh/.zshrc +echo "**Backing up config files**" +[[ -f ~/.zshrc ]] && mv -v ~/.zshrc ~/.zshrc.bak +[[ -f ~/.vimrc ]] && mv -v ~/.vimrc ~/.vimrc.bak +[[ -f ~/.tmux.conf ]] && mv -v ~/.tmux.conf ~/.tmux.conf.bak +[[ -f ~/.git-completion ]] && mv -v ~/.git-completion ~/.git-completion.bak +[[ -f ~/.gitconfig ]] && mv -v ~/.gitconfig ~/.gitconfig.bak +[[ -f ~/.oysttyerrc ]] && mv -v ~/.oysttyerrc ~/.oysttyerrc.bak +[[ -f ~/.oysttyerkey ]] && mv -v ~/.oysttyerkey ~/.oysttyerkey.bak +[[ -f ~/.egrc ]] && mv -v ~/.egrc ~/.egrc.bak +[[ -f /usr/local/bin/consolidate-path ]] && mv -v /usr/local/bin/consolidate-path /usr/local/bin/consolidate-path.bak +echo "**Installing new config files**" +stow -t ~ zsh +stow -t ~ vim +stow -t ~ tmux +stow -t ~ git +stow -t ~ newsboat +stow -t ~ eg +stow -t ~ oysttyer +stow -t /usr/local/bin bin +echo "**Installing Heroku CLI**" +sudo snap install --classic heroku +echo "**Installing glances**" +pip3 install glances +echo "**Installing ddgr**" +pip3 install ddgr +echo "**Installing NVM**" +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash +echo "**Installing Yarn**" +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +sudo apt-get update && sudo apt-get install --no-install-recommends yarn +echo "**Installing Oh My Zsh**" +git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh +echo "**Installing zsh-nvm**" +git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm +echo "**Switching to zsh**" +chsh -s /bin/zsh +echo "[TODO] **Download and install bat cb eg exa fd newsboat consolidate-path**" +echo "**Please restart the system and run ~/dotfiles/post-install.sh**" +/bin/zsh + diff --git a/m/newsboat/.newsboat/config b/m/newsboat/.newsboat/config new file mode 100644 index 0000000..72bc8b8 --- /dev/null +++ b/m/newsboat/.newsboat/config @@ -0,0 +1,10 @@ +browser "surf-open.sh %u" +color background black white +color listnormal black white +color listfocus white blue +color listnormal_unread magenta white +color listfocus_unread white blue bold +color info white blue +color article black white +max-items 4096 +keep-articles-days 45 diff --git a/m/newsboat/.newsboat/history.search b/m/newsboat/.newsboat/history.search new file mode 100644 index 0000000..e69de29 diff --git a/m/newsboat/.newsboat/urls b/m/newsboat/.newsboat/urls new file mode 100644 index 0000000..97943f5 --- /dev/null +++ b/m/newsboat/.newsboat/urls @@ -0,0 +1,37 @@ +http://feeds.guardian.co.uk/theguardian/world/rss "nuggets" +http://www.wsws.org/rss/en.xml "nuggets" +http://www.democracynow.org/democracynow.rss "nuggets" +http://news.ycombinator.com/rss "tech" +https://lobste.rs/rss "tech" +http://www.languagehat.com/index.rdf "linguistics" +http://www.opengeodata.org/?feed=rss2 "tech" +http://feeds.arstechnica.com/arstechnica/index/ "tech" +http://feeds.feedburner.com/TheCssAwards "tech" +http://feeds.feedburner.com/CssTricks "tech" +https://protonvpn.com/blog/feed/ "tech" +https://cloudblog.withgoogle.com/rss/ "tech" +https://spreadprivacy.com/feed "tech" +https://protonmail.ch/blog/feed/ "tech" +http://www.bleepingcomputer.com/feed/ "tech" +https://os.phil-opp.com/rss.xml "tech" +https://mondediplo.com/backend "nuggets" +http://feeds.feedburner.com/Metafilter "nuggets" +http://feeds.feedburner.com/InTheseTimes "nuggets" +http://whowhatwhy.com/feed/ "nuggets" +http://jacobinmag.com/feed/ "nuggets" +http://www.thebaffler.com/blog/rss "nuggets" +http://www.dissentmagazine.org/feed "nuggets" +https://www.govtrack.us/events/events.rss?feeds=bill%3As116-1489 "nuggets" +https://harpers.org/feed/ "nuggets" +http://feeds.propublica.org/propublica/nerds "nuggets" +http://feeds.propublica.org/propublica/main "nuggets" +http://www.counterpunch.org/feed/ "nuggets" +http://thenewinquiry.com/rss "nuggets" +http://editor.currentaffairs.org/feed/ "nuggets" +https://www.truthdig.com/feed/ "nuggets" +http://googletesting.blogspot.com/feeds/posts/default "webdev" +http://javascriptweekly.com/rss "webdev" +http://feeds.feedburner.com/Bludice "webdev" +https://reactjs.org/feed.xml "webdev" +https://theintercept.com/feed/?lang=en "nuggets" +https://wallabag.theadamcooper.com/amcooper/iNav2v9Pb8t5ja9/unread.xml "webdev" diff --git a/m/oysttyer/.oysttyerkey b/m/oysttyer/.oysttyerkey new file mode 100644 index 0000000..d9874d0 --- /dev/null +++ b/m/oysttyer/.oysttyerkey @@ -0,0 +1 @@ +ck=X&cs=X&at=14814274-sTXAoAlc9gpgjRR451UsnG0ZLRodvDD6rfeOmJGHZ&ats=V8MtTSuNb5HKy1JGFC2q3T3DhdpfGbjdRKCCFeo0zc9Z8 diff --git a/m/oysttyer/.oysttyerrc b/m/oysttyer/.oysttyerrc new file mode 100644 index 0000000..151e005 --- /dev/null +++ b/m/oysttyer/.oysttyerrc @@ -0,0 +1,11 @@ +# keyf=/Users/adamcooper/.oysttyerkey +oauthkey=17N3a4JBR8jJsbBBdwxfAqM5a +oauthsecret=pIuaI8sDqwMH7eqthVpqTAA1zY37pB3MY4EfrVFHnSLOpElg0T +ansi=1 +separator= * * * * * * * * * * * +doublespace=1 +vcheck=1 +urlopen=surf-open.sh %U +synch=1 +mentions=1 +verify=1 diff --git a/m/post-install.sh b/m/post-install.sh new file mode 100755 index 0000000..082f376 --- /dev/null +++ b/m/post-install.sh @@ -0,0 +1,15 @@ +# Post-install script +echo "**Installing Node and NPM with NVM**" +echo "source $HOME/.nvm/nvm.sh" >> ./zsh/.zshrc +stow -t ~ -R zsh +nvm install lts/dubnium +nvm use default +echo "**Installing Typescript**" +npm install -g typescript +echo "" +echo "All that\'s left is the vim plugins. Install them by running:" +echo " $ vim -c \":PlugInstall\"" +echo "and then compile YouCompleteMe: " +echo " $ python3 ~/.vim/plugged/YouCompleteMe/install.py --ts-completer --rust-completer" +echo "and you're off to the races." + diff --git a/m/tmux/.tmux.conf b/m/tmux/.tmux.conf new file mode 100644 index 0000000..4c559ba --- /dev/null +++ b/m/tmux/.tmux.conf @@ -0,0 +1,64 @@ +# 256 colors for vim +set -g default-terminal "screen-256color" + +# Set default shell to zsh +set-option -g default-shell /bin/zsh + +# Tmuxline +if-shell "test -f ~/.tmuxline_theme_snapshot" "source ~/.tmuxline_theme_snapshot" + +# Start window numbering at 1 +set-option -g base-index 1 +set-window-option -g pane-base-index 1 + +# Cycle panes with C-b C-b +unbind ^B +bind ^B select-pane -t :.+ + +# Reload config wtih a key +bind-key r source-file ~/.tmux.conf \; display "Config reloaded!" + +# Mouse works as expected +set -g mouse on +# set -g mode-mouse on +# set -g mouse-select-pane on +# set -g mouse-resize-pane on +# set -g mouse-select-window on + +# Scrolling works as expected +set -g terminal-overrides 'xterm*:smcup@:rmcup@' + +# Use the system clipboard +# set-option -g default-command "reattach-to-user-namespace -l zsh" + +# Clear the pane and its history +bind -n C-k send-keys C-l \; clear-history + +# Smart pane switching with awareness of vim splits +# From github.com/christoomey/vim-tmux-navigator +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind-key -n C-\\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" +bind-key -T copy-mode-vi C-h select-pane -L +bind-key -T copy-mode-vi C-j select-pane -D +bind-key -T copy-mode-vi C-k select-pane -U +bind-key -T copy-mode-vi C-l select-pane -R +bind-key -T copy-mode-vi C-\\ select-pane -l + +# C-l is taken oer by vim style pane navigation (not sure where this comes from or whether I still need it) +bind C-l send-keys 'C-l' + +# Use vim keybindings in copy mode +setw -g mode-keys vi + +# Setup 'v' to begin selection as in Vim +# bind-key -t vi-copy v begin-selection +# bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" + +# Update default binding of `Enter` to also use copy-pipe +# unbind -t vi-copy Enter +# bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy" diff --git a/m/tmux/.tmuxline_theme_snapshot b/m/tmux/.tmuxline_theme_snapshot new file mode 100644 index 0000000..fe12959 --- /dev/null +++ b/m/tmux/.tmuxline_theme_snapshot @@ -0,0 +1,21 @@ +# This tmux statusbar config was created by tmuxline.vim +# on Tue, 14 Jul 2020 + +set -g status-justify "left" +set -g status "on" +set -g status-left-style "none" +set -g message-command-style "fg=colour52,bg=colour214" +set -g status-right-style "none" +set -g pane-active-border-style "fg=colour202" +set -g status-style "none,bg=colour228" +set -g message-style "fg=colour52,bg=colour214" +set -g pane-border-style "fg=colour214" +set -g status-right-length "100" +set -g status-left-length "100" +setw -g window-status-activity-style "none" +setw -g window-status-separator "" +setw -g window-status-style "none,fg=colour166,bg=colour228" +set -g status-left "#[fg=colour255,bg=colour202] #S #[fg=colour202,bg=colour228,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=colour214,bg=colour228,nobold,nounderscore,noitalics]#[fg=colour52,bg=colour214] %Y-%m-%d  %H:%M #[fg=colour202,bg=colour214,nobold,nounderscore,noitalics]#[fg=colour255,bg=colour202] #h " +setw -g window-status-format "#[fg=colour166,bg=colour228] #I #[fg=colour166,bg=colour228] #W " +setw -g window-status-current-format "#[fg=colour228,bg=colour214,nobold,nounderscore,noitalics]#[fg=colour52,bg=colour214] #I #[fg=colour52,bg=colour214] #W #[fg=colour214,bg=colour228,nobold,nounderscore,noitalics]" diff --git a/m/tmux/.tmuxp/acorn.json b/m/tmux/.tmuxp/acorn.json new file mode 100644 index 0000000..cf0f746 --- /dev/null +++ b/m/tmux/.tmuxp/acorn.json @@ -0,0 +1,25 @@ +{ + "session_name": "acorn", + "windows": [{ + "window_name": "ide", + "panes": [ + "vim -R package.json", + "ls", + "git status" + ], + "layout": "main-horizontal", + "start_directory": "~/code/acorn-glen" + }, { + "window_name": "servers", + "start_directory": "~/code/acorn-glen", + "layout": "main-horizontal", + "panes": [{ + "shell_command": [ "cd ~/code/acorn-glen", "echo 'yarn dev'" ] + }, { + "shell_command": [ "sleep 4", "echo 'yarn relay --watch'" ] + }, { + "shell_command": [ "sleep 4", "echo 'yarn start'" ] + }] + }] +} + diff --git a/m/tmux/.tmuxp/general.json b/m/tmux/.tmuxp/general.json new file mode 100644 index 0000000..6301794 --- /dev/null +++ b/m/tmux/.tmuxp/general.json @@ -0,0 +1,8 @@ +{ + "session_name": "general", + "windows": [{ + "panes": ["/etc/update-motd.d/90-custom"] + }], + "start_directory": "~" +} + diff --git a/m/tmux/.tmuxp/morning.json b/m/tmux/.tmuxp/morning.json new file mode 100644 index 0000000..a64bc82 --- /dev/null +++ b/m/tmux/.tmuxp/morning.json @@ -0,0 +1,18 @@ +{ + "session_name": "morning", + "windows": [{ + "window_name": "newsboat", + "panes": ["newsboat"] + }, { + "window_name": "ddgr", + "panes": ["ddgr --colors=ecdgxy Patrice Lumumba"] + }, { + "window_name": "oysttyer", + "panes": ["oysttyer"] + }, { + "window_name": "general", + "panes": ["date"] + }], + "start_directory": "~" +} + diff --git a/m/vim/.vimrc b/m/vim/.vimrc new file mode 100644 index 0000000..70bf330 --- /dev/null +++ b/m/vim/.vimrc @@ -0,0 +1,96 @@ +" Make backspace behave in a sane manner. +set backspace=indent,eol,start + +" Spaces indentation +set expandtab +set tabstop=2 +" set softtabstop=2 +set shiftwidth=2 +" Consider installing the Smart Tabs plugin + +" Show whitespace +set listchars=eol:¬,tab:>-,trail:~,extends:>,precedes:<,space:· + +" Show line numbers +set number +set relativenumber + +" Default: split right +set splitright + +" Allow hidden buffers, don't limit to one file per window/split +set hidden + +" Sane vim split naviagation (via Gaslight blog) +nnoremap j +nnoremap k +nnoremap h +nnoremap l + +" Disable filetype detection +filetype off + +" vim-plug +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +call plug#begin('~/.vim/plugged') +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'edkolev/tmuxline.vim' +Plug 'christoomey/vim-tmux-navigator' +Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'dense-analysis/ale' +Plug 'Valloric/YouCompleteMe' +Plug 'pangloss/vim-javascript' +Plug 'MaxMEllon/vim-jsx-pretty' +Plug 'leafgarland/typescript-vim' +Plug 'HerringtonDarkholme/yats.vim' +Plug 'Quramy/tsuquyomi' +Plug 'rust-lang/rust.vim' +Plug 'severij/vadelma' +Plug 'tpope/vim-surround' +call plug#end() + +" NERDTree on ctrl+n +let NERDTreeShowHidden=1 +map :NERDTreeToggle + +" close NERDTree after opening a file +" let g:NERDTreeQuitOnOpen=1 + +" Tsuquyomi +autocmd Filetype typescript nmap t : echo tsuquyomi#hint() + +" Airline +let g:airline_powerline_fonts = 1 +let g:airline_theme = 'light' + +" Tmuxline +let g:tmuxline_theme = 'airline_visual' + +" YouCompleteMe <> TypeScript +if !exists("g:ycm_semantic_triggers") + let g:ycm_semantic_triggers = {} +endif +let g:ycm_semantic_triggers['typescript'] = ['.'] + +" Enable file type detection and do language-dependent indenting +filetype plugin indent on + +" Switch syntax highlighting on +syntax enable + +" Set color scheme +set background=light +colorscheme vadelma + +" Temporary file locations +set backupdir=.backup/,~/.backup/,/tmp// +set directory=.swp/,~/.swp/,/tmp// +set undodir=.undo/,~/.undo/,/tmp// diff --git a/m/zsh/.zshrc b/m/zsh/.zshrc new file mode 100644 index 0000000..33a5fef --- /dev/null +++ b/m/zsh/.zshrc @@ -0,0 +1,161 @@ +## Vi keybindings for the shell ## +bindkey -v + +## History navigation by search pattern +bindkey '^[0A' history-beginning-search-backward +bindkey '^[0B' history-beginning-search-forward + +## bash history timestamps ## +export HISTTIMEFORMAT="%a %Y-%m-%d %T " + +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +# Set name of the theme to load. +# Look in ~/.oh-my-zsh/themes/ +# Optionally, if you set this to "random", it'll load a random theme each +# time that oh-my-zsh is loaded. +ZSH_THEME="" + +# Suppress display of name of default user in prompt +DEFAULT_USER=$USER +prompt_context() {} + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_ZSH_DAYS=13 + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +export DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(git zsh-nvm vi-mode) + +source $ZSH/oh-my-zsh.sh + +# User configuration + +export PATH="$HOME/.cargo/env:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/go/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" +# export PATH="$HOME/.local/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/go/bin:$PATH" + +## Add Visual Studio Code (code) +# export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin" + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi +export VISUAL=vim +export EDITOR=$VISUAL + +export BROWSER=surf-open.sh + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# ssh +# export SSH_KEY_PATH="~/.ssh/dsa_id" + +# Set personal aliases, overriding those provided by oh-my-zsh libs, +# plugins, and themes. Aliases can be placed here, though oh-my-zsh +# users are encouraged to define aliases within the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" + +# If not running interactively, don't do anything + +[ -z "$PS1" ] && return + +# Why are these not exports? +# enable git unstaged indicators - set to a non-empty value +GIT_PS1_SHOWDIRTYSTATE="." + +# enable showing of untracked files - set to a non-empty value +GIT_PS1_SHOWUNTRACKEDFILES="." + +# enable stash checking - set to a non-empty value +GIT_PS1_SHOWSTASHSTATE="." + +# enable showing of HEAD vs its upstream +GIT_PS1_SHOWUPSTREAM="auto" + +BLACK=$(tput setaf 0) +RED=$(tput setaf 1) +GREEN=$(tput setaf 2) +YELLOW=$(tput setaf 3) +LIME_YELLOW=$(tput setaf 190) +POWDER_BLUE=$(tput setaf 153) +BLUE=$(tput setaf 4) +MAGENTA=$(tput setaf 5) +CYAN=$(tput setaf 6) +WHITE=$(tput setaf 7) +BRIGHT=$(tput bold) +NORMAL=$(tput sgr0) +BLINK=$(tput blink) +REVERSE=$(tput smso) +UNDERLINE=$(tput smul) + +## NVM ## +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Starship +eval "$(starship init zsh)" + +## FZF ## +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh +export FZF_DEFAULT_COMMAND="find ." # Includes hidden files + +# exa colors +export LS_COLORS="*.md=37" +export EXA_COLORS="uu=33;45;1" + +# tmuxp completion +eval "$(_TMUXP_COMPLETE=source_zsh tmuxp)" + +source /home/adam/.cargo/env +source /home/adam/.nvm/nvm.sh + +# Consolidate PATH +export PATH="$(consolidate-path "$PATH")"