├── vim ├── init.vim ├── plugin │ ├── lean.lua │ ├── insert.vim │ └── spacemacs.vim ├── ftplugin │ └── tex.vim └── indent │ ├── html.vim │ └── javascript.vim ├── gitignore_global ├── zed ├── .gitignore ├── global_settings.json ├── settings.json └── tasks.json ├── nvim ├── .gitignore ├── .stylua.toml ├── lua │ ├── custom │ │ └── plugins │ │ │ └── init.lua │ └── kickstart │ │ ├── plugins │ │ ├── indent_line.lua │ │ ├── autopairs.lua │ │ ├── neo-tree.lua │ │ ├── lint.lua │ │ ├── gitsigns.lua │ │ └── debug.lua │ │ └── health.lua ├── .github │ ├── pull_request_template.md │ ├── workflows │ │ └── stylua.yml │ └── ISSUE_TEMPLATE │ │ └── bug_report.md ├── LICENSE.md ├── doc │ └── kickstart.txt └── README.md ├── wasavi.rc ├── mac_defaults.sh ├── zshrc_scripts ├── osx.zsh ├── colorized_man.sh ├── aliases.sh ├── bindkeys.sh ├── fasd.fzf.zsh └── sessions.zsh ├── screenrc ├── vmailrc.template ├── .gitignore ├── vimium ├── exclusions ├── search └── mappings ├── dotty.rc ├── focus-tab ├── tried.md ├── todo.md ├── brewlist ├── pbcopy ├── preview.sh ├── karabiner ├── README.md └── karabiner_settings.py ├── monkey_scripts └── youtube.user.js ├── README.md ├── vscode.jsonc ├── ublock_filters ├── clipy-snippets.xml ├── my.zsh-theme ├── vimperator └── plugin │ ├── wasavi_mediator.js │ └── smoozy.js ├── zshrc ├── vimperatorrc ├── RectangleConfig.json ├── tmux.conf ├── my.itermcolors ├── dotty ├── spacemacs └── gitconfig /vim/init.vim: -------------------------------------------------------------------------------- 1 | ../vimrc -------------------------------------------------------------------------------- /gitignore_global: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /zed/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.backup 3 | prompts/ 4 | conversations/ 5 | -------------------------------------------------------------------------------- /nvim/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | test.sh 3 | .luarc.json 4 | nvim 5 | 6 | spell/ 7 | lazy-lock.json 8 | -------------------------------------------------------------------------------- /wasavi.rc: -------------------------------------------------------------------------------- 1 | " exrc for wasavi 2 | set noerrorbells 3 | set nolaunchbell 4 | map ; : 5 | map ZZ 6 | -------------------------------------------------------------------------------- /vim/plugin/lean.lua: -------------------------------------------------------------------------------- 1 | require('lean').setup{ 2 | lsp = { on_attach = on_attach }, 3 | mappings = true, 4 | } 5 | -------------------------------------------------------------------------------- /mac_defaults.sh: -------------------------------------------------------------------------------- 1 | 2 | # basically hide dock forever 3 | defaults write com.apple.Dock autohide-delay -float 5 4 | # defaults delete com.apple.Dock autohide-delay 5 | -------------------------------------------------------------------------------- /zshrc_scripts/osx.zsh: -------------------------------------------------------------------------------- 1 | # works on sierra 2 | 3 | osx_logout() { 4 | "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession" -suspend 5 | } 6 | -------------------------------------------------------------------------------- /screenrc: -------------------------------------------------------------------------------- 1 | defscrollback 10000 2 | shell zsh 3 | term xterm-256color 4 | # so that escape doesn't trigger escape sequences (which is very annoying in vim/evil) 5 | maptimeout 0 6 | -------------------------------------------------------------------------------- /vmailrc.template: -------------------------------------------------------------------------------- 1 | username: wuthefwasthat@gmail.com 2 | name: Jeff Wu 3 | password: {generate an app specific password from google} 4 | signature: | 5 | -- 6 | Best, Jeff 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.sw* 2 | vim/.netrwhist 3 | vim/indnt/.netrwhist 4 | vim/plugged 5 | vim_old/plugged 6 | vimperator/info 7 | yankring_history* 8 | .DS_Store 9 | .mypy_cache 10 | -------------------------------------------------------------------------------- /nvim/.stylua.toml: -------------------------------------------------------------------------------- 1 | column_width = 160 2 | line_endings = "Unix" 3 | indent_type = "Spaces" 4 | indent_width = 2 5 | quote_style = "AutoPreferSingle" 6 | call_parentheses = "None" 7 | -------------------------------------------------------------------------------- /vimium/exclusions: -------------------------------------------------------------------------------- 1 | https?://mail.google.com/* ejkarf#ugimloxc 2 | https?://www.youtube.com/* hlm><.,][;/v 3 | https?://www.pathery.com/* lvwxesgrzym12345 4 | https?://calendar.google.com/* dwmtjkc? 5 | -------------------------------------------------------------------------------- /nvim/lua/custom/plugins/init.lua: -------------------------------------------------------------------------------- 1 | -- You can add your own plugins here or in other files in this directory! 2 | -- I promise not to create any merge conflicts in this directory :) 3 | -- 4 | -- See the kickstart.nvim README for more information 5 | return {} 6 | -------------------------------------------------------------------------------- /nvim/lua/kickstart/plugins/indent_line.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { -- Add indentation guides even on blank lines 3 | 'lukas-reineke/indent-blankline.nvim', 4 | -- Enable `lukas-reineke/indent-blankline.nvim` 5 | -- See `:help ibl` 6 | main = 'ibl', 7 | opts = {}, 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /dotty.rc: -------------------------------------------------------------------------------- 1 | gitconfig 2 | gitignore_global 3 | screenrc 4 | spacemacs 5 | tmux.conf 6 | vim 7 | nvim ~/.config/nvim 8 | zed ~/.config/zed 9 | vimperator 10 | vimperatorrc 11 | vimrc 12 | zshrc_scripts 13 | config/karabiner/karabiner.json 14 | preview.sh 15 | 16 | # NOTE: works, but better to source this in zshrc instead of installing it 17 | # zshrc 18 | -------------------------------------------------------------------------------- /vim/ftplugin/tex.vim: -------------------------------------------------------------------------------- 1 | set sw=2 2 | 3 | " TIP: if you write your \label's as \label{fig:something}, then if you 4 | " type in \ref{fig: and press you will automatically cycle through 5 | " all the figure labels. Very useful! 6 | set iskeyword+=: 7 | 8 | au BufWritePost *.tex silent call Tex_RunLaTeX() 9 | au BufWritePost *.tex silent !pkill -USR1 xdvi.bin 10 | -------------------------------------------------------------------------------- /nvim/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | *************************************************************************** 2 | **NOTE** 3 | Please verify that the `base repository` above has the intended destination! 4 | Github by default opens Pull Requests against the parent of a forked repository. 5 | If this is your personal fork and you didn't intend to open a PR for contribution 6 | to the original project then adjust the `base repository` accordingly. 7 | ************************************************************************** 8 | 9 | -------------------------------------------------------------------------------- /zshrc_scripts/colorized_man.sh: -------------------------------------------------------------------------------- 1 | # http://boredzo.org/blog/archives/2016-08-15/colorized-man-pages-understood-and-customized 2 | man() { 3 | env \ 4 | LESS_TERMCAP_mb=$(printf "\e[1;31m") \ 5 | LESS_TERMCAP_md=$(printf "\e[1;31m") \ 6 | LESS_TERMCAP_me=$(printf "\e[0m") \ 7 | LESS_TERMCAP_se=$(printf "\e[0m") \ 8 | LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ 9 | LESS_TERMCAP_ue=$(printf "\e[0m") \ 10 | LESS_TERMCAP_us=$(printf "\e[1;32m") \ 11 | man "$@" 12 | } 13 | -------------------------------------------------------------------------------- /nvim/lua/kickstart/plugins/autopairs.lua: -------------------------------------------------------------------------------- 1 | -- autopairs 2 | -- https://github.com/windwp/nvim-autopairs 3 | 4 | return { 5 | 'windwp/nvim-autopairs', 6 | event = 'InsertEnter', 7 | -- Optional dependency 8 | dependencies = { 'hrsh7th/nvim-cmp' }, 9 | config = function() 10 | require('nvim-autopairs').setup {} 11 | -- If you want to automatically add `(` after selecting a function or method 12 | local cmp_autopairs = require 'nvim-autopairs.completion.cmp' 13 | local cmp = require 'cmp' 14 | cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) 15 | end, 16 | } 17 | -------------------------------------------------------------------------------- /vimium/search: -------------------------------------------------------------------------------- 1 | w: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedia 2 | g: http://www.google.com/search?q=%s Google 3 | gl: http://www.google.com/search?q=%s&btnI I'm feeling lucky... 4 | y: http://www.youtube.com/results?search_query=%s Youtube 5 | m: https://www.google.com/maps?q=%s Google maps 6 | az: http://www.amazon.com/s/?field-keywords=%s Amazon 7 | 8 | # More examples. 9 | # 10 | # (Vimium supports search completion Wikipedia, as 11 | # above, and for these.) 12 | # 13 | # b: https://www.bing.com/search?q=%s Bing 14 | # d: https://duckduckgo.com/?q=%s DuckDuckGo 15 | # qw: https://www.qwant.com/?q=%s Qwant 16 | -------------------------------------------------------------------------------- /nvim/.github/workflows/stylua.yml: -------------------------------------------------------------------------------- 1 | # Check Lua Formatting 2 | name: Check Lua Formatting 3 | on: pull_request_target 4 | 5 | jobs: 6 | stylua-check: 7 | if: github.repository == 'nvim-lua/kickstart.nvim' 8 | name: Stylua Check 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout Code 12 | uses: actions/checkout@v2 13 | with: 14 | ref: ${{ github.event.pull_request.head.sha }} 15 | - name: Stylua Check 16 | uses: JohnnyMorganz/stylua-action@v3 17 | with: 18 | token: ${{ secrets.GITHUB_TOKEN }} 19 | version: latest 20 | args: --check . 21 | 22 | -------------------------------------------------------------------------------- /nvim/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ## Describe the bug 13 | 14 | 15 | ## To Reproduce 16 | 17 | 1. ... 18 | 19 | ## Desktop 20 | 21 | - OS: 22 | - Terminal: 23 | 24 | ## Neovim Version 25 | 26 | 27 | ``` 28 | ``` 29 | -------------------------------------------------------------------------------- /nvim/lua/kickstart/plugins/neo-tree.lua: -------------------------------------------------------------------------------- 1 | -- Neo-tree is a Neovim plugin to browse the file system 2 | -- https://github.com/nvim-neo-tree/neo-tree.nvim 3 | 4 | return { 5 | 'nvim-neo-tree/neo-tree.nvim', 6 | version = '*', 7 | dependencies = { 8 | 'nvim-lua/plenary.nvim', 9 | 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended 10 | 'MunifTanjim/nui.nvim', 11 | }, 12 | cmd = 'Neotree', 13 | keys = { 14 | { '\\', ':Neotree reveal', desc = 'NeoTree reveal' }, 15 | }, 16 | opts = { 17 | filesystem = { 18 | window = { 19 | mappings = { 20 | ['\\'] = 'close_window', 21 | }, 22 | }, 23 | }, 24 | }, 25 | } 26 | -------------------------------------------------------------------------------- /focus-tab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ]; then 4 | echo "Usage: focus-tab " 5 | exit 1 6 | fi 7 | 8 | osascript -e " 9 | tell application \"Google Chrome\" 10 | activate 11 | set theUrl to \"$1\" 12 | 13 | repeat with w in windows 14 | set i to 0 15 | repeat with t in tabs of w 16 | set i to i + 1 17 | if theUrl is in (URL of t as string) then 18 | tell w 19 | set active tab index to i 20 | set index to 1 21 | end tell 22 | return 23 | end if 24 | end repeat 25 | end repeat 26 | 27 | # If we get here, URL wasn't found 28 | open location theUrl 29 | end tell" 30 | -------------------------------------------------------------------------------- /tried.md: -------------------------------------------------------------------------------- 1 | ## found to be meh 2 | - install vmail 3 | - make a vmailrc from the vmailrc.template 4 | - install macports if needed 5 | - add `export PATH=$PATH:/opt/local/bin:/opt/local/sbin` to zshrc 6 | - sudo env "PATH=$PATH" port install lynx 7 | - gem install vmail 8 | - `git clone https://github.com/WuTheFWasThat/vmail.git` 9 | or `git clone git@github.com:WuTheFWasThat/vmail.git` 10 | - replace stuff with wuthefwasthat vmail 11 | INSTALLED_VMAIL_PATH=/usr/local/lib/ruby/gems/2.3.0/gems/vmail-2.9.8/ 12 | NEW_VMAIL_PATH=~/Documents/vmail 13 | ``` 14 | rm $INSTALLED_VMAIL_PATH/vmail.vim 15 | rm $INSTALLED_VMAIL_PATH/vmail.rb 16 | ln -s -f $NEW_VMAIL_PATH/vmail.vim $INSTALLED_VMAIL_PATH/vmail.vim 17 | ln -s -f $NEW_VMAIL_PATH/vmail.rb $INSTALLED_VMAIL_PATH/vmail.rb 18 | ``` 19 | -------------------------------------------------------------------------------- /zed/global_settings.json: -------------------------------------------------------------------------------- 1 | // This configuration is centrally managed by Kandji. 2 | // Join #zed-announce and #zed-users in Anthropic's slack. 3 | // Visit go/zed for more information. 4 | 5 | { 6 | // Titlebar related settings. 7 | "title_bar": { 8 | // Whether to show the sign in button in the titlebar. 9 | "show_sign_in": false 10 | }, 11 | "collaboration_panel": { 12 | // Whether to show the collaboration panel button in the status bar. 13 | "button": false 14 | }, 15 | "agent": { 16 | // When enabled, show voting thumbs for feedback on agent edits. 17 | "enable_feedback": false 18 | }, 19 | // Control what info is collected by Zed. 20 | "telemetry": { 21 | // Send debug info like crash reports. 22 | "diagnostics": false, 23 | // Send anonymized usage data like what languages you're using Zed with. 24 | "metrics": false 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /todo.md: -------------------------------------------------------------------------------- 1 | ## TODO 2 | - make dotty link zsh-theme, takes A -> B in rcfile 3 | - set up git aliases like described in answer here: 4 | https://stackoverflow.com/questions/7275508/is-there-a-way-to-squash-a-number-of-commits-non-interactively 5 | - integrate ripgrep into workflow http://owen.cymru/fzf-ripgrep-navigate-with-bash-faster-than-ever-before/ 6 | - vim, see .vimrc 7 | - maybe try intsead of fzf: https://github.com/jhawthorn/fzy 8 | - spacemacs, see .spacemacs 9 | - vimperator, see .vimperatorrc 10 | - for neovim 11 | - https://github.com/neomake/neomake 12 | 13 | let g:neomake_tsc_maker = { 'exe': 'tsc', 'args': [] } 14 | autocmd BufEnter,BufWritePost *.ts Neomake! tsc 15 | 16 | let g:neomake_cargo_maker = { 'exe': 'cargo', 'args': [] } 17 | autocmd BufEnter,BufWritePost *.rs Neomake! cargo 18 | 19 | - alias pip to pipenv 20 | https://github.com/kennethreitz/pipenv 21 | 22 | - on remote machines, often useful to install: 23 | https://github.com/skaji/remote-pbcopy-iterm2 24 | 25 | -------------------------------------------------------------------------------- /vim/plugin/insert.vim: -------------------------------------------------------------------------------- 1 | """"""""""" 2 | " movement 3 | """"""""""" 4 | " TODO: enable these when spacemacs mappings are done (also, figure out esc 5 | " for visual block insert and stuff 6 | " inoremap 7 | " inoremap 8 | " inoremap 9 | " inoremap 10 | " inoremap 11 | 12 | inoremap 13 | inoremap 14 | inoremap 15 | inoremap 16 | 17 | inoremap I 18 | inoremap A 19 | inoremap lei 20 | " inoremap lwi 21 | inoremap bi 22 | " this doesn't work 23 | " imap wi 24 | " imap bi 25 | 26 | inoremap i 27 | inoremap i 28 | 29 | """"""""""" 30 | " abbreviations 31 | """"""""""" 32 | 33 | " iabbrev @@ wuthefwasthat@gmail.com 34 | " iabbrev sig Jeff Wuwuthefwasthat@gmail.com 35 | 36 | " autocorrect 37 | iabbrev tehn then 38 | iabbrev taht that 39 | iabbrev teh the 40 | iabbrev nad and 41 | iabbrev adn and 42 | -------------------------------------------------------------------------------- /nvim/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /vimium/mappings: -------------------------------------------------------------------------------- 1 | # Insert your preferred key mappings here. 2 | # map Vomnibar.activateInNewTab # this doesnt work 3 | map Vomnibar.activateInNewTab 4 | map Vomnibar.activateTabSelection 5 | 6 | unmap 7 | unmap 8 | unmap 9 | unmap 10 | 11 | map b Vomnibar.activateTabSelection 12 | map Vomnibar.activateTabSelection 13 | # unmap b 14 | # unmap B 15 | map bp previousTab 16 | map bn nextTab 17 | unmap x 18 | map previousTab 19 | map nextTab 20 | map visitPreviousTab 21 | map bb visitPreviousTab 22 | map t Vomnibar.activateTabSelection 23 | unmap T 24 | unmap 25 | unmap 26 | unmap d 27 | unmap u 28 | map scrollPageDown 29 | map scrollPageUp 30 | map removeTab 31 | 32 | unmap H 33 | unmap L 34 | map goBack 35 | map goForward 36 | 37 | unmap J 38 | unmap K 39 | map previousTab 40 | map nextTab 41 | # more sensible with firefox 42 | map previousTab 43 | map nextTab 44 | 45 | 46 | unmap ^ 47 | map visitPreviousTab 48 | 49 | unmap 50 | map gp togglePinTab 51 | -------------------------------------------------------------------------------- /zshrc_scripts/aliases.sh: -------------------------------------------------------------------------------- 1 | # python stuff 2 | export PYTHONPATH=.:/usr/local/lib/python 3 | alias py='python' 4 | alias py3='python3' 5 | alias ipy='ipython' 6 | 7 | if which bat > /dev/null; then 8 | alias cat='bat' 9 | fi 10 | 11 | # TODO: use fd instead of find 12 | # https://github.com/sharkdp/fd#installation 13 | 14 | # TODO: use ripgrep instead of grep 15 | 16 | function list_space { 17 | du -sh -- $1* | sort -rg 18 | } 19 | 20 | function tmux_reload { 21 | tmux source-file ~/.tmux.conf 22 | } 23 | 24 | alias o='open' 25 | alias g='git' 26 | alias gnp='git --no-pager' 27 | 28 | function gj { 29 | query=${1:-*} 30 | dir=$(fasd -d $query -Rld | grep "^$(g root)" | head -n 1) 31 | if [ -n "$dir" ]; then cd $dir; fi 32 | } 33 | alias h='history | less' 34 | alias b='popd' 35 | 36 | alias docs='pushd ~/Documents' 37 | alias dls='pushd ~/Downloads' 38 | alias p='pushd ~/Projects' 39 | 40 | # stupid: nvim C-H doesn't work 41 | # alias vim='nvim' 42 | alias plug='vim +PlugInstall +qall' 43 | 44 | alias pypibump='rm -rf dist build *.egg-info && python3 setup.py sdist bdist_wheel && python3 -m twine upload dist/*' 45 | -------------------------------------------------------------------------------- /nvim/doc/kickstart.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | INTRODUCTION *kickstart.nvim* 3 | 4 | Kickstart.nvim is a project to help you get started on your neovim journey. 5 | 6 | *kickstart-is-not* 7 | It is not: 8 | - Complete framework for every plugin under the sun 9 | - Place to add every plugin that could ever be useful 10 | 11 | *kickstart-is* 12 | It is: 13 | - Somewhere that has a good start for the most common "IDE" type features: 14 | - autocompletion 15 | - goto-definition 16 | - find references 17 | - fuzzy finding 18 | - and hinting at what more can be done :) 19 | - A place to _kickstart_ your journey. 20 | - You should fork this project and use/modify it so that it matches your 21 | style and preferences. If you don't want to do that, there are probably 22 | other projects that would fit much better for you (and that's great!)! 23 | 24 | vim:tw=78:ts=8:ft=help:norl: 25 | -------------------------------------------------------------------------------- /zshrc_scripts/bindkeys.sh: -------------------------------------------------------------------------------- 1 | # https://coderwall.com/p/jpj_6q/zsh-better-history-searching-with-arrow-keys 2 | autoload -U up-line-or-beginning-search 3 | autoload -U down-line-or-beginning-search 4 | zle -N up-line-or-beginning-search 5 | zle -N down-line-or-beginning-search 6 | # bindkey "^[[A" up-line-or-beginning-search # Up 7 | # bindkey "^[[B" down-line-or-beginning-search # Down 8 | 9 | # for emacs mode: 10 | bindkey '^u' backward-kill-line 11 | # normally this is ^k 12 | # NOTE: '^i' is also tab 13 | bindkey '^o' kill-line 14 | 15 | # set vi mode 16 | # bindkey -v 17 | # decrease delay afer key 18 | export KEYTIMEOUT=1 19 | 20 | # neither seems totally correct, but: 21 | # http://www.tcsh.org/tcsh.html/Editor_commands.html 22 | # `man bash` 23 | bindkey '^h' backward-char 24 | bindkey '^l' forward-char 25 | bindkey '^k' up-history 26 | bindkey '^j' down-history 27 | # ^k and ^j might not work in tmux (used for switching panes) 28 | # bindkey '^p' up-history 29 | # bindkey '^n' down-history 30 | bindkey '^p' up-line-or-beginning-search 31 | bindkey '^n' down-line-or-beginning-search 32 | 33 | bindkey '^v' edit-command-line 34 | # bindkey -M vicmd v edit-command-line 35 | 36 | bindkey '^b' backward-word 37 | bindkey '^f' forward-word 38 | 39 | bindkey '^a' beginning-of-line 40 | bindkey '^e' end-of-line 41 | bindkey '^r' fzf-history-widget 42 | # bindkey '^r' history-incremental-search-backward 43 | # bindkey '^r' history-incremental-pattern-search-backward 44 | bindkey '^g' clear-screen 45 | -------------------------------------------------------------------------------- /brewlist: -------------------------------------------------------------------------------- 1 | abseil 2 | autoconf 3 | azure-cli 4 | bat 5 | bdw-gc 6 | berkeley-db 7 | boost 8 | ca-certificates 9 | cmake 10 | coreutils 11 | double-conversion 12 | edencommon 13 | elan-init 14 | emacs 15 | fasd 16 | fb303 17 | fbthrift 18 | fizz 19 | fmt 20 | fnm 21 | folly 22 | fzf 23 | gcc 24 | gdbm 25 | gettext 26 | gflags 27 | ghostscript 28 | git-delta 29 | glog 30 | gmp 31 | gnupg 32 | gnutls 33 | guile 34 | heroku 35 | heroku-node 36 | htop 37 | hub 38 | hwloc 39 | icu4c 40 | isl 41 | jansson 42 | jpeg 43 | jq 44 | jsoncpp 45 | krb5 46 | kubernetes-cli 47 | libassuan 48 | libevent 49 | libgcrypt 50 | libgpg-error 51 | libidn2 52 | libksba 53 | libmpc 54 | libnghttp2 55 | libomp 56 | libsodium 57 | libtasn1 58 | libtermkey 59 | libtiff 60 | libtool 61 | libunistring 62 | libusb 63 | libuv 64 | libvterm 65 | libyaml 66 | little-cms2 67 | lua 68 | luajit 69 | luajit-openresty 70 | luv 71 | lz4 72 | m4 73 | mosh 74 | mpdecimal 75 | mpfr 76 | mpich 77 | msgpack 78 | mysql 79 | ncurses 80 | neovim 81 | nettle 82 | npth 83 | oniguruma 84 | openssl@1.1 85 | openssl@3 86 | p11-kit 87 | p7zip 88 | pcre 89 | pcre2 90 | perl 91 | pinentry 92 | pipenv 93 | pkg-config 94 | postgresql 95 | postgresql@14 96 | protobuf 97 | pyenv 98 | python@2 99 | python@3.10 100 | python@3.11 101 | python@3.9 102 | readline 103 | ripgrep 104 | ruby 105 | six 106 | snappy 107 | sqlite 108 | swig 109 | tfswitch 110 | the_silver_searcher 111 | tmux 112 | tree 113 | tree-sitter 114 | unbound 115 | unibilium 116 | utf8proc 117 | vim 118 | wangle 119 | watch 120 | watchman 121 | xz 122 | zlib 123 | zstd 124 | bitbar 125 | calibre 126 | mactex 127 | -------------------------------------------------------------------------------- /nvim/lua/kickstart/health.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | -- 3 | -- This file is not required for your own configuration, 4 | -- but helps people determine if their system is setup correctly. 5 | -- 6 | --]] 7 | 8 | local check_version = function() 9 | local verstr = tostring(vim.version()) 10 | if not vim.version.ge then 11 | vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) 12 | return 13 | end 14 | 15 | if vim.version.ge(vim.version(), '0.10-dev') then 16 | vim.health.ok(string.format("Neovim version is: '%s'", verstr)) 17 | else 18 | vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) 19 | end 20 | end 21 | 22 | local check_external_reqs = function() 23 | -- Basic utils: `git`, `make`, `unzip` 24 | for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do 25 | local is_executable = vim.fn.executable(exe) == 1 26 | if is_executable then 27 | vim.health.ok(string.format("Found executable: '%s'", exe)) 28 | else 29 | vim.health.warn(string.format("Could not find executable: '%s'", exe)) 30 | end 31 | end 32 | 33 | return true 34 | end 35 | 36 | return { 37 | check = function() 38 | vim.health.start 'kickstart.nvim' 39 | 40 | vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` 41 | 42 | Fix only warnings for plugins and languages you intend to use. 43 | Mason will give warnings for languages that are not installed. 44 | You do not need to install, unless you want to use those languages!]] 45 | 46 | local uv = vim.uv or vim.loop 47 | vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) 48 | 49 | check_version() 50 | check_external_reqs() 51 | end, 52 | } 53 | -------------------------------------------------------------------------------- /pbcopy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # linux versio nof pbcopy 3 | use strict; 4 | use warnings; 5 | use MIME::Base64 qw(encode_base64); 6 | 7 | my $input = do { local $/; <> } || ""; 8 | $input =~ s/\n+\z//sm; 9 | $input or exit; 10 | 11 | my $b = "\\"; # 1 backslash, not 2 12 | # escape sequences taken from http://qiita.com/kefir_/items/515ed5264fce40dec522 13 | my %format = ( 14 | normal => "\e]52;;%s\e$b", 15 | tmux => "\ePtmux;\e\e]52;;%s\e\e$b$b\e$b", 16 | screen => "\eP\e]52;;%s\x07\e$b", 17 | ); 18 | 19 | my $format = sub { 20 | if (my $tmux = $ENV{TMUX}) { 21 | # check tmux -CC 22 | (undef, my $pid) = split /,/, $tmux, 3; 23 | if ($pid) { 24 | my $ps = `ps -p $pid -o command= 2>/dev/null` || ""; 25 | chomp $ps; 26 | (undef, my @option) = split /\s+/, $ps; 27 | if (grep { $_ eq "-CC" } @option) { 28 | return $format{normal}; 29 | } 30 | } 31 | $format{tmux}; 32 | } elsif ( ($ENV{TERM} || "") eq "screen" ) { 33 | $format{screen}; 34 | } else { 35 | $format{normal}; 36 | } 37 | }->(); 38 | 39 | printf $format, encode_base64($input, ""); 40 | 41 | __END__ 42 | 43 | =head1 NAME 44 | 45 | pbcopy - remote pbcopy for iTerm2 46 | 47 | =head1 SYNOPSIS 48 | 49 | [remote] $ echo "copy to clipboard from remote!" | pbcopy 50 | 51 | [local] $ pbcopy 52 | copy to clipboard from remote! 53 | 54 | =head1 SEE ALSO 55 | 56 | =over 4 57 | 58 | =item * http://doda.b.sourceforge.jp/2011/12/15/tmux-set-clipboard/ 59 | 60 | =item * http://qiita.com/kefir_/items/1f635fe66b778932e278 61 | 62 | =item * http://qiita.com/kefir_/items/515ed5264fce40dec522 63 | 64 | =back 65 | 66 | =head1 AUTHOR 67 | 68 | Shoichi Kaji 69 | 70 | =cut 71 | -------------------------------------------------------------------------------- /preview.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | REVERSE="\x1b[7m" 4 | RESET="\x1b[m" 5 | 6 | if [ -z "$1" ]; then 7 | echo "usage: $0 FILENAME[:LINENO][:IGNORED]" 8 | exit 1 9 | fi 10 | 11 | IFS=':' read -r -a INPUT <<< "$1" 12 | FILE=${INPUT[0]} 13 | CENTER=${INPUT[1]} 14 | 15 | if [[ $1 =~ ^[A-Z]:\\ ]]; then 16 | FILE=$FILE:${INPUT[1]} 17 | CENTER=${INPUT[2]} 18 | fi 19 | 20 | if [[ -n "$CENTER" && ! "$CENTER" =~ ^[0-9] ]]; then 21 | exit 1 22 | fi 23 | CENTER=${CENTER/[^0-9]*/} 24 | 25 | FILE="${FILE/#\~\//$HOME/}" 26 | if [ ! -r "$FILE" ]; then 27 | echo "File not found ${FILE}" 28 | exit 1 29 | fi 30 | 31 | FILE_LENGTH=${#FILE} 32 | MIME=$(file --dereference --mime "$FILE") 33 | if [[ "${MIME:FILE_LENGTH}" =~ binary ]]; then 34 | echo "$MIME" 35 | exit 0 36 | fi 37 | 38 | if [ -z "$CENTER" ]; then 39 | CENTER=0 40 | fi 41 | 42 | if [ -n "$FZF_PREVIEW_LINES" ]; then 43 | LINES=$FZF_PREVIEW_LINES 44 | else 45 | if [ -r /dev/tty ]; then 46 | LINES=$(stty size < /dev/tty | awk '{print $1}') 47 | else 48 | LINES=40 49 | fi 50 | fi 51 | 52 | FIRST=$(($CENTER-$LINES/3)) 53 | FIRST=$(($FIRST < 1 ? 1 : $FIRST)) 54 | LAST=$((${FIRST}+${LINES}-1)) 55 | 56 | if [ -z "$FZF_PREVIEW_COMMAND" ] && command -v bat > /dev/null; then 57 | bat --style="${BAT_STYLE:-numbers}" --color=always --pager=never \ 58 | --line-range=$FIRST:$LAST --highlight-line=$CENTER "$FILE" 59 | exit $? 60 | fi 61 | 62 | DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}" 63 | CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND} 64 | CMD=${CMD//{\}/$(printf %q "$FILE")} 65 | 66 | eval "$CMD" 2> /dev/null | awk "NR >= $FIRST && NR <= $LAST { \ 67 | if (NR == $CENTER) \ 68 | { gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \ 69 | else printf(\"$RESET%s\n\", \$0); \ 70 | }" 71 | -------------------------------------------------------------------------------- /karabiner/README.md: -------------------------------------------------------------------------------- 1 | First, install Karabiner elements 2 | 3 | Then `./dotty install` should move the config in place. You can also do it manually: 4 | `mv ~/.config/karabiner/karabiner.json ~/.config/karabiner/karabiner.old.json` 5 | `cp config/karabiner/karabiner.json ~/.config/karabiner/karabiner.json` 6 | 7 | # Simple modifications 8 | 9 | The above should set up the simple modifications: 10 | 11 | `right_command` -> `escape` 12 | `caps_lock` -> `left_control` 13 | `semicolon` -> `return_or_enter` 14 | `return_or_enter` -> `semicolon` 15 | 16 | 17 | 18 | # Complex modifications 19 | 20 | At a terminal, do: 21 | 22 | `open karabiner://karabiner/assets/complex_modifications/import?url=https://raw.githubusercontent.com/wuthefwasthat/dotfiles/master/karabiner/karabiner_settings.json` 23 | 24 | Or if cloned: 25 | 26 | `open karabiner://karabiner/assets/complex_modifications/import?url=file:///Users/jeffwu/dotfiles/karabiner/karabiner_settings.json` 27 | 28 | This will install a number of useful modifications, of which you can enable any subset. 29 | (replace `master` with a git hash if you want. You can also just open the link directly in Chrome). 30 | 31 | NOTE: See [here](https://pqrs.org/osx/karabiner/complex_modifications/) for some other example complex modifications. 32 | 33 | ## Vim mode 34 | 35 | Hold down `;` for vim mode 36 | 37 | `hjkl`: arrows 38 | `a` + `hjkl`: fast mouse move 39 | `s` + `hjkl`: fast mouse move 40 | `d` + `hjkl`: fast scroll 41 | `d` + `s` + `hjkl`: slow scroll 42 | 43 | `u` or `f`: left click 44 | `i` or `v`: middle click 45 | `o` or `F` or `g`: right click 46 | 47 | ## Better backspace 48 | 49 | Ctrl+Space = Backspace 50 | 51 | (assumes you have caps lock mapped to left_control) 52 | 53 | ## Better caps 54 | 55 | Caps lock = left control, or esc if alone 56 | 57 | ## Better shift 58 | 59 | Shift = parentheses if alone 60 | -------------------------------------------------------------------------------- /zshrc_scripts/fasd.fzf.zsh: -------------------------------------------------------------------------------- 1 | # SEE here for more info: https://github.com/clvv/fasd 2 | eval "$(fasd --init auto)" 3 | 4 | [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh 5 | # needed sometimes? 6 | # source $(brew --prefix)/Cellar/fzf/$(fzf --version | cut -d ' ' -f 1)/shell/key-bindings.zsh 7 | 8 | export FZF_CTRL_R_OPTS='--sort --exact' 9 | 10 | # alias a='fasd -a' # any 11 | # alias s='fasd -si' # show / search / select 12 | # alias d='fasd -d' # directory 13 | # alias dd='fasd -sid' # interactive directory selection 14 | dd() { 15 | fasd -Rdl | fzf -m -q "$*" 16 | } 17 | # alias f='fasd -f' # file 18 | # alias ff='fasd -sif' # interactive file selection 19 | ff() { 20 | fasd -Rfl | fzf -m -q "$*" 21 | } 22 | 23 | # SEE: http://seanbowman.me/blog/fzf-fasd-and-bash-aliases/ 24 | 25 | # alias j='fasd_cd -d' 26 | j() { 27 | local dir="$(fasd -ld "$@" | tail -n 1)" 28 | [[ -d "$dir" ]] && pushd "$dir" 29 | } 30 | # complete -d j 31 | 32 | # alias jj='fasd_cd -d -i' 33 | jj() { 34 | local dir 35 | dir=$(fasd -Rdl |\ 36 | sed "s:$HOME:~:" |\ 37 | fzf +m -q "$*" |\ 38 | sed "s:~:$HOME:")\ 39 | && pushd "$dir" 40 | } 41 | # complete -d jj 42 | 43 | # quick opening files with emacs 44 | alias e='fasd -f -e "emacsclient -c"' 45 | 46 | # quick opening files with vim 47 | alias v='fasd -f -e vim' 48 | 49 | # alias v='f -t -e vim -b viminfo' 50 | 51 | vv() { 52 | local files=$(fasd -Rfl | fzf -m -q "$*") 53 | if [[ -z $files ]]; then return 1; fi 54 | vim $files 55 | } 56 | 57 | killz() { 58 | local tokill=$(ps aux | tail -n +2 | fzf -m | awk '{print $2}') 59 | 60 | echo "=== Killing the following processes ===" 61 | while read -r pid; do 62 | echo "$pid: $(ps -p $pid -o command=)" 63 | done <<< $tokill 64 | echo "=== Hit y to continue ===" 65 | read REPLY 66 | if [[ $REPLY =~ ^[Yy]$ ]] 67 | then 68 | while read -r pid; do 69 | echo "killing: $(ps -p $pid -o command=)" 70 | kill -9 $pid 71 | done <<< $tokill 72 | else 73 | echo "Aborted" 74 | fi 75 | } 76 | -------------------------------------------------------------------------------- /nvim/lua/kickstart/plugins/lint.lua: -------------------------------------------------------------------------------- 1 | return { 2 | 3 | { -- Linting 4 | 'mfussenegger/nvim-lint', 5 | event = { 'BufReadPre', 'BufNewFile' }, 6 | config = function() 7 | local lint = require 'lint' 8 | lint.linters_by_ft = { 9 | markdown = { 'markdownlint' }, 10 | } 11 | 12 | -- To allow other plugins to add linters to require('lint').linters_by_ft, 13 | -- instead set linters_by_ft like this: 14 | -- lint.linters_by_ft = lint.linters_by_ft or {} 15 | -- lint.linters_by_ft['markdown'] = { 'markdownlint' } 16 | -- 17 | -- However, note that this will enable a set of default linters, 18 | -- which will cause errors unless these tools are available: 19 | -- { 20 | -- clojure = { "clj-kondo" }, 21 | -- dockerfile = { "hadolint" }, 22 | -- inko = { "inko" }, 23 | -- janet = { "janet" }, 24 | -- json = { "jsonlint" }, 25 | -- markdown = { "vale" }, 26 | -- rst = { "vale" }, 27 | -- ruby = { "ruby" }, 28 | -- terraform = { "tflint" }, 29 | -- text = { "vale" } 30 | -- } 31 | -- 32 | -- You can disable the default linters by setting their filetypes to nil: 33 | -- lint.linters_by_ft['clojure'] = nil 34 | -- lint.linters_by_ft['dockerfile'] = nil 35 | -- lint.linters_by_ft['inko'] = nil 36 | -- lint.linters_by_ft['janet'] = nil 37 | -- lint.linters_by_ft['json'] = nil 38 | -- lint.linters_by_ft['markdown'] = nil 39 | -- lint.linters_by_ft['rst'] = nil 40 | -- lint.linters_by_ft['ruby'] = nil 41 | -- lint.linters_by_ft['terraform'] = nil 42 | -- lint.linters_by_ft['text'] = nil 43 | 44 | -- Create autocommand which carries out the actual linting 45 | -- on the specified events. 46 | local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) 47 | vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { 48 | group = lint_augroup, 49 | callback = function() 50 | lint.try_lint() 51 | end, 52 | }) 53 | end, 54 | }, 55 | } 56 | -------------------------------------------------------------------------------- /zed/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "vim_mode": true, 3 | "vim": { 4 | "use_system_clipboard": "never" 5 | }, 6 | "file_scan_exclusions": ["**/*.rst", "**/*.cu"], 7 | "features": { 8 | // Which edit prediction provider to use. 9 | "edit_prediction_provider": "copilot" 10 | }, 11 | "relative_line_numbers": true, 12 | "theme": "Night Owl Dark", 13 | "soft_wrap": "editor_width", 14 | "telemetry": { 15 | "diagnostics": false, 16 | "metrics": true 17 | }, 18 | "search": { 19 | "case_sensitive": true, 20 | "regex": false 21 | }, 22 | "assistant": { 23 | "default_model": { 24 | "provider": "anthropic", 25 | "model": "claude-3-7-sonnet-20250219" 26 | }, 27 | "inline_alternatives": [ 28 | { 29 | "provider": "anthropic", 30 | "model": "claude-3-5-sonnet-20241022" 31 | } 32 | ], 33 | "version": "2", 34 | "enable_experimental_live_diffs": true 35 | }, 36 | "language_models": { 37 | "anthropic": { 38 | "version": "1", 39 | "low_speed_timeout_in_seconds": 60, 40 | "speculate": true, 41 | "available_models": [ 42 | { 43 | "name": "claude-3-5-sonnet-20241022", 44 | "max_tokens": 200000, 45 | "max_output_tokens": 8192, 46 | "cache_configuration": { 47 | "max_cache_anchors": 4, 48 | "should_speculate": true, 49 | "min_total_token": 2048 50 | }, 51 | "display_name": "Claude Sonnet 3.5" 52 | } 53 | ] 54 | } 55 | }, 56 | "auto_install_extensions": { 57 | "html": true, 58 | "python-refactoring": true 59 | }, 60 | "languages": { 61 | "Python": { 62 | "language_servers": ["pyright", "python-refactoring", "ruff"] 63 | }, 64 | "YAML": { 65 | "format_on_save": "off" 66 | } 67 | }, 68 | "lsp": { 69 | "pyright": { 70 | "settings": { 71 | "python.analysis": { 72 | "diagnosticMode": "openFilesOnly", 73 | "typeCheckingMode": "strict" 74 | }, 75 | "python": { 76 | "pythonPath": "/opt/homebrew/Caskroom/miniforge/base/envs/py311/bin/python" 77 | } 78 | } 79 | } 80 | }, 81 | "languages.Python.language_servers": [ 82 | "pyright", 83 | "python-refactoring", 84 | "!pylsp", 85 | "ruff" 86 | ] 87 | } 88 | -------------------------------------------------------------------------------- /monkey_scripts/youtube.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Youtube-mini-fullscreen 3 | // @namespace wuthefwasthat 4 | // @version 0.1 5 | // @description Youtube mini-fullscreen 6 | // @match *://www.youtube.com/watch* 7 | // @copyright 2017+, You 8 | // @grant none 9 | // ==/UserScript== 10 | 11 | function addStyle(style_str, id) { 12 | var el = document.createElement('style'); 13 | el.type = "text/css"; 14 | if (id) el.id = id; 15 | if (el.styleSheet) { el.styleSheet.cssText = str; } // IE only 16 | else { el.appendChild(document.createTextNode(style_str)); } 17 | document.head.appendChild(el); 18 | } 19 | 20 | // TODO: make this work for all widths 21 | function toggleCustomStyle() { 22 | const styleElemId = 'yt-custom-style'; 23 | const styleEl = document.getElementById(styleElemId); 24 | if (styleEl) { 25 | styleEl.parentNode.removeChild(styleEl); 26 | } else { 27 | addStyle(` 28 | .html5-video-player.playing-mode { 29 | position: fixed; 30 | left: 0; 31 | bottom: 0px; 32 | } 33 | .playing-mode .html5-video-container { 34 | width: 100% !important; 35 | height: 100% !important; 36 | } 37 | .playing-mode .html5-main-video { 38 | width: 100% !important; 39 | height: 100% !important; 40 | left: 0px !important; 41 | } 42 | #masthead-positioner { 43 | z-index: 0 !important; 44 | } 45 | #container { 46 | display: none; 47 | } 48 | #main { 49 | display: none; 50 | } 51 | #items { 52 | display: none; 53 | } 54 | `, styleElemId); 55 | } 56 | } 57 | 58 | // toggle once by default 59 | toggleCustomStyle(); 60 | 61 | function togglePlay() { 62 | document.getElementsByClassName("ytp-play-button")[0].click(); 63 | } 64 | 65 | document.addEventListener("keydown", function(e) { 66 | var keyCode = e.keyCode; 67 | if (keyCode === 13) { // enter 68 | toggleCustomStyle(); 69 | } else if (keyCode === 0 || keyCode === 32) { // space 70 | togglePlay(); 71 | } 72 | }, false); 73 | 74 | /* 75 | function loadScript(src, callback) { 76 | var el = document.createElement('script'); 77 | el.src = src; 78 | el.onload = callback; 79 | document.head.appendChild(el); 80 | } 81 | 82 | function loadJquery(callback) { 83 | loadScript('//code.jquery.com/jquery-latest.min.js', function() { 84 | jQuery.noConflict(); 85 | callback(jQuery); 86 | }); 87 | } 88 | 89 | loadJquery(function($) { 90 | window.$ = $; 91 | }); 92 | */ 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # setup: 2 | 3 | incomplete notes 4 | all commands ran from root directory 5 | 6 | - `./dotty install` 7 | - install zsh (e.g. `brew install zsh zsh-completions` and `chsh -s /bin/zsh`) 8 | - install oh-my-zsh 9 | ``` 10 | curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -o /tmp/omz-install.sh 11 | sh /tmp/omz-install.sh --skip-chsh 12 | ``` 13 | 14 | - install zsh theme: 15 | `ln -s $(pwd)/my.zsh-theme ~/.oh-my-zsh/themes/jeffwu.zsh-theme` 16 | - overwrite zshrc: 17 | `echo "source $(pwd)/zshrc" > ~/.zshrc` 18 | 19 | - install fasd 20 | ``` 21 | cd ~; git clone https://github.com/whjvenyl/fasd.git; cd fasd; make install; mkdir -p ~/.cache 22 | ``` 23 | used to work, but no longer works `brew install fasd` (as of may 2024) 24 | 25 | - install neovim, then 26 | ``` 27 | mkdir -p $HOME/.config 28 | ln -s ~/.vim $HOME/.config/nvim 29 | # sudo pip3 install neovim 30 | sudo pip3 install pynvim 31 | ``` 32 | To clear plugins: `rm -rf ~/.local/share/nvim/ ~/.local/state/nvim ~/.cache/nvim` 33 | 34 | - install tmux (e.g. `brew install tmux`) 35 | 36 | - optional 37 | - set iterm colors, if appropriate 38 | - install git 2.3+ 39 | - install hub (git wrapper) `brew install hub` 40 | - for `git pr`, do: 41 | - https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ 42 | - Then add to `~/.config/hub`: 43 | ``` 44 | --- 45 | github.com: 46 | - protocol: https 47 | user: jeffwu 48 | oauth_token: YOURTOKEN 49 | ``` 50 | - also put that token in a file at `~/.github_token` for some of my git aliases to work 51 | - install thefuck (https://github.com/nvbn/thefuck) (e.g. `brew install thefuck`) 52 | - install icdiff, change gitconfig differ 53 | - very optional: 54 | - install spacemacs: 55 | `git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d` 56 | - install [fnm](https://github.com/Schniz/fnm#shell-setup) 57 | `brew install fnm` 58 | - install latex 59 | `brew cask install mactex` 60 | 61 | - OLD 62 | - make sure vim is 7.4+, preferably 8+ (e.g. `brew install vim`) 63 | - install vim plugins: `vim +PlugInstall +qall` 64 | - this should install fzf (if not, do e.g. `brew install fzf`) 65 | - install `Ag` (https://github.com/ggreer/the_silver_searcher): 66 | - `brew install the_silver_searcher` 67 | 68 | # TODO 69 | - try pv (pipeviewer)? like command line tqdm 70 | - try https://github.com/eradman/entr instead of watch 71 | -------------------------------------------------------------------------------- /vscode.jsonc: -------------------------------------------------------------------------------- 1 | // notes: command shift P, search for "Preferences: Open settings (JSON)" 2 | { 3 | "vim.leader": "", 4 | "vim.insertModeKeyBindingsNonRecursive": [ 5 | ], 6 | "vim.normalModeKeyBindingsNonRecursive": [ 7 | // https://code.visualstudio.com/docs/getstarted/keybindings 8 | // TODO: find definitive version 9 | { 10 | "before": ["", "q", "q"], 11 | "commands": ["workbench.action.closeWindow"] 12 | }, 13 | { 14 | "before": ["", "w", "c"], 15 | "commands": ["workbench.action.closeEditorsInGroup"] 16 | }, 17 | { 18 | "before": ["", "w", "v"], 19 | "commands": ["workbench.action.splitEditor"] 20 | }, 21 | { 22 | "before": ["", "f", "s"], 23 | "commands": ["workbench.action.files.save"] 24 | }, 25 | { 26 | "before": ["", "e", "n"], 27 | "commands": ["editor.action.marker.nextInFiles"] 28 | }, 29 | { 30 | "before": ["", "e", "p"], 31 | "commands": ["editor.action.marker.prevInFiles"] 32 | }, 33 | // { 34 | // "before": ["", "b", "b"], 35 | // "commands": ["workbench.action.navigateEditorGroups"] 36 | // }, 37 | { 38 | "before": ["", "b", "d"], 39 | "commands": ["workbench.action.closeActiveEditor"] 40 | }, 41 | { 42 | "before": ["", "b", "n"], 43 | "commands": ["workbench.action.nextEditor"] 44 | }, 45 | { 46 | "before": ["", "b", "p"], 47 | "commands": ["workbench.action.previousEditor"] 48 | }, 49 | { 50 | "before": [""], 51 | "commands": ["editor.action.clipboardCopyAction"] 52 | }, 53 | { 54 | "before": ["g", "o"], 55 | "commands": ["workbench.action.quickOpen"] 56 | }, 57 | { 58 | "before": [""], 59 | "after": ["", "h"] 60 | }, 61 | { 62 | "before": [""], 63 | "after": ["", "j"] 64 | }, 65 | { 66 | "before": [""], 67 | "after": ["", "k"] 68 | }, 69 | { 70 | "before": [""], 71 | "after": ["", "l"] 72 | }, 73 | { 74 | "before": ["", "r", "l"], "after": [], 75 | "commands": [ {"command": "runInTerminal.run", "args": {"name": "l"}} ] 76 | }, 77 | ], 78 | "editor.tabSize": 4, 79 | "editor.cursorStyle": "line", 80 | "editor.insertSpaces": true, 81 | "editor.lineNumbers": "on", 82 | "editor.wordWrap": "off", 83 | "github.copilot.advanced": { 84 | "debug.forceUseEarhartModel": true, 85 | "secret_key": "REDACTED" 86 | }, 87 | "copilot.enabled": { 88 | "python": false 89 | }, 90 | } 91 | -------------------------------------------------------------------------------- /nvim/lua/kickstart/plugins/gitsigns.lua: -------------------------------------------------------------------------------- 1 | -- Adds git related signs to the gutter, as well as utilities for managing changes 2 | -- NOTE: gitsigns is already included in init.lua but contains only the base 3 | -- config. This will add also the recommended keymaps. 4 | 5 | return { 6 | { 7 | 'lewis6991/gitsigns.nvim', 8 | opts = { 9 | on_attach = function(bufnr) 10 | local gitsigns = require 'gitsigns' 11 | 12 | local function map(mode, l, r, opts) 13 | opts = opts or {} 14 | opts.buffer = bufnr 15 | vim.keymap.set(mode, l, r, opts) 16 | end 17 | 18 | -- Navigation 19 | map('n', ']c', function() 20 | if vim.wo.diff then 21 | vim.cmd.normal { ']c', bang = true } 22 | else 23 | gitsigns.nav_hunk 'next' 24 | end 25 | end, { desc = 'Jump to next git [c]hange' }) 26 | 27 | map('n', '[c', function() 28 | if vim.wo.diff then 29 | vim.cmd.normal { '[c', bang = true } 30 | else 31 | gitsigns.nav_hunk 'prev' 32 | end 33 | end, { desc = 'Jump to previous git [c]hange' }) 34 | 35 | -- Actions 36 | -- visual mode 37 | map('v', 'hs', function() 38 | gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } 39 | end, { desc = 'stage git hunk' }) 40 | map('v', 'hr', function() 41 | gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } 42 | end, { desc = 'reset git hunk' }) 43 | -- normal mode 44 | map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) 45 | map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) 46 | map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) 47 | map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) 48 | map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) 49 | map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) 50 | map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) 51 | map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) 52 | map('n', 'hD', function() 53 | gitsigns.diffthis '@' 54 | end, { desc = 'git [D]iff against last commit' }) 55 | -- Toggles 56 | map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) 57 | map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) 58 | end, 59 | }, 60 | }, 61 | } 62 | -------------------------------------------------------------------------------- /ublock_filters: -------------------------------------------------------------------------------- 1 | ! 10/18/2017, 9:40:41 PM https://www.wsj.com/articles/protecting-against-ais-existential-threat-1508332313 2 | www.wsj.com###trending_now > .zonedModule > .trending_now.module > .trending_videos 3 | 4 | ! 10/18/2017, 9:40:51 PM https://www.wsj.com/articles/protecting-against-ais-existential-threat-1508332313 5 | www.wsj.com###trending_now > .zonedModule > .trending_now.module > .trending_articles 6 | 7 | ! 10/22/2017, 2:04:26 PM https://go.twitch.tv/DreamHackSmash 8 | go.twitch.tv##.relative.flex-nowrap.flex-grow-1.flex-column.flex.overflow-hidden.full-height.chat__pane 9 | 10 | ! 10/22/2017, 2:09:39 PM https://go.twitch.tv/DreamHackSmash 11 | go.twitch.tv##.pd-2.mg-b-2.full-width.c-background.border--marked.border-b.border-r.border-t.channel-login-upsell 12 | 13 | ! 10/22/2017, 2:10:01 PM https://go.twitch.tv/DreamHackSmash 14 | go.twitch.tv##.ps--theme_twitch-side-nav.ps.flex-grow-1.full-width.side-nav__scrollable 15 | 16 | ! 11/3/2017, 6:26:35 PM https://go.twitch.tv/beyondthesummit 17 | go.twitch.tv##.channel-panels-container 18 | 19 | ! 1/24/2018, 10:03:37 PM https://uk.news.yahoo.com/kawhi-leonard-wants-leave-san-191039119.html 20 | uk.news.yahoo.com###YDC-Col2-Stack 21 | 22 | ! 1/25/2018, 11:18:52 PM https://www.washingtonpost.com/news/early-lead/wp/2018/01/25/lebron-james-drafted-a-much-better-all-star-team-than-stephen-curry-says-everyone/?utm_term=.2fafc673e416 23 | www.washingtonpost.com##.content-strip 24 | 25 | ! 2/2/2018, 4:24:10 PM http://www.bbc.com/news/world-latin-america-42916261 26 | www.bbc.com##.column--secondary 27 | 28 | ! 2/16/2018, 5:06:01 PM https://motherboard.vice.com/en_us/article/mb53jn/fcc-inspector-general-investigation-ajit-pai-corruption 29 | motherboard.vice.com##.p-3-xs.up-next--visible.up-next 30 | 31 | ! 2/16/2018, 5:06:27 PM https://motherboard.vice.com/en_us/article/mb53jn/fcc-inspector-general-investigation-ajit-pai-corruption 32 | motherboard.vice.com###article_5a85bc37b3e6197d537b9e83 > .short-form-article > .short-form-article__bounding-box > .m-r-0-xl.m-l-0-xl.m-r-aut-xs.m-l-aut-xs.short-form-article__body > .short-form-article__body__content > .m-b-6-xs.gutter > .col-12-xs.gutter__content > .col-12-xs.related__video 33 | 34 | ! 6/9/2018, 9:54:31 PM https://www.netflix.com/browse 35 | ||occ-0-1885-2794.1.nflxso.net/art/ffd11/e07842f601137572c9fa75c5e37523535d9ffd11.jpg$image 36 | 37 | ! 8/5/2018, 7:57:22 PM https://www.cnet.com/news/an-ai-just-smashed-humans-beings-at-dota-2-open-ai-twitch/ 38 | www.cnet.com##.uvpjs__controlbar 39 | 40 | ! 8/5/2018, 7:57:37 PM https://www.cnet.com/news/an-ai-just-smashed-humans-beings-at-dota-2-open-ai-twitch/ 41 | www.cnet.com##.entered.dock.inviewElement 42 | 43 | ! 8/7/2018, 11:02:31 AM https://gizmodo.com/facebook-wanted-us-to-kill-this-investigative-tool-1826620111 44 | gizmodo.com##.sidebar 45 | 46 | -------------------------------------------------------------------------------- /zed/tasks.json: -------------------------------------------------------------------------------- 1 | // Static tasks configuration. 2 | // 3 | // Example: 4 | [ 5 | { 6 | "label": "task debug", 7 | "command": "echo ${ZED_SELECTED_TEXT:-}; echo ${ZED_WORKTREE_ROOT};", 8 | "env": {}, 9 | "cwd": "${ZED_WORKTREE_ROOT}", 10 | "allow_concurrent_runs": false, 11 | "use_new_terminal": true, 12 | "reveal": "always", 13 | "hide": "never" 14 | }, 15 | { 16 | "label": "pytest:current_file", 17 | "command": "pytest -vsx $ZED_FILE", 18 | //"args": [], 19 | // Env overrides for the command, will be appended to the terminal's environment from the settings. 20 | "env": {}, 21 | // Current working directory to spawn the command into, defaults to current project root. 22 | // "cwd": "/path/to/working/directory", 23 | // Whether to use a new terminal tab or reuse the existing one to spawn the process, defaults to `false`. 24 | "use_new_terminal": false, 25 | // Whether to allow multiple instances of the same task to be run, or rather wait for the existing ones to finish, defaults to `false`. 26 | "allow_concurrent_runs": false, 27 | // What to do with the terminal pane and tab, after the command was started: 28 | // * `always` — always show the terminal pane, add and focus the corresponding task's tab in it (default) 29 | // * `never` — avoid changing current terminal pane focus, but still add/reuse the task's tab there 30 | "reveal": "always" 31 | }, 32 | { 33 | "label": "pytest:current_fn", 34 | "command": "pytest -vsx $ZED_FILE::$ZED_SYMBOL", 35 | "env": {}, 36 | "use_new_terminal": false, 37 | "allow_concurrent_runs": false, 38 | "reveal": "always" 39 | }, 40 | { 41 | "label": "pytest:loop_current_fn", 42 | "command": "osascript -e 'tell application \"iTerm2\"' -e 'tell current session of current window' -e 'write text \"python -m tputron.scripts.loop_test $ZED_FILE $ZED_SYMBOL\"' -e 'end tell' -e 'end tell' ", 43 | "env": {}, 44 | "use_new_terminal": false, 45 | "allow_concurrent_runs": false, 46 | "reveal": "never" 47 | }, 48 | { 49 | "label": "search:project", 50 | "command": "QUERY=${ZED_SELECTED_TEXT:-}; FILE=$(rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob '!**/.git/' '--glob' '!**/node_modules' \"$QUERY\" . | fzf --ansi --delimiter : --preview 'bat --style=numbers,changes,header --color=always --highlight-line {2} {1}' --preview-window 'up:60%:+{2}+3/3' --layout=reverse --query \"$QUERY\" --print-query | tail -1); if [ -n \"$FILE\" ]; then LINE=$(echo $FILE | cut -d':' -f2); COL=$(echo $FILE | cut -d':' -f3); FILE=$(echo $FILE | cut -d':' -f1); coo zed -p $FILE:$LINE:$COL; fi", 51 | "env": {}, 52 | "cwd": "${ZED_WORKTREE_ROOT}", 53 | "allow_concurrent_runs": false, 54 | "use_new_terminal": false, 55 | "reveal": "always", 56 | "hide": "on_success" 57 | } 58 | ] 59 | -------------------------------------------------------------------------------- /zshrc_scripts/sessions.zsh: -------------------------------------------------------------------------------- 1 | ##### 2 | # emacs stuff 3 | ##### 4 | 5 | function eml { 6 | ps aux | grep 'emacs --daemon' | grep -v grep 7 | } 8 | 9 | function ems { 10 | local name=$1 11 | if [ -n "$name" ]; then 12 | emacs --daemon=$name 13 | else 14 | emacs --daemon 15 | fi 16 | } 17 | 18 | function emx { 19 | local name=$1 20 | shift 21 | if [ -n "$name" ]; then 22 | emacsclient -nw -c -s $name $@ 23 | else 24 | emacsclient -nw -c $@ 25 | fi 26 | } 27 | 28 | function emk { 29 | local name=$1 30 | if [ -n "$name" ]; then 31 | line=$(ps aux | grep "emacs --daemon=$name" | grep -v grep | head -n 1) 32 | else 33 | line=$(ps aux | grep 'emacs --daemon$' | grep -v grep | head -n 1) 34 | fi 35 | pid=$(echo $line | awk '{ print $2 }') 36 | kill $pid 37 | } 38 | 39 | function emr { 40 | local name=$1 41 | emk $name 42 | ems $name 43 | } 44 | 45 | function em { 46 | sessionname=$(sname) 47 | 48 | if [ -n "$sessionname" ]; then 49 | emx $sessionname $@ 50 | else 51 | emx '' $@ 52 | fi 53 | } 54 | 55 | ################################################################################ 56 | # session management (via gnu screen or tmux) 57 | ################################################################################ 58 | 59 | use_tmux=true 60 | 61 | function sname { # get session name 62 | if [ "$use_tmux" = true ] ; then 63 | if [ -n "$TMUX" ] ; then 64 | tmux display-message -p '#S' 65 | fi 66 | else 67 | echo $STY | cut -d '.' -f 2 68 | fi 69 | } 70 | 71 | function sx { # attach to session 72 | local sessionname=$1 73 | if [ "$use_tmux" = true ] ; then 74 | tmux a -t $sessionname 75 | else 76 | screen -x $sessionname 77 | fi 78 | } 79 | 80 | function sl { # list sessions 81 | if [ "$use_tmux" = true ] ; then 82 | tmux ls 83 | else 84 | screen -ls 85 | fi 86 | } 87 | 88 | function ss { # start session 89 | local sessionname=$1 90 | if [ -z "$sessionname" ]; then 91 | echo "Please give your session a name!" 92 | return 1 93 | fi 94 | # start corresponding emacs daemon 95 | # NOTE: ems doesn't work here, not sure why 96 | # nohup emacs --daemon=$sessionname &>/dev/null & 97 | 98 | if [ "$use_tmux" = true ] ; then 99 | tmux new -s $sessionname 100 | else 101 | screen -S $sessionname 102 | fi 103 | } 104 | 105 | function sk { # kill session 106 | # default to killing current session 107 | local sessionname=${1:-$(sname)} 108 | if [ -z "$sessionname" ]; then 109 | sl 110 | echo "Must specifiy which session to kill!" 111 | return 1 112 | fi 113 | # kill corresponding emacs session 114 | # emk $sessionname 115 | 116 | if [ "$use_tmux" = true ] ; then 117 | tmux kill-session -t $sessionname 118 | else 119 | screen -S $sessionname -X quit 120 | fi 121 | } 122 | -------------------------------------------------------------------------------- /clipy-snippets.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js 5 | 6 | 7 | add jquery 8 | function addScript(url) { 9 | var s = document.createElement("script"); 10 | s.type = "text/javascript"; 11 | s.src = url; 12 | document.head.appendChild(s); 13 | } 14 | 15 | addScript("https://code.jquery.com/jquery-3.3.1.min.js"); 16 | 17 | 18 | 19 | 20 | py 21 | 22 | 23 | ipdb 24 | import ipdb; ipdb.set_trace() 25 | 26 | 27 | tfsimple 28 | import tensorflow as tf 29 | 30 | a = tf.Variable(dtype=tf.float32, initial_value=tf.zeros([1])) 31 | b = tf.placeholder(dtype=tf.int32, shape=[None]) 32 | c = tf.constant([[0.0, 1.0], [1.0, 1.0]]) 33 | sess = tf.Session() 34 | sess.__enter__() 35 | # sess.run(tf.initialize_all_variables()) 36 | # print(sess.run(a)) 37 | 38 | 39 | tfgraph 40 | import tensorflow as tf 41 | 42 | with tf.Graph().as_default() as g: 43 | with tf.Session() as sess: 44 | a = tf.Variable(dtype=tf.float32, initial_value=tf.zeros([1])) 45 | b = tf.placeholder(dtype=tf.int32, shape=[None]) 46 | c = tf.constant([[0.0, 1.0], [1.0, 1.0]]) 47 | # sess.run(tf.initialize_all_variables()) 48 | # print(sess.run(a)) 49 | 50 | 51 | tftimeline 52 | # add additional options to trace the session execution 53 | options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE) 54 | run_metadata = tf.RunMetadata() 55 | sess.run(res, options=options, run_metadata=run_metadata) 56 | 57 | # Create the Timeline object, and write it to a json file 58 | fetched_timeline = timeline.Timeline(run_metadata.step_stats) 59 | chrome_trace = fetched_timeline.generate_chrome_trace_format() 60 | with open('timeline_01.json', 'w') as f: 61 | f.write(chrome_trace) 62 | 63 | 64 | tfeager 65 | import tensorflow as tf 66 | tf.enable_eager_execution() 67 | 68 | 69 | torch-print 70 | def printr(name, tensor): 71 | import torch.distributed as dist 72 | print(f'[{dist.get_rank()}] {name} \n {tensor.cpu().detach().numpy()}\n') 73 | 74 | 75 | 76 | 77 | bash 78 | 79 | 80 | tee stderr+stdout 81 | 2>&1 | tee 82 | 83 | 84 | date 85 | date +%Y-%m-%d-%H-%M 86 | 87 | 88 | 89 | 90 | openai 91 | 92 | 93 | datestr 94 | $(date +%y%m%d%H%M) 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /my.zsh-theme: -------------------------------------------------------------------------------- 1 | autoload -Uz vcs_info 2 | 3 | red="$FG[001]" 4 | green="$FG[002]" 5 | yellow="$FG[003]" 6 | 7 | zstyle ':vcs_info:*' enable git 8 | zstyle ':vcs_info:git*:*' get-revision true 9 | zstyle ':vcs_info:git*:*' check-for-changes true 10 | 11 | 12 | zstyle ':vcs_info:git:*' stagedstr "${yellow}✘" 13 | zstyle ':vcs_info:git:*' unstagedstr "${red}✘" 14 | 15 | # hash changes branch misc 16 | zstyle ':vcs_info:git*' formats "(%s) %b%m %7.7i %c%u" 17 | zstyle ':vcs_info:git*' actionformats "(%s|%a) %b%m %7.7i %c%u" 18 | zstyle ':vcs_info:git*+set-message:*' hooks git-st 19 | main_color='%B%F{blue}' 20 | 21 | # Show remote ref name and number of commits ahead-of or behind 22 | function +vi-git-st() { 23 | local ahead behind remote 24 | local -a gitstatus 25 | 26 | # Are we on a remote-tracking branch? 27 | remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} 28 | 29 | if [[ -n ${remote} ]] ; then 30 | # for git prior to 1.7 31 | # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l) 32 | ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l | xargs) 33 | (( $ahead )) && gitstatus+=( "${yellow}+${ahead}${main_color}" ) 34 | 35 | # for git prior to 1.7 36 | # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l) 37 | behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l | xargs) 38 | (( $behind )) && gitstatus+=( "${red}-${behind}${main_color}" ) 39 | 40 | if [ -z "$gitstatus" ]; then gitstatus+=( "${green}up-to-date${main_color}" ); fi 41 | 42 | hook_com[branch]="${hook_com[branch]} [${remote} ${(j:/:)gitstatus}]" 43 | fi 44 | } 45 | 46 | function theme_preexec() { 47 | # set time of start of command 48 | timer=${timer:-$SECONDS} 49 | } 50 | 51 | theme_precmd () { 52 | # http://eseth.org/2010/git-in-zsh.html 53 | vcs_info 54 | 55 | # display time it took for last command to execute 56 | if [ $timer ]; then 57 | time_seconds=$(($SECONDS - $timer)) 58 | unset timer 59 | ret_result="%(?:%{$fg_bold[green]%}✔:%{$fg_bold[red]%}✘)%(?,, %{${fg_bold[red]}%}[%?]) ${time_seconds}s%{$reset_color%} 60 | " 61 | else 62 | ret_result="" 63 | fi 64 | } 65 | 66 | # useful chars: » ● ✔ ✘ 67 | setopt prompt_subst 68 | 69 | if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] || [ -n "$SSH_CONNECTION" ]; then 70 | # if [[ "$(uname)" != "Darwin" ]]; then 71 | PROMPT_SHOW_HOSTNAME=true 72 | fi 73 | 74 | if [ -n "$PROMPT_SHOW_HOSTNAME" ]; then 75 | PROMPT_MACHINE="%B%F{green}$(hostname) " 76 | else 77 | PROMPT_MACHINE="" 78 | fi 79 | PROMPT=$'${ret_result}$PROMPT_MACHINE%B%F{blue}%c${CUSTOM_PROMPT}%{$reset_color%} %B%F{blue}#%{$reset_color%} ' 80 | VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}" 81 | RPROMPT='${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} %B%F{blue}${vcs_info_msg_0_}%{$reset_color%} [%D{%L:%M:%S %p}]' 82 | 83 | # to update time: 84 | # TMOUT=1 85 | # TRAPALRM() { 86 | # # don't reset prompt if a command is being typed, since copy/paste becomes impossible 87 | # if [ -z "$BUFFER" ]; then 88 | # zle reset-prompt 89 | # fi 90 | # } 91 | 92 | # add vim prompt, see: https://dougblack.io/words/zsh-vi-mode.html 93 | function zle-line-init zle-keymap-select { 94 | zle reset-prompt 95 | } 96 | zle -N zle-line-init 97 | zle -N zle-keymap-select 98 | 99 | autoload -U add-zsh-hook 100 | add-zsh-hook precmd theme_precmd 101 | add-zsh-hook preexec theme_preexec 102 | -------------------------------------------------------------------------------- /vimperator/plugin/wasavi_mediator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * wasavi mediator: ensure running wasavi on environment of Firefox + vimperator. 3 | * this plugin for vimperator is a part of wasavi . 4 | * ============================================================================= 5 | * 6 | * @author akahuku@gmail.com 7 | */ 8 | /** 9 | * Copyright 2012-2015 akahuku, akahuku@gmail.com 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | (function () { 25 | // consts 26 | var OUTPUT_LOG = false; 27 | var TARGET_URL_HTTP = 'http://wasavi.appsweets.net/'; 28 | var TARGET_URL_HTTPS = 'https://ss1.xrea.com/wasavi.appsweets.net/'; 29 | var TARGET_IFRAME = 'body>iframe[src="about:blank?wasavi-frame-source"]'; 30 | var DELAY_MSECS = 250; 31 | 32 | // privates 33 | var delayTimer = null; 34 | var initialized = false; 35 | 36 | function log (message) { 37 | OUTPUT_LOG && liberator.log('wasavi_mediator: ' + message, 0); 38 | } 39 | 40 | function toBracket (obj) { 41 | return Object.prototype.toString.call(obj); 42 | } 43 | 44 | function getWindow () { 45 | return window.content instanceof Window ? window.content : null; 46 | } 47 | 48 | function isWasaviExists (wnd) { 49 | if (!(wnd.document instanceof HTMLDocument)) return; 50 | 51 | if (wnd.location.href == TARGET_URL_HTTP 52 | || wnd.location.href == TARGET_URL_HTTPS) { 53 | return true; 54 | } 55 | 56 | return !!wnd.document.querySelector(TARGET_IFRAME); 57 | } 58 | 59 | function registerEvents (wnd) { 60 | if (!(wnd.document instanceof HTMLDocument)) return; 61 | wnd.document.addEventListener('WasaviStarted', wasaviStarted, false); 62 | wnd.document.addEventListener('WasaviTerminated', wasaviTerminated, false); 63 | return true; 64 | } 65 | 66 | function suspend () { 67 | liberator.modules.modes.passAllKeys = true; 68 | log('vimp passAllKeys set to ' + liberator.modules.modes.passAllKeys); 69 | } 70 | 71 | function resume () { 72 | liberator.modules.modes.passAllKeys = false; 73 | log('vimp passAllKeys set to ' + liberator.modules.modes.passAllKeys); 74 | } 75 | 76 | // event handlers 77 | function locationChange () { 78 | delayTimer && clearTimeout(delayTimer); 79 | delayTimer = setTimeout(function () { 80 | delayTimer = null; 81 | var wnd = getWindow(); 82 | if (wnd) { 83 | if (isWasaviExists(wnd)) { 84 | log('vimperator is in suspend state on ' + wnd.location.href); 85 | suspend(); 86 | } 87 | if (registerEvents(wnd)) { 88 | log('registered custom events'); 89 | return; 90 | } 91 | } 92 | log('failed: ' + toBracket(wnd)); 93 | }, DELAY_MSECS); 94 | } 95 | 96 | function wasaviStarted (e) { 97 | log('catched wasavi launching'); 98 | suspend(); 99 | } 100 | 101 | function wasaviTerminated (e) { 102 | log('catched wasavi termination'); 103 | resume(); 104 | } 105 | 106 | // 107 | if (!initialized) { 108 | liberator.modules.autocommands.add('LocationChange', /^/, locationChange); 109 | initialized = true; 110 | log('registered the wasavi mediator.'); 111 | } 112 | 113 | })(); 114 | 115 | // vim:set ts=4 sw=4 fileencoding=UTF-8 fileformat=unix filetype=javascript : 116 | -------------------------------------------------------------------------------- /zshrc: -------------------------------------------------------------------------------- 1 | # Path to your oh-my-zsh installation. 2 | export ZSH=$HOME/.oh-my-zsh 3 | 4 | # Set name of the theme to load. 5 | # Look in ~/.oh-my-zsh/themes/ 6 | # Optionally, if you set this to "random", it'll load a random theme each 7 | # time that oh-my-zsh is loaded. 8 | ZSH_THEME="jeffwu" 9 | 10 | # Uncomment the following line to use case-sensitive completion. 11 | # CASE_SENSITIVE="true" 12 | 13 | # Uncomment the following line to use hyphen-insensitive completion. Case 14 | # sensitive completion must be off. _ and - will be interchangeable. 15 | # HYPHEN_INSENSITIVE="true" 16 | 17 | # Uncomment the following line to disable bi-weekly auto-update checks. 18 | # DISABLE_AUTO_UPDATE="true" 19 | 20 | # Uncomment the following line to change how often to auto-update (in days). 21 | # export UPDATE_ZSH_DAYS=13 22 | 23 | # Uncomment the following line to disable colors in ls. 24 | # DISABLE_LS_COLORS="true" 25 | 26 | # Uncomment the following line to disable auto-setting terminal title. 27 | # DISABLE_AUTO_TITLE="true" 28 | 29 | # Uncomment the following line to enable command auto-correction. 30 | # ENABLE_CORRECTION="true" 31 | 32 | # Uncomment the following line to display red dots whilst waiting for completion. 33 | # COMPLETION_WAITING_DOTS="true" 34 | 35 | # Uncomment the following line if you want to disable marking untracked files 36 | # under VCS as dirty. This makes repository status check for large repositories 37 | # much, much faster. 38 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 39 | 40 | # Uncomment the following line if you want to change the command execution time 41 | # stamp shown in the history command output. 42 | # The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 43 | # HIST_STAMPS="mm/dd/yyyy" 44 | 45 | # Would you like to use another custom folder than $ZSH/custom? 46 | # ZSH_CUSTOM=/path/to/new-custom-folder 47 | 48 | # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) 49 | # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ 50 | # Example format: plugins=(rails git textmate ruby lighthouse) 51 | # Add wisely, as too many plugins slow down shell startup. 52 | plugins=(git extract macos) 53 | 54 | # User configuration 55 | 56 | # export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" 57 | # export MANPATH="/usr/local/man:$MANPATH" 58 | 59 | # automatically upgrade 60 | export DISABLE_UPDATE_PROMPT=true 61 | source $ZSH/oh-my-zsh.sh 62 | 63 | # You may need to manually set your language environment 64 | # export LANG=en_US.UTF-8 65 | 66 | export VISUAL='vim' 67 | export EDITOR='vim' 68 | 69 | # ffuuuuu 70 | if which thefuck &>/dev/null; then 71 | eval "$(thefuck --alias fu)" 72 | fi 73 | 74 | if which nvim &>/dev/null; then 75 | alias vim="nvim" 76 | fi 77 | 78 | 79 | export PATH=$PATH:/Library/TeX/texbin 80 | export PATH=$PATH:~/.multirust/toolchains/stable/cargo/bin 81 | export PATH=$PATH:~/.multirust/toolchains/1.5.0/cargo/bin 82 | export PATH=$PATH:~/.cargo/bin 83 | export PATH=$PATH:~/Library/Haskell/bin 84 | export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin/ 85 | export PATH=$PATH:$HOME/.yarn/bin 86 | if [[ "$OSTYPE" == "darwin"* ]] && command -v brew >/dev/null 2>&1; then 87 | export PATH="$(brew --prefix)/bin:$PATH" 88 | export PATH="/usr/local/opt/ruby@3.2/bin:$PATH" 89 | # export PATH="/usr/local/opt/ruby/bin:$PATH" 90 | fi 91 | export RUST_BACKTRACE=1 92 | 93 | for file in ~/.zshrc_scripts/*; do 94 | source "$file" 95 | done 96 | alias w='watchcmd' 97 | 98 | # SEE: https://babushk.in/posts/renew-environment-tmux.html 99 | # NOTE: causes issues with prompt display in mosh 100 | # function preexec { 101 | # if [ -n "$TMUX" ]; then 102 | # export $(tmux show-environment | grep "^SSH_AUTH_SOCK") 103 | # export $(tmux show-environment | grep "^DISPLAY") 104 | # fi 105 | # } 106 | 107 | if which fnm &>/dev/null; then 108 | eval "$(fnm env --use-on-cd)" 109 | fi 110 | 111 | -------------------------------------------------------------------------------- /vimperator/plugin/smoozy.js: -------------------------------------------------------------------------------- 1 | // smoozy.js 2 | // 3 | // LICENSE: 4 | // Copyright (c) 2009 snaka 5 | // Copyright (c) 2011 yuttie 6 | // 7 | // distributable under the terms of MIT license. 8 | // http://opensource.org/licenses/mit-license.php 9 | // 10 | 11 | liberator.plugins.smoozy = (function() { 12 | mappings.addUserMap( 13 | [modes.NORMAL], 14 | ["j", ""], 15 | "Smooth scroll down", 16 | function(count){ 17 | smoothScrollBy(getScrollImpulse() * (count || 1)); 18 | }, 19 | { 20 | count: true 21 | } 22 | ); 23 | mappings.addUserMap( 24 | [modes.NORMAL], 25 | ["k", ""], 26 | "Smooth scroll up", 27 | function(count){ 28 | smoothScrollBy(getScrollImpulse() * -(count || 1)); 29 | }, 30 | { 31 | count: true 32 | } 33 | ); 34 | mappings.addUserMap( 35 | [modes.NORMAL], 36 | ["", ""], 37 | "Smooth scroll down", 38 | function(count){ 39 | smoothScrollBy(2 * getScrollImpulse() * (count || 1)); 40 | }, 41 | { 42 | count: true 43 | } 44 | ); 45 | mappings.addUserMap( 46 | [modes.NORMAL], 47 | ["", ""], 48 | "Smooth scroll up", 49 | function(count){ 50 | smoothScrollBy(2 * getScrollImpulse() * -(count || 1)); 51 | }, 52 | { 53 | count: true 54 | } 55 | ); 56 | var PUBLICS = { 57 | } 58 | 59 | function getScrollImpulse() { return window.eval(liberator.globalVariables.smoozy_scroll_impulse || '1000'); } 60 | function getScrollInterval() { return window.eval(liberator.globalVariables.smoozy_scroll_interval || '16.67'); } 61 | function getScrollFriction() { return window.eval(liberator.globalVariables.smoozy_scroll_friction || '5000'); } 62 | function getScrollAirDrag() { return window.eval(liberator.globalVariables.smoozy_scroll_air_drag || '4'); } 63 | function smoothScrollBy(impulse) { 64 | win = Buffer.findScrollableWindow(); 65 | applyImpulse(impulse, win); 66 | } 67 | 68 | function applyImpulse(impulse, win) { 69 | if (win.smoozyState) { 70 | var s = win.smoozyState; 71 | s.impulse += impulse; 72 | } 73 | else { 74 | win.smoozyState = { 75 | "impulse": impulse, 76 | "velocity": 0, 77 | "delta": 0 78 | }; 79 | 80 | // start a thread 81 | var interval = getScrollInterval(); 82 | var frictionCoef = getScrollFriction(); 83 | var airDragCoef = getScrollAirDrag(); 84 | var dt = interval / 1000; // unit conversion: ms -> s 85 | function tick() { 86 | // update the state 87 | var s = win.smoozyState; 88 | var v_sign = s.velocity === 0 ? 0 : Math.abs(s.velocity) / s.velocity; 89 | var friction = -v_sign * frictionCoef * 1; // mass is 1 90 | var airDrag = -s.velocity * airDragCoef; 91 | var additionalForce = friction + airDrag; 92 | s.delta += s.velocity * dt; 93 | s.velocity += s.impulse + (Math.abs(additionalForce * dt) > Math.abs(s.velocity) ? -s.velocity : additionalForce * dt); 94 | s.impulse = 0; 95 | 96 | // scroll 97 | var intDelta = s.delta >= 0 ? Math.floor(s.delta) : Math.ceil(s.delta); 98 | s.delta -= intDelta; 99 | var posBeforeScroll = win.scrollY; 100 | win.scrollBy(0, intDelta); 101 | var posAfterScroll = win.scrollY; 102 | var reachedBound = Math.abs(posAfterScroll - posBeforeScroll) < Math.abs(intDelta); 103 | 104 | // stop the thread or continue it 105 | if (Math.abs(s.velocity) < 1 || reachedBound) { 106 | win.smoozyState = null; 107 | } 108 | else { 109 | setTimeout(tick, interval); 110 | } 111 | } 112 | setTimeout(tick, interval); 113 | } 114 | } 115 | 116 | return PUBLICS; 117 | })(); 118 | // vim: sw=2 ts=2 et si fdm=marker: 119 | -------------------------------------------------------------------------------- /nvim/lua/kickstart/plugins/debug.lua: -------------------------------------------------------------------------------- 1 | -- debug.lua 2 | -- 3 | -- Shows how to use the DAP plugin to debug your code. 4 | -- 5 | -- Primarily focused on configuring the debugger for Go, but can 6 | -- be extended to other languages as well. That's why it's called 7 | -- kickstart.nvim and not kitchen-sink.nvim ;) 8 | 9 | return { 10 | -- NOTE: Yes, you can install new plugins here! 11 | 'mfussenegger/nvim-dap', 12 | -- NOTE: And you can specify dependencies as well 13 | dependencies = { 14 | -- Creates a beautiful debugger UI 15 | 'rcarriga/nvim-dap-ui', 16 | 17 | -- Required dependency for nvim-dap-ui 18 | 'nvim-neotest/nvim-nio', 19 | 20 | -- Installs the debug adapters for you 21 | 'williamboman/mason.nvim', 22 | 'jay-babu/mason-nvim-dap.nvim', 23 | 24 | -- Add your own debuggers here 25 | 'leoluz/nvim-dap-go', 26 | }, 27 | keys = function(_, keys) 28 | local dap = require 'dap' 29 | local dapui = require 'dapui' 30 | return { 31 | -- Basic debugging keymaps, feel free to change to your liking! 32 | { '', dap.continue, desc = 'Debug: Start/Continue' }, 33 | { '', dap.step_into, desc = 'Debug: Step Into' }, 34 | { '', dap.step_over, desc = 'Debug: Step Over' }, 35 | { '', dap.step_out, desc = 'Debug: Step Out' }, 36 | { 'b', dap.toggle_breakpoint, desc = 'Debug: Toggle Breakpoint' }, 37 | { 38 | 'B', 39 | function() 40 | dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') 41 | end, 42 | desc = 'Debug: Set Breakpoint', 43 | }, 44 | -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. 45 | { '', dapui.toggle, desc = 'Debug: See last session result.' }, 46 | unpack(keys), 47 | } 48 | end, 49 | config = function() 50 | local dap = require 'dap' 51 | local dapui = require 'dapui' 52 | 53 | require('mason-nvim-dap').setup { 54 | -- Makes a best effort to setup the various debuggers with 55 | -- reasonable debug configurations 56 | automatic_installation = true, 57 | 58 | -- You can provide additional configuration to the handlers, 59 | -- see mason-nvim-dap README for more information 60 | handlers = {}, 61 | 62 | -- You'll need to check that you have the required things installed 63 | -- online, please don't ask me how to install them :) 64 | ensure_installed = { 65 | -- Update this to ensure that you have the debuggers for the langs you want 66 | 'delve', 67 | }, 68 | } 69 | 70 | -- Dap UI setup 71 | -- For more information, see |:help nvim-dap-ui| 72 | dapui.setup { 73 | -- Set icons to characters that are more likely to work in every terminal. 74 | -- Feel free to remove or use ones that you like more! :) 75 | -- Don't feel like these are good choices. 76 | icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, 77 | controls = { 78 | icons = { 79 | pause = '⏸', 80 | play = '▶', 81 | step_into = '⏎', 82 | step_over = '⏭', 83 | step_out = '⏮', 84 | step_back = 'b', 85 | run_last = '▶▶', 86 | terminate = '⏹', 87 | disconnect = '⏏', 88 | }, 89 | }, 90 | } 91 | 92 | dap.listeners.after.event_initialized['dapui_config'] = dapui.open 93 | dap.listeners.before.event_terminated['dapui_config'] = dapui.close 94 | dap.listeners.before.event_exited['dapui_config'] = dapui.close 95 | 96 | -- Install golang specific config 97 | require('dap-go').setup { 98 | delve = { 99 | -- On Windows delve must be run attached or it crashes. 100 | -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring 101 | detached = vim.fn.has 'win32' == 0, 102 | }, 103 | } 104 | end, 105 | } 106 | -------------------------------------------------------------------------------- /vimperatorrc: -------------------------------------------------------------------------------- 1 | " clear all key mappings 2 | " to avoid troubles from loading rc file several times 3 | mapclear 4 | cmapclear 5 | imapclear 6 | " clear user-defined commands 7 | comclear 8 | 9 | " default search/suggest engine: google 10 | set defsearch=google 11 | set suggestengines=google 12 | 13 | set! browser.bookmarks.showRecentlyBookmarked=false 14 | 15 | ignorekeys clear 16 | ignorekeys add mail\\.google\\.com -except b,,,,,,,: 17 | ignorekeys add inbox.google.com -except b,,,,,,,: 18 | ignorekeys add docs.google.com -except ,,, 19 | ignorekeys add www.pathery.com -except b,,,,,,,: 20 | ignorekeys add beta.pathery.net -except b,,,,,,,: 21 | ignorekeys add blue.pathery.net -except b,,,,,,,: 22 | ignorekeys add localhost:3000 -except ,,,,: 23 | ignorekeys add vimflowy.bitballoon.com -except ,,,,: 24 | ignorekeys add youtube.com -except b,,,,,,,: 25 | ignorekeys add workflowy.com -except ,,, 26 | 27 | " don't focus any "input" elements automatically when open pages. 28 | " sadly, this messes with new tab 29 | " set focuscontent 30 | 31 | "javascript to hide statusbar 32 | " http://stackoverflow.com/questions/21053262/vimperator-autohide-statusline 33 | noremap :js toggle_bottombar() 34 | noremap ; :js toggle_bottombar('on'): 35 | noremap o :js toggle_bottombar('on')o 36 | noremap O :js toggle_bottombar('on')O 37 | noremap t :js toggle_bottombar('on')t 38 | noremap T :js toggle_bottombar('on')t 39 | noremap b :js toggle_bottombar('on')b 40 | noremap f :js toggle_bottombar('on')f 41 | noremap F :js toggle_bottombar('on')F 42 | noremap / :js toggle_bottombar('on')/ 43 | cnoremap :js toggle_bottombar('off') 44 | cnoremap :js toggle_bottombar('off') 45 | nnoremap :js toggle_bottombar('off') 46 | 47 | js << EOF 48 | function toggle_bottombar(p) { 49 | var bb = document.getElementById('liberator-bottombar'); 50 | if (!bb) { return; } 51 | if (!p) { p = (bb.style.height == '') ? 'off' : 'on'; } 52 | if (p == 'on'){ 53 | bb.style.height = ''; 54 | bb.style.overflow = ''; 55 | } else if (p == 'off') { 56 | bb.style.height = '0px'; 57 | bb.style.overflow = 'hidden'; 58 | } 59 | } 60 | toggle_bottombar(); 61 | EOF 62 | 63 | map , 64 | " map 65 | " NOTE: this doesnt work 66 | " https://github.com/vimperator/vimperator-labs/issues/10 67 | " has an inline javascript solution, but it causes problems with other remappings (e.g. statusbar toggle) 68 | 69 | " tab operation {{{2 70 | nnoremap b 71 | " nnoremap gT 72 | " nnoremap gt 73 | nnoremap bp gT 74 | nnoremap bn gt 75 | nnoremap bl :b# 76 | nnoremap gt 77 | nnoremap gT 78 | " reorder tabs 79 | noremap :tabmove! -1 80 | noremap :tabmove! +1 81 | " new tab 82 | nnoremap g o 83 | nnoremap G t 84 | 85 | " jump to previous tab 86 | nnoremap 87 | " not working 88 | " nnoremap 89 | 90 | nnoremap fed :source ~/.vimperatorrc 91 | " TODO cant... :echo "Configuration reloaded." 92 | 93 | command! dev -description "Toggle developer tools" :emenu Tools.Web Developer.Web Console 94 | nnoremap gd :dev 95 | 96 | " doesn't work, problems with space remapping: http://superuser.com/questions/704015/hide-status-line-bottom-bar-in-vimperator 97 | nnoremap ui :set gui!=addons,menu,navigation 98 | nnoremap ta :set gui=invaddons,invmenu,invnavigation 99 | " set gui=nobookmarks,noaddons,nomenu,nonavigation,tabs 100 | 101 | " nnoremap ; : 102 | " nnoremap : ; 103 | 104 | " Scroll faster. 105 | " nnoremap j 10j 106 | " nnoremap k 10k 107 | let g:smoozy_scroll_impulse="1500" 108 | let g:smoozy_scroll_interval="10" 109 | source ~/.vimperator/plugin/smoozy.js 110 | 111 | set editor='bash -lc "mvim -f \$*" mvim ' 112 | 113 | " TODO: 114 | " - Calling up Vim itself with C-i in a textarea? 115 | " set editor=/usr/local/bin/vim 116 | " - USEFUL TO LOOK AT: https://github.com/januswel/dotfiles/blob/master/.vimperatorrc 117 | -------------------------------------------------------------------------------- /RectangleConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "bundleId" : "com.knollsoft.Rectangle", 3 | "defaults" : { 4 | "allowAnyShortcut" : { 5 | "bool" : true 6 | }, 7 | "almostMaximizeHeight" : { 8 | "float" : 0 9 | }, 10 | "almostMaximizeWidth" : { 11 | "float" : 0 12 | }, 13 | "alternateDefaultShortcuts" : { 14 | "bool" : false 15 | }, 16 | "altThirdCycle" : { 17 | "int" : 0 18 | }, 19 | "applyGapsToMaximize" : { 20 | "int" : 0 21 | }, 22 | "applyGapsToMaximizeHeight" : { 23 | "int" : 0 24 | }, 25 | "attemptMatchOnNextPrevDisplay" : { 26 | "int" : 0 27 | }, 28 | "autoMaximize" : { 29 | "int" : 0 30 | }, 31 | "cascadeAllDeltaSize" : { 32 | "float" : 30 33 | }, 34 | "centeredDirectionalMove" : { 35 | "int" : 0 36 | }, 37 | "centerHalfCycles" : { 38 | "int" : 0 39 | }, 40 | "cornerSnapAreaSize" : { 41 | "float" : 20 42 | }, 43 | "curtainChangeSize" : { 44 | "int" : 0 45 | }, 46 | "disabledApps" : { 47 | 48 | }, 49 | "footprintAlpha" : { 50 | "float" : 0.30000001192092896 51 | }, 52 | "footprintBorderWidth" : { 53 | "float" : 2 54 | }, 55 | "footprintColor" : { 56 | 57 | }, 58 | "footprintFade" : { 59 | "int" : 0 60 | }, 61 | "fullIgnoreBundleIds" : { 62 | 63 | }, 64 | "gapSize" : { 65 | "float" : 0 66 | }, 67 | "hideMenubarIcon" : { 68 | "bool" : false 69 | }, 70 | "ignoredSnapAreas" : { 71 | "int" : 0 72 | }, 73 | "launchOnLogin" : { 74 | "bool" : true 75 | }, 76 | "minimumWindowHeight" : { 77 | "float" : 0 78 | }, 79 | "minimumWindowWidth" : { 80 | "float" : 0 81 | }, 82 | "moveCursor" : { 83 | "int" : 0 84 | }, 85 | "moveCursorAcrossDisplays" : { 86 | "int" : 0 87 | }, 88 | "notifiedOfProblemApps" : { 89 | "bool" : false 90 | }, 91 | "obtainWindowOnClick" : { 92 | "int" : 0 93 | }, 94 | "relaunchOpensMenu" : { 95 | "bool" : false 96 | }, 97 | "resizeOnDirectionalMove" : { 98 | "bool" : false 99 | }, 100 | "screenEdgeGapBottom" : { 101 | "float" : 0 102 | }, 103 | "screenEdgeGapLeft" : { 104 | "float" : 0 105 | }, 106 | "screenEdgeGapRight" : { 107 | "float" : 0 108 | }, 109 | "screenEdgeGapTop" : { 110 | "float" : 0 111 | }, 112 | "shortEdgeSnapAreaSize" : { 113 | "float" : 145 114 | }, 115 | "showAllActionsInMenu" : { 116 | "int" : 0 117 | }, 118 | "sizeOffset" : { 119 | "float" : 0 120 | }, 121 | "snapEdgeMarginBottom" : { 122 | "float" : 5 123 | }, 124 | "snapEdgeMarginLeft" : { 125 | "float" : 5 126 | }, 127 | "snapEdgeMarginRight" : { 128 | "float" : 5 129 | }, 130 | "snapEdgeMarginTop" : { 131 | "float" : 5 132 | }, 133 | "snapModifiers" : { 134 | "int" : 0 135 | }, 136 | "specifiedHeight" : { 137 | "float" : 1050 138 | }, 139 | "specifiedWidth" : { 140 | "float" : 1680 141 | }, 142 | "subsequentExecutionMode" : { 143 | "int" : 0 144 | }, 145 | "SUEnableAutomaticChecks" : { 146 | "bool" : false 147 | }, 148 | "todo" : { 149 | "int" : 0 150 | }, 151 | "todoApplication" : { 152 | 153 | }, 154 | "todoMode" : { 155 | "bool" : false 156 | }, 157 | "todoSidebarWidth" : { 158 | "float" : 400 159 | }, 160 | "traverseSingleScreen" : { 161 | "int" : 0 162 | }, 163 | "unsnapRestore" : { 164 | "int" : 0 165 | }, 166 | "windowSnapping" : { 167 | "int" : 0 168 | } 169 | }, 170 | "shortcuts" : { 171 | "bottomHalf" : { 172 | "keyCode" : 38, 173 | "modifierFlags" : 786432 174 | }, 175 | "centerThird" : { 176 | "keyCode" : 34, 177 | "modifierFlags" : 786432 178 | }, 179 | "leftHalf" : { 180 | "keyCode" : 4, 181 | "modifierFlags" : 786432 182 | }, 183 | "maximize" : { 184 | "keyCode" : 46, 185 | "modifierFlags" : 786432 186 | }, 187 | "nextDisplay" : { 188 | "keyCode" : 45, 189 | "modifierFlags" : 786432 190 | }, 191 | "previousDisplay" : { 192 | "keyCode" : 35, 193 | "modifierFlags" : 786432 194 | }, 195 | "rightHalf" : { 196 | "keyCode" : 37, 197 | "modifierFlags" : 786432 198 | }, 199 | "topHalf" : { 200 | "keyCode" : 40, 201 | "modifierFlags" : 786432 202 | } 203 | }, 204 | "version" : "59" 205 | } -------------------------------------------------------------------------------- /tmux.conf: -------------------------------------------------------------------------------- 1 | # NOTE to self: 2 | # - change split, use C-a option-[1-5] 3 | # SEE: 4 | # https://superuser.com/questions/493048/how-to-convert-2-horizontal-panes-to-vertical-panes-in-tmux 5 | 6 | # colors-option 7 | set -g default-terminal "screen-256color" 8 | #set inactive/active window styles 9 | set -g window-style 'bg=colour235' 10 | set -g window-active-style 'bg=colour234' 11 | # https://github.com/dandavison/delta/pull/1560/files 12 | set -ga terminal-overrides ",*-256color:Tc" 13 | 14 | set -g set-clipboard on 15 | 16 | # remap prefix to Control + a 17 | set -g prefix C-a 18 | unbind C-b 19 | # bind C-a send-prefix 20 | bind a send-prefix 21 | 22 | # make tmux a bit more like screen 23 | # http://stackoverflow.com/questions/7771557/how-to-terminate-a-window-in-tmux 24 | bind x kill-window 25 | # bind x confirm kill-window 26 | bind q last-window 27 | 28 | bind-key m resize-pane -Z 29 | # prevent confirmation for pane killing 30 | bind k kill-pane 31 | 32 | # force a reload of the config file 33 | unbind r 34 | bind r source-file ~/.tmux.conf 35 | 36 | # bind fast session switching 37 | unbind S 38 | bind S command-prompt "switch -t %1" 39 | 40 | # quick pane cycling 41 | unbind ^A 42 | bind ^A select-pane -t :.+ 43 | 44 | # rebind pane tiling 45 | bind | split-window -h -c "#{pane_current_path}" 46 | bind - split-window -v -c "#{pane_current_path}" 47 | bind V split-window -h -c "#{pane_current_path}" 48 | bind S split-window -v -c "#{pane_current_path}" 49 | 50 | # start window numbering at 1 for easier switching 51 | set -g base-index 1 52 | 53 | # vim movement bindings 54 | set-window-option -g mode-keys vi 55 | bind-key -Tcopy-mode-vi 'v' send -X begin-selection 56 | bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" 57 | # remote version of copy 58 | bind-key -T copy-mode-vi 'Y' send-keys -X copy-pipe-and-cancel "tmux save-buffer /tmp/tmux-copy.txt" \; run "remote copy command" 59 | # NOTE: or just use this on linux? 60 | # bind-key -Tcopy-mode-vi 'y' send -X copy-selection 61 | bind-key -Tcopy-mode-vi Escape send -X cancel 62 | bind-key -Tcopy-mode-vi V send -X rectangle-toggle 63 | 64 | # SEE: https://blog.bugsnag.com/tmux-and-vim/ 65 | # and https://github.com/christoomey/vim-tmux-navigator 66 | # -t version stopped working https://github.com/christoomey/vim-tmux-navigator/issues/299 67 | # is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ 68 | # | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" 69 | is_vim="ps -o state=,tty=,comm= | grep -iqE '^[^TXZ ]+ +#{s|/dev/||:pane_tty}\s+(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" 70 | # is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \ 71 | # | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'" 72 | is_fzf="ps -o state=,tty=,comm= | grep -iqE '^[^TXZ ]+ +#{s|/dev/||:pane_tty}\s+(\\S+\\/)?fzf$'" 73 | bind -n C-h run "($is_vim && tmux send-keys C-h) || \ 74 | tmux select-pane -L" 75 | bind -n C-j run "($is_vim && tmux send-keys C-j) || \ 76 | ($is_fzf && tmux send-keys C-j) || \ 77 | tmux select-pane -D" 78 | bind -n C-k run "($is_vim && tmux send-keys C-k) || \ 79 | ($is_fzf && tmux send-keys C-k) || \ 80 | tmux select-pane -U" 81 | bind -n C-l run "($is_vim && tmux send-keys C-l) || \ 82 | tmux select-pane -R" 83 | # TODO: C-; instead? 84 | bind -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l" 85 | 86 | 87 | # unicode 88 | # setw -g utf8 on 89 | # set -g status-utf8 on 90 | 91 | # status bar config 92 | # status bar colors 93 | set -g status-bg black 94 | set -g status-fg white 95 | 96 | # alignment settings 97 | set-option -g status-justify centre 98 | 99 | # status left options 100 | set-option -g status-left '#[fg=green][#[bg=black,fg=cyan]#S#[fg=green]]' 101 | set-option -g status-left-length 20 102 | 103 | # window list options 104 | set-window-option -g automatic-rename off 105 | set-window-option -g window-status-format '#[fg=cyan,dim]#I#[fg=blue]:#[default]#W#[fg=grey,dim]#F' 106 | set-window-option -g window-status-current-format '#[bg=black,fg=cyan,bold]#I#[bg=black,fg=cyan]:#[fg=colour230]#W#[fg=dim]#F' 107 | set -g base-index 1 108 | 109 | # listen to alerts from all windows 110 | set -g bell-action any 111 | 112 | # make history limit larger 113 | set-option -g history-limit 100000 114 | # SEE: http://stackoverflow.com/questions/11832199/tmux-set-g-mouse-mode-on-doesnt-work 115 | # let mouse do stuff 116 | set -g mouse on 117 | # set -g mouse off 118 | # make scrolling with wheels work 119 | # bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode} 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'" 120 | # bind -n WheelDownPane select-pane -t= \; send-keys -M 121 | 122 | # don't make escape pause 123 | # SEE: https://bitbucket.org/lyro/evil/issues/69/delay-between-esc-or-c-and-modeswitch 124 | set -s escape-time 0 125 | 126 | # Update environment variables for tmux when reattaching 127 | # SEE: https://babushk.in/posts/renew-environment-tmux.html 128 | set-option -g update-environment "SSH_AUTH_SOCK \ 129 | SSH_CONNECTION \ 130 | DISPLAY" 131 | 132 | # TODO OSX copying doesn't work 133 | # try this? https://evertpot.com/osx-tmux-vim-copy-paste-clipboard/ 134 | 135 | bind-key -r H resize-pane -L 5 136 | bind-key -r J resize-pane -D 5 137 | bind-key -r K resize-pane -U 5 138 | bind-key -r L resize-pane -R 5 139 | -------------------------------------------------------------------------------- /my.itermcolors: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ansi 0 Color 6 | 7 | Blue Component 8 | 0.19370138645172119 9 | Green Component 10 | 0.15575926005840302 11 | Red Component 12 | 0.0 13 | 14 | Ansi 1 Color 15 | 16 | Blue Component 17 | 0.38809829950332642 18 | Green Component 19 | 0.41782402992248535 20 | Red Component 21 | 0.81926977634429932 22 | 23 | Ansi 10 Color 24 | 25 | Blue Component 26 | 0.30664927034266187 27 | Green Component 28 | 0.47484611742424243 29 | Red Component 30 | 0.34182660753088823 31 | 32 | Ansi 11 Color 33 | 34 | Blue Component 35 | 0.27418601512908936 36 | Green Component 37 | 0.75782757997512817 38 | Red Component 39 | 0.79865056276321411 40 | 41 | Ansi 12 Color 42 | 43 | Blue Component 44 | 0.77468037605285645 45 | Green Component 46 | 0.43287396430969238 47 | Red Component 48 | 0.27467691898345947 49 | 50 | Ansi 13 Color 51 | 52 | Blue Component 53 | 0.73907041549682617 54 | Green Component 55 | 0.38857379555702209 56 | Red Component 57 | 0.43010443449020386 58 | 59 | Ansi 14 Color 60 | 61 | Blue Component 62 | 0.74923056364059448 63 | Green Component 64 | 0.47768214344978333 65 | Red Component 66 | 0.59071630239486694 67 | 68 | Ansi 15 Color 69 | 70 | Blue Component 71 | 1 72 | Green Component 73 | 1 74 | Red Component 75 | 1 76 | 77 | Ansi 2 Color 78 | 79 | Blue Component 80 | 0.21634918789075153 81 | Green Component 82 | 0.38782354797979801 83 | Red Component 84 | 0.0005304260218654068 85 | 86 | Ansi 3 Color 87 | 88 | Blue Component 89 | 0.27202704548835754 90 | Green Component 91 | 0.74045592546463013 92 | Red Component 93 | 0.80778485536575317 94 | 95 | Ansi 4 Color 96 | 97 | Blue Component 98 | 0.9392361044883728 99 | Green Component 100 | 0.68243330717086792 101 | Red Component 102 | 0.34100940823554993 103 | 104 | Ansi 5 Color 105 | 106 | Blue Component 107 | 0.60506445169448853 108 | Green Component 109 | 0.1968284547328949 110 | Red Component 111 | 0.77738940715789795 112 | 113 | Ansi 6 Color 114 | 115 | Blue Component 116 | 0.95298689603805542 117 | Green Component 118 | 0.67026388645172119 119 | Red Component 120 | 0.12102869898080826 121 | 122 | Ansi 7 Color 123 | 124 | Blue Component 125 | 1 126 | Green Component 127 | 0.95864009857177734 128 | Red Component 129 | 0.95778185129165649 130 | 131 | Ansi 8 Color 132 | 133 | Blue Component 134 | 0.15170273184776306 135 | Green Component 136 | 0.11783610284328461 137 | Red Component 138 | 0.0 139 | 140 | Ansi 9 Color 141 | 142 | Blue Component 143 | 0.18229223787784576 144 | Green Component 145 | 0.18229223787784576 146 | Red Component 147 | 0.69541114568710327 148 | 149 | Background Color 150 | 151 | Blue Component 152 | 0.087397411465644836 153 | Green Component 154 | 0.087397411465644836 155 | Red Component 156 | 0.087397411465644836 157 | 158 | Bold Color 159 | 160 | Blue Component 161 | 0.8532986044883728 162 | Green Component 163 | 0.8383975625038147 164 | Red Component 165 | 0.8364708423614502 166 | 167 | Cursor Color 168 | 169 | Blue Component 170 | 0.50879889726638794 171 | Green Component 172 | 0.41405221819877625 173 | Red Component 174 | 0.47524374723434448 175 | 176 | Cursor Text Color 177 | 178 | Blue Component 179 | 0.25798022747039795 180 | Green Component 181 | 0.82495200634002686 182 | Red Component 183 | 0.91883683204650879 184 | 185 | Foreground Color 186 | 187 | Blue Component 188 | 0.51207387447357178 189 | Green Component 190 | 0.51207387447357178 191 | Red Component 192 | 0.51207387447357178 193 | 194 | Selected Text Color 195 | 196 | Blue Component 197 | 0.56363654136657715 198 | Green Component 199 | 0.56485837697982788 200 | Red Component 201 | 0.50599193572998047 202 | 203 | Selection Color 204 | 205 | Blue Component 206 | 0.21821732819080353 207 | Green Component 208 | 0.13964666426181793 209 | Red Component 210 | 0.16894493997097015 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /vim/plugin/spacemacs.vim: -------------------------------------------------------------------------------- 1 | " avy 2 | " NOTE: double leader is mapped to easymotion-prefix for some reason (easymotion default?) 3 | function! s:spacevim_bind(map, binding, name, value, isCmd) 4 | if a:isCmd 5 | let l:value = ':' . a:value . '' 6 | else 7 | let l:value = a:value 8 | endif 9 | if a:map == "map" 10 | let l:noremap = 'noremap' 11 | elseif a:map == "nmap" 12 | let l:noremap = 'nnoremap' 13 | elseif a:map == "vmap" 14 | let l:noremap = 'vnoremap' 15 | endif 16 | execute l:noremap . " " . a:name . " " . l:value 17 | execute a:map . " " . a:binding . " " . a:name 18 | " NOTE: this is much faster in some cases? see fold commands below 19 | " execute a:map . " " . a:binding . " " . l:value 20 | endfunction 21 | 22 | function! Get_visual_selection() 23 | " Why is this not a built-in Vim script function?! 24 | let [lnum1, col1] = getpos("'<")[1:2] 25 | let [lnum2, col2] = getpos("'>")[1:2] 26 | let lines = getline(lnum1, lnum2) 27 | let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] 28 | let lines[0] = lines[0][col1 - 1:] 29 | return join(lines, "\n") 30 | endfunction 31 | 32 | call s:spacevim_bind('map', 'fx', 'file-save-quit', ':w:bd', 1) 33 | 34 | function! CustomFzfGrep() 35 | " Get user input from a popup 36 | let user_input = input('Enter search query: ') 37 | 38 | " Build the rg command with user input 39 | let g:rg_command = ' 40 | \ rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --color "always" 41 | \ ' 42 | let command_with_input = g:rg_command . shellescape(user_input) 43 | 44 | " Call fzf#vim#grep with the command and input 45 | call fzf#vim#grep(command_with_input, 1) 46 | endfunction 47 | 48 | " git grep 49 | call s:spacevim_bind('map', 'gg', 'git-grep', ':call CustomFzfGrep()', 1) 50 | 51 | "toggle 52 | call s:spacevim_bind('map', 't\', 'toggle-invisible-chars', 'set list!', 1) 53 | call s:spacevim_bind('map', 'tp', 'toggle-paste', 'set paste!', 1) 54 | call s:spacevim_bind('map', 'ti', 'toggle-indent-lines', 'IndentLinesToggle', 1) 55 | call s:spacevim_bind('map', 'tn', 'toggle-line-numbers', ':setlocal invnumber:setlocal invrelativenumber', 0) 56 | call s:spacevim_bind('map', 'tg', 'toggle-git-gutter', 'GitGutterToggle', 1) 57 | 58 | call s:spacevim_bind('map', '/', 'search-current-file', 'BLines', 1) 59 | function! spacemacs#toggleAlleFolds() 60 | if &foldlevel 61 | normal! zM 62 | " set foldlevel=0 63 | else 64 | normal! zR 65 | " set foldlevel=20 66 | endif 67 | endfunction 68 | " Just copying from http://vimdoc.sourceforge.net/htmldoc/fold.html 69 | call s:spacevim_bind('map', 'z', 'toggle-all-folds', "call spacemacs#toggleAlleFolds()", 1) 70 | " NOTE: for some reason these are slow! 71 | " call s:spacevim_bind('map', 'zz', 'toggle-all-folds', "call spacemacs#toggleAlleFolds()", 1) 72 | "" call s:spacevim_bind('map', 'za', 'toggle-fold', "normal! za", 1) 73 | " call s:spacevim_bind('map', 'za', 'toggle-fold', "za", 0) 74 | " call s:spacevim_bind('map', 'zA', 'toggle-fold-recursive', "zA", 0) 75 | " call s:spacevim_bind('map', 'zf', 'create-fold', "zf", 0) 76 | " call s:spacevim_bind('map', 'zd', 'delete-fold', "zd", 0) 77 | " call s:spacevim_bind('map', 'zD', 'delete-fold-recursive', "zD", 0) 78 | " call s:spacevim_bind('map', 'zE', 'delete-all-folds', "zE", 0) 79 | " call s:spacevim_bind('map', 'zR', 'open-all-folds', "zR", 0) 80 | " call s:spacevim_bind('map', 'zM', 'close-all-folds', "zM", 0) 81 | " call s:spacevim_bind('map', 'zo', 'open-fold', "zo", 0) 82 | " call s:spacevim_bind('map', 'zO', 'open-fold-recursive', "zO", 0) 83 | " call s:spacevim_bind('map', 'zc', 'close-fold', "zc", 0) 84 | " call s:spacevim_bind('map', 'zC', 'close-fold-recursive', "zC", 0) 85 | 86 | " project 87 | function! spacemacs#toggleExplorerAtRoot() 88 | if exists(':ProjectRootExe') 89 | exe "ProjectRootExe NERDTreeToggle" 90 | else 91 | exe "NERDTreeToggle" 92 | endif 93 | endfunction 94 | call s:spacevim_bind('map', 'pt', 'toggle-explorer', ':call spacemacs#toggleExplorerAtRoot()', 1) 95 | call s:spacevim_bind('map', 'te', 'toggle-explorer', ':call spacemacs#toggleExplorerAtRoot()', 1) 96 | 97 | " files 98 | " yank history 99 | " nnoremap fp :Unite history/yank 100 | nnoremap fd :filetype detect 101 | call s:spacevim_bind('map', 'fl', 'reload-file', ':e', 1) 102 | call s:spacevim_bind('map', 'bD', 'force-quit-buffer', ':bd!', 1) 103 | call s:spacevim_bind('map', 'xx', 'save-quit-all', ':wqa', 1) 104 | function! spacemacs#reloadVimrc() 105 | source $MYVIMRC 106 | exe "AirlineRefresh" 107 | endfunction 108 | call s:spacevim_bind('map', 'feR', 'sync-configuration', ':call spacemacs#reloadVimrc()', 1) 109 | " TODO: switch saving stuff to s instead of f? 110 | call s:spacevim_bind('map', 'fS', 'sudo-write', ':w !sudo tee %', 1) 111 | 112 | call s:spacevim_bind('map', 'i;', 'insert-semicolon', 'mzA;`z', 0) 113 | call s:spacevim_bind('map', 'i,', 'insert-comma', 'mzA,`z', 0) 114 | call s:spacevim_bind('map', 'i.', 'insert-period', 'mzA.`z', 0) 115 | call s:spacevim_bind('map', 'i?', 'insert-question', 'mzA?`z', 0) 116 | call s:spacevim_bind('map', 'i!', 'insert-exclamation', 'mzA!`z', 0) 117 | call s:spacevim_bind('map', 'i', 'insert-return', 'o', 0) 118 | 119 | call s:spacevim_bind('map', 'J', 'smart-join', ':SplitjoinJoin', 1) 120 | call s:spacevim_bind('map', 'K', 'smart-split', ':SplitjoinJoin', 1) 121 | 122 | " git 123 | nnoremap ga :Git add --all 124 | nnoremap gp :Git push 125 | 126 | nnoremap b1 :b1 127 | nnoremap b2 :b2 128 | nnoremap b3 :b3 129 | nnoremap b4 :b4 130 | nnoremap b5 :b5 131 | nnoremap b6 :b6 132 | nnoremap b7 :b7 133 | nnoremap b8 :b8 134 | nnoremap b9 :b9 135 | nnoremap b0 :b10 136 | 137 | nnoremap bl :b# 138 | 139 | " copilot 140 | call s:spacevim_bind('map', 'cp', 'copilot-setup', ':Copilot setup', 0) 141 | 142 | " nnoremap bs :Scratch 143 | 144 | function! ToggleSaveAutoGroup() 145 | if !exists('#onsave#BufWritePre') 146 | augroup onsave 147 | autocmd! 148 | " strip whitespace on save 149 | autocmd BufWritePre * :%s/\s\+$//e 150 | augroup END 151 | else 152 | augroup onsave 153 | autocmd! 154 | augroup END 155 | endif 156 | endfunction 157 | 158 | call s:spacevim_bind('map', 'tw', 'toggle-onsave-strip', ':call ToggleSaveAutoGroup()', 1) 159 | call ToggleSaveAutoGroup() 160 | 161 | " TODO: folding 162 | -------------------------------------------------------------------------------- /dotty: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import argparse 4 | import glob 5 | import sys 6 | import os 7 | import subprocess 8 | import logging 9 | 10 | logging.basicConfig() 11 | logger = logging.getLogger('dotty') 12 | logger.setLevel(logging.INFO) 13 | 14 | class DottyException(Exception): 15 | def __init__(self, msg): 16 | super(Exception, self).__init__(msg) 17 | 18 | class FileStatus(object): 19 | IS_MISSING = 1 20 | IS_DIRECTORY = 2 21 | IS_FILE = 3 22 | IS_LINK = 4 23 | 24 | class LinkStatus(object): 25 | # destination is already something, not a link to the right place 26 | DST_WRONG = 1 27 | # source file doesn't exist 28 | SRC_MISSING = 2 29 | # installed correctly 30 | INSTALLED = 3 31 | # not installed 32 | UNINSTALLED = 4 33 | 34 | class DotFile(object): 35 | def __init__(self, dotty_dir, src_path, dst_path=None): 36 | if src_path[:len(dotty_dir)] != dotty_dir: 37 | raise DottyException( 38 | """ 39 | Internal error: 40 | %s did not start with %s 41 | """ % (src_path, dotty_dir) 42 | ) 43 | self.dotty_dir = dotty_dir 44 | self.src_path = src_path 45 | self.name = src_path[len(dotty_dir)+1:] 46 | if dst_path is None: 47 | dst_path = os.path.join('~', '.' + self.name) 48 | dst_path = os.path.expanduser(dst_path) 49 | self.dst_path = dst_path 50 | 51 | def read_rcfile(dotty_dir): 52 | dotty_rc = os.path.join(dotty_dir, "dotty.rc") 53 | if not os.path.exists(dotty_rc): 54 | logger.warn( 55 | """ 56 | No dotty.rc file found! 57 | Please place a file containing a pattern on each line at %s 58 | """ % dotty_rc 59 | ) 60 | lines = (line.strip() for line in open(dotty_rc)) 61 | 62 | dotfiles = [] 63 | for line in lines: 64 | if line == "": 65 | continue 66 | if line.startswith("#"): # a comment 67 | continue 68 | if ' ' in line: 69 | pattern, dst = line.split(' ') 70 | else: 71 | pattern, dst = line, None 72 | full_pattern = os.path.join(dotty_dir, pattern) 73 | filepaths = glob.glob(full_pattern) 74 | if len(filepaths) == 0: 75 | logger.warn( 76 | """ 77 | dotty.rc contained line with invalid pattern %s. 78 | Expected a file matching %s. Ignoring line. 79 | """ % (pattern, full_pattern) 80 | ) 81 | dotfiles.extend([ 82 | DotFile(dotty_dir, filepath, dst_path=dst) 83 | for filepath in filepaths 84 | ]) 85 | return dotfiles 86 | 87 | def check_file(filepath): 88 | # NOTE: we do the link check before existence so that 89 | # broken links are IS_LINK 90 | if os.path.islink(filepath): 91 | return FileStatus.IS_LINK 92 | elif os.path.isdir(filepath): 93 | return FileStatus.IS_DIRECTORY 94 | elif os.path.exists(filepath): 95 | return FileStatus.IS_FILE 96 | else: 97 | return FileStatus.IS_MISSING 98 | 99 | def get_link_status(dotfile): 100 | src_status = check_file(dotfile.src_path) 101 | if src_status == FileStatus.IS_MISSING: 102 | return LinkStatus.SRC_MISSING 103 | dst_status = check_file(dotfile.dst_path) 104 | if dst_status == FileStatus.IS_MISSING: 105 | return LinkStatus.UNINSTALLED 106 | elif dst_status == FileStatus.IS_DIRECTORY or \ 107 | dst_status == FileStatus.IS_FILE: 108 | return LinkStatus.DST_WRONG 109 | else: 110 | assert dst_status == FileStatus.IS_LINK 111 | source = os.readlink(dotfile.dst_path) 112 | if source != dotfile.src_path: 113 | return LinkStatus.DST_WRONG 114 | else: 115 | return LinkStatus.INSTALLED 116 | 117 | def get_statuses(dotty_dir): 118 | dotfiles = read_rcfile(dotty_dir) 119 | return [ 120 | (dotfile, get_link_status(dotfile)) 121 | for dotfile in dotfiles 122 | ] 123 | 124 | 125 | argp = argparse.ArgumentParser(description='manage your dotfiles.') 126 | argp_sub = argp.add_subparsers(title='dotty commands') 127 | 128 | argp_status = argp_sub.add_parser('status', help="get status") 129 | def status(args): 130 | statuses = get_statuses(args.dotty_dir) 131 | 132 | lcol = max(len(pair[0].name) for pair in statuses) 133 | for (dotfile, status) in statuses: 134 | if status == LinkStatus.SRC_MISSING: 135 | msg = 'UNINSTALLED (source file is missing)' 136 | elif status == LinkStatus.DST_WRONG: 137 | msg = 'UNINSTALLED (destination %s already exists)' % dotfile.dst_path 138 | elif status == LinkStatus.UNINSTALLED: 139 | msg = 'UNINSTALLED' 140 | else: 141 | assert status == LinkStatus.INSTALLED 142 | msg = 'INSTALLED' 143 | print ('%s : %s' % (dotfile.name.ljust(lcol), msg)) 144 | 145 | argp_status.set_defaults(func=status) 146 | 147 | argp_install = argp_sub.add_parser('install', help="install symlinks") 148 | argp_install.add_argument('-f', '--force', help='overwrite existing files', action='store_true') 149 | def install(args): 150 | statuses = get_statuses(args.dotty_dir) 151 | 152 | lcol = max(len(pair[0].name) for pair in statuses) 153 | for (dotfile, status) in statuses: 154 | if status == LinkStatus.SRC_MISSING: 155 | msg = 'ERROR (source file is missing)' 156 | elif status == LinkStatus.DST_WRONG: 157 | if args.force: 158 | os.unlink(dotfile.dst_path) 159 | # os.remove? os.rmdir? 160 | os.symlink(dotfile.src_path, dotfile.dst_path) 161 | msg = 'SUCCESS' 162 | else: 163 | msg = 'ERROR (destination %s already exists)' % dotfile.dst_path 164 | elif status == LinkStatus.INSTALLED: 165 | msg = 'SUCCESS (already installed)' 166 | else: 167 | assert status == LinkStatus.UNINSTALLED 168 | os.makedirs(os.path.dirname(dotfile.dst_path), exist_ok=True) 169 | os.symlink(dotfile.src_path, dotfile.dst_path) 170 | msg = 'SUCCESS' 171 | print ('%s : %s' % (dotfile.name.ljust(lcol), msg)) 172 | argp_install.set_defaults(func=install) 173 | 174 | 175 | argp_uninstall = argp_sub.add_parser('uninstall', help="uninstall symlinks") 176 | def uninstall(args): 177 | statuses = get_statuses(args.dotty_dir) 178 | 179 | lcol = max(len(pair[0].name) for pair in statuses) 180 | for (dotfile, status) in statuses: 181 | if status == LinkStatus.SRC_MISSING or \ 182 | status == LinkStatus.DST_WRONG or \ 183 | status == LinkStatus.UNINSTALLED: 184 | msg = 'SUCCESS (already uninstalled)' 185 | else: 186 | assert status == LinkStatus.INSTALLED 187 | os.unlink(dotfile.dst_path) 188 | msg = 'SUCCESS' 189 | print ('%s : %s' % (dotfile.name.ljust(lcol), msg)) 190 | argp_uninstall.set_defaults(func=uninstall) 191 | 192 | if __name__ == "__main__": 193 | args = argp.parse_args() 194 | args.dotty_dir = os.path.dirname(os.path.realpath(sys.argv[0])) 195 | 196 | # Python3 doesn't error on parse_args with no subcommand. 197 | try: 198 | if 'func' in args: 199 | args.func(args) 200 | else: 201 | argp.print_help() 202 | except DottyException as e: 203 | logger.error(e) 204 | sys.exit(1) 205 | sys.exit(0) 206 | -------------------------------------------------------------------------------- /vim/indent/html.vim: -------------------------------------------------------------------------------- 1 | 2 | " Description: html indenter 3 | " Author: Johannes Zellner 4 | " Last Change: Mo, 05 Jun 2006 22:32:41 CEST 5 | " Restoring 'cpo' and 'ic' added by Bram 2006 May 5 6 | " Globals: g:html_indent_tags -- indenting tags 7 | " g:html_indent_strict -- inhibit 'O O' elements 8 | " g:html_indent_strict_table -- inhibit 'O -' elements 9 | 10 | " Only load this indent file when no other was loaded. 11 | "if exists("b:did_indent") 12 | "finish 13 | "endif 14 | "let b:did_indent = 1 15 | 16 | if exists("g:js_indent") 17 | so g:js_indent 18 | else 19 | ru! indent/javascript.vim 20 | endif 21 | 22 | echo "Sourcing html indent" 23 | 24 | 25 | " [-- local settings (must come before aborting the script) --] 26 | setlocal indentexpr=HtmlIndentGetter(v:lnum) 27 | setlocal indentkeys=o,O,*,<>>,{,} 28 | 29 | 30 | if exists('g:html_indent_tags') 31 | unlet g:html_indent_tags 32 | endif 33 | 34 | " [-- helper function to assemble tag list --] 35 | fun! HtmlIndentPush(tag) 36 | if exists('g:html_indent_tags') 37 | let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag 38 | else 39 | let g:html_indent_tags = a:tag 40 | endif 41 | endfun 42 | 43 | 44 | " [-- --] 45 | call HtmlIndentPush('a') 46 | call HtmlIndentPush('abbr') 47 | call HtmlIndentPush('acronym') 48 | call HtmlIndentPush('address') 49 | call HtmlIndentPush('b') 50 | call HtmlIndentPush('bdo') 51 | call HtmlIndentPush('big') 52 | call HtmlIndentPush('blockquote') 53 | call HtmlIndentPush('button') 54 | call HtmlIndentPush('caption') 55 | call HtmlIndentPush('center') 56 | call HtmlIndentPush('cite') 57 | call HtmlIndentPush('code') 58 | call HtmlIndentPush('colgroup') 59 | call HtmlIndentPush('del') 60 | call HtmlIndentPush('dfn') 61 | call HtmlIndentPush('dir') 62 | call HtmlIndentPush('div') 63 | call HtmlIndentPush('dl') 64 | call HtmlIndentPush('em') 65 | call HtmlIndentPush('fieldset') 66 | call HtmlIndentPush('font') 67 | call HtmlIndentPush('form') 68 | call HtmlIndentPush('frameset') 69 | call HtmlIndentPush('h1') 70 | call HtmlIndentPush('h2') 71 | call HtmlIndentPush('h3') 72 | call HtmlIndentPush('h4') 73 | call HtmlIndentPush('h5') 74 | call HtmlIndentPush('h6') 75 | call HtmlIndentPush('i') 76 | call HtmlIndentPush('iframe') 77 | call HtmlIndentPush('ins') 78 | call HtmlIndentPush('kbd') 79 | call HtmlIndentPush('label') 80 | call HtmlIndentPush('legend') 81 | call HtmlIndentPush('map') 82 | call HtmlIndentPush('menu') 83 | call HtmlIndentPush('noframes') 84 | call HtmlIndentPush('noscript') 85 | call HtmlIndentPush('object') 86 | call HtmlIndentPush('ol') 87 | call HtmlIndentPush('optgroup') 88 | " call HtmlIndentPush('pre') 89 | call HtmlIndentPush('q') 90 | call HtmlIndentPush('s') 91 | call HtmlIndentPush('samp') 92 | call HtmlIndentPush('script') 93 | call HtmlIndentPush('select') 94 | call HtmlIndentPush('small') 95 | call HtmlIndentPush('span') 96 | call HtmlIndentPush('strong') 97 | call HtmlIndentPush('style') 98 | call HtmlIndentPush('sub') 99 | call HtmlIndentPush('sup') 100 | call HtmlIndentPush('table') 101 | call HtmlIndentPush('textarea') 102 | call HtmlIndentPush('title') 103 | call HtmlIndentPush('tt') 104 | call HtmlIndentPush('u') 105 | call HtmlIndentPush('ul') 106 | call HtmlIndentPush('var') 107 | 108 | 109 | " [-- --] 110 | if !exists('g:html_indent_strict') 111 | call HtmlIndentPush('body') 112 | call HtmlIndentPush('head') 113 | call HtmlIndentPush('html') 114 | call HtmlIndentPush('tbody') 115 | endif 116 | 117 | 118 | " [-- --] 119 | if !exists('g:html_indent_strict_table') 120 | call HtmlIndentPush('th') 121 | call HtmlIndentPush('td') 122 | call HtmlIndentPush('tr') 123 | call HtmlIndentPush('tfoot') 124 | call HtmlIndentPush('thead') 125 | endif 126 | 127 | delfun HtmlIndentPush 128 | 129 | let s:cpo_save = &cpo 130 | set cpo-=C 131 | 132 | " [-- count indent-increasing tags of line a:lnum --] 133 | fun! HtmlIndentOpen(lnum, pattern) 134 | let s = substitute('x'.getline(a:lnum), 135 | \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g') 136 | let s = substitute(s, "[^\1].*$", '', '') 137 | return strlen(s) 138 | endfun 139 | 140 | " [-- count indent-decreasing tags of line a:lnum --] 141 | fun! HtmlIndentClose(lnum, pattern) 142 | let s = substitute('x'.getline(a:lnum), 143 | \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g') 144 | let s = substitute(s, "[^\1].*$", '', '') 145 | return strlen(s) 146 | endfun 147 | 148 | " [-- count indent-increasing '{' of (java|css) line a:lnum --] 149 | fun! HtmlIndentOpenAlt(lnum) 150 | return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g')) 151 | endfun 152 | 153 | " [-- count indent-decreasing '}' of (java|css) line a:lnum --] 154 | fun! HtmlIndentCloseAlt(lnum) 155 | return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g')) 156 | endfun 157 | 158 | " [-- return the sum of indents respecting the syntax of a:lnum --] 159 | fun! HtmlIndentSum(lnum, style) 160 | if a:style == match(getline(a:lnum), '^\s*') 162 | let open = HtmlIndentOpen(a:lnum, g:html_indent_tags) 163 | let close = HtmlIndentClose(a:lnum, g:html_indent_tags) 164 | if 0 != open || 0 != close 165 | return open - close 166 | endif 167 | endif 168 | endif 169 | if '' != &syntax && 170 | \ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' && 171 | \ synIDattr(synID(a:lnum, strlen(getline(a:lnum)), 1), 'name') 172 | \ =~ '\(css\|java\).*' 173 | if a:style == match(getline(a:lnum), '^\s*}') 174 | return HtmlIndentOpenAlt(a:lnum) - HtmlIndentCloseAlt(a:lnum) 175 | endif 176 | endif 177 | return 0 178 | endfun 179 | 180 | fun! HtmlIndentGetter(lnum) 181 | 182 | echo "Grabbing html indent for line: " . a:lnum 183 | " Find a non-empty line above the current line. 184 | let lnum = prevnonblank(a:lnum - 1) 185 | 186 | " Hit the start of the file, use zero indent. 187 | if lnum == 0 188 | return 0 189 | endif 190 | 191 | let restore_ic = &ic 192 | setlocal ic " ignore case 193 | 194 | " [-- special handling for
: no indenting --]
195 |     if getline(a:lnum) =~ '\c
' 196 | \ || 0 < searchpair('\c
', '', '\c
', 'nWb') 197 | \ || 0 < searchpair('\c
', '', '\c
', 'nW') 198 | " we're in a line with or inside
 ... 
199 | if restore_ic == 0 200 | setlocal noic 201 | endif 202 | return -1 203 | endif 204 | 205 | " [-- special handling for : use cindent --] 206 | let js = ', 05 Jun 2006 210 | " ZDR: This needs to be an AND (we are 'after the start of the pair' AND 211 | " we are 'before the end of the pair'). Otherwise, indentation 212 | " before the start of the script block will be affected; the end of 213 | " the pair will still match if we are before the beginning of the 214 | " pair. 215 | " 216 | if 0 < searchpair(js, '', '', 'nWb') 217 | \ && 0 < searchpair(js, '', '', 'nW') 218 | " we're inside javascript 219 | 220 | if getline(lnum) !~ js && getline(a:lnum) !~ '' 221 | if restore_ic == 0 222 | setlocal noic 223 | endif 224 | return GetJsIndent(a:lnum) 225 | endif 226 | endif 227 | 228 | if getline(lnum) =~ '\c' 229 | " line before the current line a:lnum contains 230 | " a closing . --> search for line before 231 | " starting
 to restore the indent.
232 | 	let preline = prevnonblank(search('\c
', 'bW') - 1)
233 | 	if preline > 0
234 | 	    if restore_ic == 0
235 | 	      setlocal noic
236 | 	    endif
237 | 	    return indent(preline)
238 | 	endif
239 |     endif
240 | 
241 |     let ind = HtmlIndentSum(lnum, -1)
242 |     let ind = ind + HtmlIndentSum(a:lnum, 0)
243 | 
244 |     if restore_ic == 0
245 | 	setlocal noic
246 |     endif
247 | 
248 |     return indent(lnum) + (&sw * ind)
249 | endfun
250 | 
251 | let &cpo = s:cpo_save
252 | unlet s:cpo_save
253 | 
254 | " [-- EOF /indent/html.vim --]
255 | 


--------------------------------------------------------------------------------
/nvim/README.md:
--------------------------------------------------------------------------------
  1 | # kickstart.nvim
  2 | 
  3 | ## Introduction
  4 | 
  5 | A starting point for Neovim that is:
  6 | 
  7 | * Small
  8 | * Single-file
  9 | * Completely Documented
 10 | 
 11 | **NOT** a Neovim distribution, but instead a starting point for your configuration.
 12 | 
 13 | ## Installation
 14 | 
 15 | ### Install Neovim
 16 | 
 17 | Kickstart.nvim targets *only* the latest
 18 | ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest
 19 | ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim.
 20 | If you are experiencing issues, please make sure you have the latest versions.
 21 | 
 22 | ### Install External Dependencies
 23 | 
 24 | External Requirements:
 25 | - Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`)
 26 | - [ripgrep](https://github.com/BurntSushi/ripgrep#installation)
 27 | - Clipboard tool (xclip/xsel/win32yank or other depending on platform)
 28 | - A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons
 29 |   - if you have it set `vim.g.have_nerd_font` in `init.lua` to true
 30 | - Language Setup:
 31 |   - If want to write Typescript, you need `npm`
 32 |   - If want to write Golang, you will need `go`
 33 |   - etc.
 34 | 
 35 | > **NOTE**
 36 | > See [Install Recipes](#Install-Recipes) for additional Windows and Linux specific notes
 37 | > and quick install snippets
 38 | 
 39 | ### Install Kickstart
 40 | 
 41 | > **NOTE**
 42 | > [Backup](#FAQ) your previous configuration (if any exists)
 43 | 
 44 | Neovim's configurations are located under the following paths, depending on your OS:
 45 | 
 46 | | OS | PATH |
 47 | | :- | :--- |
 48 | | Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` |
 49 | | Windows (cmd)| `%localappdata%\nvim\` |
 50 | | Windows (powershell)| `$env:LOCALAPPDATA\nvim\` |
 51 | 
 52 | #### Recommended Step
 53 | 
 54 | [Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo
 55 | so that you have your own copy that you can modify, then install by cloning the
 56 | fork to your machine using one of the commands below, depending on your OS.
 57 | 
 58 | > **NOTE**
 59 | > Your fork's url will be something like this:
 60 | > `https://github.com//kickstart.nvim.git`
 61 | 
 62 | #### Clone kickstart.nvim
 63 | > **NOTE**
 64 | > If following the recommended step above (i.e., forking the repo), replace
 65 | > `nvim-lua` with `` in the commands below
 66 | 
 67 | 
Linux and Mac 68 | 69 | ```sh 70 | git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim 71 | ``` 72 | 73 |
74 | 75 |
Windows 76 | 77 | If you're using `cmd.exe`: 78 | 79 | ``` 80 | git clone https://github.com/nvim-lua/kickstart.nvim.git %localappdata%\nvim\ 81 | ``` 82 | 83 | If you're using `powershell.exe` 84 | 85 | ``` 86 | git clone https://github.com/nvim-lua/kickstart.nvim.git $env:LOCALAPPDATA\nvim\ 87 | ``` 88 | 89 |
90 | 91 | ### Post Installation 92 | 93 | Start Neovim 94 | 95 | ```sh 96 | nvim 97 | ``` 98 | 99 | That's it! Lazy will install all the plugins you have. Use `:Lazy` to view 100 | current plugin status. Hit `q` to close the window. 101 | 102 | Read through the `init.lua` file in your configuration folder for more 103 | information about extending and exploring Neovim. That also includes 104 | examples of adding popularly requested plugins. 105 | 106 | 107 | ### Getting Started 108 | 109 | [The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o) 110 | 111 | ### FAQ 112 | 113 | * What should I do if I already have a pre-existing neovim configuration? 114 | * You should back it up and then delete all associated files. 115 | * This includes your existing init.lua and the neovim files in `~/.local` 116 | which can be deleted with `rm -rf ~/.local/share/nvim/` 117 | * Can I keep my existing configuration in parallel to kickstart? 118 | * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` 119 | to maintain multiple configurations. For example, you can install the kickstart 120 | configuration in `~/.config/nvim-kickstart` and create an alias: 121 | ``` 122 | alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' 123 | ``` 124 | When you run Neovim using `nvim-kickstart` alias it will use the alternative 125 | config directory and the matching local directory 126 | `~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim 127 | distribution that you would like to try out. 128 | * What if I want to "uninstall" this configuration: 129 | * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information 130 | * Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? 131 | * The main purpose of kickstart is to serve as a teaching tool and a reference 132 | configuration that someone can easily use to `git clone` as a basis for their own. 133 | As you progress in learning Neovim and Lua, you might consider splitting `init.lua` 134 | into smaller parts. A fork of kickstart that does this while maintaining the 135 | same functionality is available here: 136 | * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) 137 | * Discussions on this topic can be found here: 138 | * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) 139 | * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) 140 | 141 | ### Install Recipes 142 | 143 | Below you can find OS specific install instructions for Neovim and dependencies. 144 | 145 | After installing all the dependencies continue with the [Install Kickstart](#Install-Kickstart) step. 146 | 147 | #### Windows Installation 148 | 149 |
Windows with Microsoft C++ Build Tools and CMake 150 | Installation may require installing build tools and updating the run command for `telescope-fzf-native` 151 | 152 | See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) 153 | 154 | This requires: 155 | 156 | - Install CMake and the Microsoft C++ Build Tools on Windows 157 | 158 | ```lua 159 | {'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } 160 | ``` 161 |
162 |
Windows with gcc/make using chocolatey 163 | Alternatively, one can install gcc and make which don't require changing the config, 164 | the easiest way is to use choco: 165 | 166 | 1. install [chocolatey](https://chocolatey.org/install) 167 | either follow the instructions on the page or use winget, 168 | run in cmd as **admin**: 169 | ``` 170 | winget install --accept-source-agreements chocolatey.chocolatey 171 | ``` 172 | 173 | 2. install all requirements using choco, exit previous cmd and 174 | open a new one so that choco path is set, and run in cmd as **admin**: 175 | ``` 176 | choco install -y neovim git ripgrep wget fd unzip gzip mingw make 177 | ``` 178 |
179 |
WSL (Windows Subsystem for Linux) 180 | 181 | ``` 182 | wsl --install 183 | wsl 184 | sudo add-apt-repository ppa:neovim-ppa/unstable -y 185 | sudo apt update 186 | sudo apt install make gcc ripgrep unzip git xclip neovim 187 | ``` 188 |
189 | 190 | #### Linux Install 191 |
Ubuntu Install Steps 192 | 193 | ``` 194 | sudo add-apt-repository ppa:neovim-ppa/unstable -y 195 | sudo apt update 196 | sudo apt install make gcc ripgrep unzip git xclip neovim 197 | ``` 198 |
199 |
Debian Install Steps 200 | 201 | ``` 202 | sudo apt update 203 | sudo apt install make gcc ripgrep unzip git xclip curl 204 | 205 | # Now we install nvim 206 | curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz 207 | sudo rm -rf /opt/nvim-linux64 208 | sudo mkdir -p /opt/nvim-linux64 209 | sudo chmod a+rX /opt/nvim-linux64 210 | sudo tar -C /opt -xzf nvim-linux64.tar.gz 211 | 212 | # make it available in /usr/local/bin, distro installs to /usr/bin 213 | sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/ 214 | ``` 215 |
216 |
Fedora Install Steps 217 | 218 | ``` 219 | sudo dnf install -y gcc make git ripgrep fd-find unzip neovim 220 | ``` 221 |
222 | 223 |
Arch Install Steps 224 | 225 | ``` 226 | sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim 227 | ``` 228 |
229 | 230 | -------------------------------------------------------------------------------- /vim/indent/javascript.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file Language: JavaScript 2 | " Author: Preston Koprivica (pkopriv2@gmail.com) 3 | " URL: 4 | " Last Change: April 30, 2010 5 | 6 | " 0. Standard Stuff 7 | " ================= 8 | 9 | " Only load one indent script per buffer 10 | if exists('b:did_indent') 11 | finish 12 | endif 13 | 14 | let b:did_indent = 1 15 | 16 | " Set the global log variable 1 = logging enabled, 0 = logging disabled 17 | if !exists("g:js_indent_log") 18 | let g:js_indent_log = 0 19 | endif 20 | 21 | setlocal indentexpr=GetJsIndent(v:lnum) 22 | setlocal indentkeys= 23 | 24 | 25 | setlocal cindent 26 | setlocal autoindent 27 | 28 | 29 | " 1. Variables 30 | " ============ 31 | 32 | " Inline comments (for anchoring other statements) 33 | let s:js_mid_line_comment = '\s*\(\/\*.*\*\/\)*\s*' 34 | let s:js_end_line_comment = s:js_mid_line_comment . '\s*\(//.*\)*' 35 | let s:js_line_comment = s:js_end_line_comment 36 | 37 | " Comment/String Syntax Key 38 | let s:syn_comment = '\(Comment\|String\|Regexp\)' 39 | 40 | 41 | " 2. Aux. Functions 42 | " ================= 43 | 44 | " = Method: IsInComment 45 | " 46 | " Determines whether the specified position is contained in a comment. "Note: 47 | " This depends on a 48 | function! s:IsInComment(lnum, cnum) 49 | return synIDattr(synID(a:lnum, a:cnum, 1), 'name') =~? s:syn_comment 50 | endfunction 51 | 52 | 53 | " = Method: IsComment 54 | " 55 | " Determines whether a line is a comment or not. 56 | function! s:IsComment(lnum) 57 | let line = getline(a:lnum) 58 | 59 | return s:IsInComment(a:lnum, 1) && s:IsInComment(a:lnum, strlen(line)) "Doesn't absolutely work. Only Probably! 60 | endfunction 61 | 62 | 63 | " = Method: GetNonCommentLine 64 | " 65 | " Grabs the nearest non-commented line 66 | function! s:GetNonCommentLine(lnum) 67 | let lnum = prevnonblank(a:lnum) 68 | 69 | while lnum > 0 70 | if s:IsComment(lnum) 71 | let lnum = prevnonblank(lnum - 1) 72 | else 73 | return lnum 74 | endif 75 | endwhile 76 | 77 | return lnum 78 | endfunction 79 | 80 | " = Method: SearchForPair 81 | " 82 | " Returns the beginning tag of a given pair starting from the given line. 83 | function! s:SearchForPair(lnum, beg, end) 84 | " Save the cursor position. 85 | let curpos = getpos(".") 86 | 87 | " Set the cursor position to the beginning of the line (default 88 | " behavior when using ==) 89 | call cursor(a:lnum, 0) 90 | 91 | " Search for the opening tag 92 | let mnum = searchpair(a:beg, '', a:end, 'bW', 93 | \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? s:syn_comment' ) 94 | 95 | "Restore the cursor position 96 | call cursor(curpos) 97 | 98 | " Finally, return the matched line number 99 | return mnum 100 | endfunction 101 | 102 | 103 | " Object Helpers 104 | " ============== 105 | let s:object_beg = '{[^}]*' . s:js_end_line_comment . '$' 106 | let s:object_end = '^' . s:js_mid_line_comment . '}[;,]\=' 107 | 108 | 109 | function! s:IsObjectBeg(line) 110 | return a:line =~ s:object_beg 111 | endfunction 112 | 113 | function! s:IsObjectEnd(line) 114 | return a:line =~ s:object_end 115 | endfunction 116 | 117 | function! s:GetObjectBeg(lnum) 118 | return s:SearchForPair(a:lnum, '{', '}') 119 | endfunction 120 | 121 | 122 | " Array Helpers 123 | " ============== 124 | let s:array_beg = '\[[^\]]*' . s:js_end_line_comment . '$' 125 | let s:array_end = '^' . s:js_mid_line_comment . '[^\[]*\][;,]*' . s:js_end_line_comment . '$' 126 | 127 | 128 | function! s:IsArrayBeg(line) 129 | return a:line =~ s:array_beg 130 | endfunction 131 | 132 | function! s:IsArrayEnd(line) 133 | return a:line =~ s:array_end 134 | endfunction 135 | 136 | function! s:GetArrayBeg(lnum) 137 | return s:SearchForPair(a:lnum, '\[', '\]') 138 | endfunction 139 | 140 | 141 | " MultiLine Declaration/Invocation Helpers 142 | " ======================================== 143 | let s:paren_beg = '([^)]*' . s:js_end_line_comment . '$' 144 | let s:paren_end = '^' . s:js_mid_line_comment . '[^(]*)[;,]*' 145 | 146 | function! s:IsParenBeg(line) 147 | return a:line =~ s:paren_beg 148 | endfunction 149 | 150 | function! s:IsParenEnd(line) 151 | return a:line =~ s:paren_end 152 | endfunction 153 | 154 | function! s:GetParenBeg(lnum) 155 | return s:SearchForPair(a:lnum, '(', ')') 156 | endfunction 157 | 158 | 159 | 160 | " Continuation Helpers 161 | " ==================== 162 | let s:continuation = '\(+\|\\\)\{1}' . s:js_line_comment . '$' 163 | 164 | function! s:IsContinuationLine(line) 165 | return a:line =~ s:continuation 166 | endfunction 167 | 168 | function! s:GetContinuationBegin(lnum) 169 | let cur = a:lnum 170 | 171 | while s:IsContinuationLine(getline(cur)) 172 | let cur -= 1 173 | endwhile 174 | 175 | return cur + 1 176 | endfunction 177 | 178 | 179 | " Switch Helpers 180 | " ============== 181 | let s:switch_beg_next_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . s:js_end_line_comment . '$' 182 | let s:switch_beg_same_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . '{\s*' . s:js_line_comment . '$' 183 | let s:switch_mid = '^.*\(case.*\|default\)\s*:\s*' 184 | 185 | function! s:IsSwitchBeginNextLine(line) 186 | return a:line =~ s:switch_beg_next_line 187 | endfunction 188 | 189 | function! s:IsSwitchBeginSameLine(line) 190 | return a:line =~ s:switch_beg_same_line 191 | endfunction 192 | 193 | function! s:IsSwitchMid(line) 194 | return a:line =~ s:switch_mid 195 | endfunction 196 | 197 | 198 | " Control Helpers 199 | " =============== 200 | let s:cntrl_beg_keys = '\(\(\(if\|for\|with\|while\)\s*(.*)\)\|\(try\|do\)\)\s*' 201 | let s:cntrl_mid_keys = '\(\(\(else\s*if\|catch\)\s*(.*)\)\|\(finally\|else\)\)\s*' 202 | 203 | let s:cntrl_beg = s:cntrl_beg_keys . s:js_end_line_comment . '$' 204 | let s:cntrl_mid = s:cntrl_mid_keys . s:js_end_line_comment . '$' 205 | 206 | let s:cntrl_end = '\(while\s*(.*)\)\s*;\=\s*' . s:js_end_line_comment . '$' 207 | 208 | function! s:IsControlBeg(line) 209 | return a:line =~ s:cntrl_beg 210 | endfunction 211 | 212 | function! s:IsControlMid(line) 213 | return a:line =~ s:cntrl_mid 214 | endfunction 215 | 216 | function! s:IsControlMidStrict(line) 217 | return a:line =~ s:cntrl_mid 218 | endfunction 219 | 220 | function! s:IsControlEnd(line) 221 | return a:line =~ s:cntrl_end 222 | endfunction 223 | 224 | " = Method: Log 225 | " 226 | " Logs a message to the stdout. 227 | function! s:Log(msg) 228 | if g:js_indent_log 229 | echo "LOG: " . a:msg 230 | endif 231 | endfunction 232 | 233 | 234 | " 3. Indenter 235 | " =========== 236 | function! GetJsIndent(lnum) 237 | " Grab the first non-comment line prior to this line 238 | let pnum = s:GetNonCommentLine(a:lnum-1) 239 | 240 | " First line, start at indent = 0 241 | if pnum == 0 242 | call s:Log("No, noncomment lines prior to the current line.") 243 | return 0 244 | endif 245 | 246 | " Grab the second non-comment line prior to this line 247 | let ppnum = s:GetNonCommentLine(pnum-1) 248 | 249 | call s:Log("Line: " . a:lnum) 250 | call s:Log("PLine: " . pnum) 251 | call s:Log("PPLine: " . ppnum) 252 | 253 | " Grab the lines themselves. 254 | let line = getline(a:lnum) 255 | let pline = getline(pnum) 256 | let ppline = getline(ppnum) 257 | 258 | " Determine the current level of indentation 259 | let ind = indent(pnum) 260 | 261 | 262 | " Handle: Object Closers (ie }) 263 | " ============================= 264 | if s:IsObjectEnd(line) && !s:IsComment(a:lnum) 265 | call s:Log("Line matched object end") 266 | 267 | let obeg = s:GetObjectBeg(a:lnum) 268 | let oind = indent(obeg) 269 | let oline = getline(obeg) 270 | 271 | call s:Log("The object beg was found at: " . obeg) 272 | return oind 273 | endif 274 | 275 | if s:IsObjectBeg(pline) 276 | call s:Log("Pline matched object beg") 277 | return ind + &sw 278 | endif 279 | 280 | 281 | " Handle: Array Closer (ie ]) 282 | " ============================ 283 | if s:IsArrayEnd(line) && !s:IsComment(a:lnum) 284 | call s:Log("Line matched array end") 285 | 286 | let abeg = s:GetArrayBeg(a:lnum) 287 | let aind = indent(abeg) 288 | 289 | call s:Log("The array beg was found at: " . abeg) 290 | return aind 291 | endif 292 | 293 | if s:IsArrayBeg(pline) 294 | call s:Log("Pline matched array beg") 295 | return ind + &sw 296 | endif 297 | 298 | " Handle: Parens 299 | " ============== 300 | if s:IsParenEnd(line) && !s:IsComment(a:lnum) 301 | call s:Log("Line matched paren end") 302 | 303 | let abeg = s:GetParenBeg(a:lnum) 304 | let aind = indent(abeg) 305 | 306 | call s:Log("The paren beg was found at: " . abeg) 307 | return aind 308 | endif 309 | 310 | if s:IsParenBeg(pline) 311 | call s:Log("Pline matched paren beg") 312 | return ind + &sw 313 | endif 314 | 315 | 316 | " Handle: Continuation Lines. 317 | " ======================================================== 318 | if s:IsContinuationLine(pline) 319 | call s:Log('Pline is a continuation line.') 320 | 321 | let cbeg = s:GetContinuationBegin(pnum) 322 | let cind = indent(cbeg) 323 | 324 | call s:Log('The continuation block begin found at: ' . cbeg) 325 | return cind + &sw 326 | endif 327 | 328 | if s:IsContinuationLine(ppline) 329 | call s:Log('PPline was a continuation line but pline wasnt.') 330 | return ind - &sw 331 | endif 332 | 333 | " Handle: Switch Control Blocks 334 | " ============================= 335 | if s:IsSwitchMid(pline) 336 | call s:Log("PLine matched switch cntrl mid") 337 | if s:IsSwitchMid(line) || s:IsObjectEnd(line) 338 | call s:Log("Line matched a cntrl mid") 339 | return ind 340 | else 341 | call s:Log("Line didnt match a cntrl mid") 342 | return ind + &sw 343 | endif 344 | endif 345 | 346 | if s:IsSwitchMid(line) 347 | call s:Log("Line matched switch cntrl mid") 348 | return ind - &sw 349 | endif 350 | 351 | 352 | " Handle: Single Line Control Blocks 353 | " ================================== 354 | if s:IsControlBeg(pline) 355 | call s:Log("Pline matched control beginning") 356 | 357 | if s:IsControlMid(line) 358 | call s:Log("Line matched a control mid") 359 | return ind 360 | elseif line =~ '^\s*{\s*$' 361 | call s:Log("Line matched an object beg") 362 | return ind 363 | else 364 | return ind + &sw 365 | endif 366 | 367 | endif 368 | 369 | if s:IsControlMid(pline) 370 | call s:Log("Pline matched a control mid") 371 | 372 | if s:IsControlMid(line) 373 | call s:Log("Line matched a control mid") 374 | return ind 375 | elseif s:IsObjectBeg(line) 376 | call s:Log("Line matched an object beg") 377 | return ind 378 | else 379 | call s:Log("Line didn't match a control mid or object beg." 380 | return ind + &sw 381 | endif 382 | endif 383 | 384 | if s:IsControlMid(line) 385 | call s:Log("Line matched a control mid.") 386 | 387 | if s:IsControlEnd(pline) || s:IsObjectEnd(pline) 388 | call s:Log("PLine matched control end") 389 | return ind 390 | else 391 | call s:Log("Pline didn't match object end") 392 | return ind - &sw 393 | endif 394 | endif 395 | 396 | 397 | if ( s:IsControlBeg(ppline) || s:IsControlMid(ppline) ) && 398 | \ !s:IsObjectBeg(pline) && !s:IsObjectEnd(pline) 399 | call s:Log("PPLine matched single line control beg or mid") 400 | return ind - &sw 401 | endif 402 | 403 | " Handle: No matches 404 | " ================== 405 | "call s:Log("Line didn't match anything. Retaining indent") 406 | return ind 407 | endfunction 408 | -------------------------------------------------------------------------------- /karabiner/karabiner_settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | 4 | simple_rules = [ 5 | { 6 | "from": { 7 | "key_code": "caps_lock" 8 | }, 9 | "to": [ 10 | { 11 | "key_code": "left_control" 12 | } 13 | ] 14 | }, 15 | { 16 | "from": { 17 | "key_code": "right_command" 18 | }, 19 | "to": [ 20 | { 21 | "key_code": "escape" 22 | } 23 | ] 24 | }, 25 | { 26 | "from": { 27 | "key_code": "return_or_enter" 28 | }, 29 | "to": [ 30 | { 31 | "key_code": "semicolon" 32 | } 33 | ] 34 | }, 35 | { 36 | "from": { 37 | "key_code": "semicolon" 38 | }, 39 | "to": [ 40 | { 41 | "key_code": "return_or_enter" 42 | } 43 | ] 44 | }, 45 | ] 46 | 47 | VIM_MODE_KEY = "return_or_enter" 48 | # VIM_MODE_KEY = "spacebar" # is mostly great except sometimes false negatives 49 | # VIM_MODE_KEY = "d" # is mostly great except sometimes false negatives 50 | # VIM_MODE_KEY = "a" # is mostly great except sometimes false negatives ... 51 | 52 | # ACTIVATE_TOGGLE = "m" 53 | DOWN = "j" 54 | UP = "k" 55 | LEFT = "h" 56 | RIGHT = "l" 57 | FAST = "a" 58 | MOUSE = "a" 59 | SLOW = "s" 60 | MOUSE_SLOW = "s" 61 | SCROLL = "d" 62 | LEFT_CLICK = "f" 63 | MIDDLE_CLICK = "v" 64 | RIGHT_CLICK = "g" 65 | LEFT_CLICK_2 = "u" 66 | MIDDLE_CLICK_2 = "i" 67 | RIGHT_CLICK_2 = "o" 68 | 69 | MOUSE_SCROLL_SPEED = 64 70 | MOUSE_SPEED = 2400 71 | MOUSE_SPEED_SLOW = 600 72 | MOUSE_SLOW_MULTIPLIER = 0.25 73 | MOUSE_FAST_MULTIPLIER = 2 74 | 75 | SIMULTANEOUS_THRESHOLD_MS = 100 76 | 77 | tab_app_manager_rules = [ 78 | { 79 | "from": {"key_code": "tab"}, 80 | "to": [{"set_variable": {"name": "tab-mode", "value": 1}}], 81 | "to_after_key_up": [{"set_variable": {"name": "tab-mode", "value": 0}}], 82 | "to_if_alone": [{"key_code": "tab"}], 83 | "type": "basic", 84 | }, 85 | ] 86 | 87 | import subprocess 88 | git_root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).strip().decode("utf-8") 89 | focus_tab_script = f"{git_root}/focus-tab" 90 | 91 | tab_mappings: dict[str, str] = { 92 | "c": "open -a 'Google Chrome.app'", 93 | "f": "open -a 'Firefox.app'", 94 | "t": "open -a 'iTerm.app'", 95 | "s": "open -a 'Slack.app'", 96 | "z": "open -a 'Zed nightly.app'", 97 | # "z": "~/bin/launch_zed", 98 | # "o": 'open -a "Outline.app"', 99 | "r": f'{focus_tab_script} "https://github.com/Wuthefwasthat/dotfiles/issues?q=((review-requested%3A%40me%20OR%20reviewed-by%3A%40me%20)%20OR%20(is%3Apr%20author%3A%40me))%20state%3Aopen"', 100 | "p": f'{focus_tab_script} "https://github.com/Wuthefwasthat/dotfiles/pulls/@me"', 101 | # "o": 'open -n -b "com.google.Chrome" --args --new-tab "https://outline.ant.dev/"', 102 | "m": "open -a 'Spotify.app'", 103 | "a": "open -a 'Claude.app'", 104 | # "f": "open -a '/System/Library/CoreServices/Finder.app'", 105 | "v": 'open -a "Visual Studio Code.app"', 106 | "1": f'{focus_tab_script} "https://mail.google.com"', 107 | "2": f'{focus_tab_script} "https://calendar.google.com"', 108 | } 109 | 110 | for key, action in tab_mappings.items(): 111 | manipulator = { 112 | "conditions": [{"name": "tab-mode", "type": "variable_if", "value": 1}], 113 | "from": {"key_code": key.lower()}, 114 | "to": [{"shell_command": action}], 115 | "type": "basic", 116 | } 117 | tab_app_manager_rules.append(manipulator) 118 | 119 | 120 | def var_is_set(var, value=1): 121 | """ Returns condition that variable is set. """ 122 | return { 123 | "type": "variable_if", 124 | "name": var, 125 | "value": value 126 | } 127 | 128 | def set_var(var, value=1): 129 | """ Sets variable to value. """ 130 | return { 131 | "set_variable": { 132 | "name": var, 133 | "value": value 134 | } 135 | } 136 | 137 | def single_key(key_code, modifiers=()): 138 | return { 139 | "key_code": key_code, 140 | "modifiers": { 141 | "mandatory": list(modifiers), 142 | "optional": [ 143 | "any" 144 | ] 145 | } 146 | } 147 | 148 | def simultaneous_keys(key_codes, after_up=None, modifiers=(), strict=True): 149 | res = { 150 | "simultaneous": [ 151 | { "key_code": key_code } for key_code in key_codes 152 | ], 153 | "simultaneous_options": { 154 | "key_down_order": "strict" if strict else "insensitive", 155 | "key_up_order": "strict_inverse" if strict else "insensitive", 156 | }, 157 | "modifiers": { 158 | "mandatory": list(modifiers), 159 | "optional": [ "any" ], 160 | } 161 | } 162 | if after_up is not None: 163 | res["simultaneous_options"]["to_after_key_up"] = after_up 164 | return res 165 | 166 | def basic_rule(items): 167 | return { 168 | "type": "basic", 169 | # "parameters": { "basic.simultaneous_threshold_milliseconds": SIMULTANEOUS_THRESHOLD_MS }, 170 | **items 171 | } 172 | 173 | 174 | caps_lock_rules = [ 175 | basic_rule({ 176 | "from": single_key("caps_lock"), 177 | "to": [ { "key_code": "left_control" } ], 178 | "to_if_alone": [ { "key_code": "escape" } ], 179 | }) 180 | ] 181 | 182 | # NOTE: this is disabled because escape delay is too annoying 183 | # Doing this with a simple rule instead 184 | # right_command_rules = [ 185 | # basic_rule({ 186 | # "from": single_key("right_command"), 187 | # "to": [ { "key_code": "right_command" } ], 188 | # "to_if_alone": [ { "key_code": "escape" } ], 189 | # }) 190 | # ] 191 | 192 | shift_rules = [ 193 | basic_rule({ 194 | "from": { "key_code": "left_shift" }, 195 | "to": [ { "key_code": "left_shift" } ], 196 | "to_if_alone": [ 197 | { 198 | "key_code": "9", 199 | "modifiers": [ "left_shift" ] 200 | } 201 | ] 202 | }), 203 | basic_rule({ 204 | "from": { "key_code": "right_shift" }, 205 | "to": [ { "key_code": "right_shift" } ], 206 | "to_if_alone": [ 207 | { 208 | "key_code": "0", 209 | "modifiers": [ "right_shift" ] 210 | } 211 | ] 212 | }), 213 | # rolls 214 | basic_rule({ 215 | "from": { 216 | "key_code": "left_shift", 217 | "modifiers": { 218 | "mandatory": [ "right_shift" ] 219 | } 220 | }, 221 | "to": [ 222 | { "key_code": "left_shift" }, 223 | { "key_code": "right_shift" } 224 | ], 225 | "to_if_alone": [ 226 | { 227 | "key_code": "0", 228 | # why both? 229 | "modifiers": [ "right_shift", "left_shift" ] 230 | }, 231 | { 232 | "key_code": "9", 233 | "modifiers": [ "right_shift", "left_shift" ] 234 | } 235 | ] 236 | }), 237 | basic_rule({ 238 | "from": { 239 | "key_code": "right_shift", 240 | "modifiers": { 241 | "mandatory": [ "left_shift" ] 242 | } 243 | }, 244 | "to": [ 245 | { "key_code": "right_shift" }, 246 | { "key_code": "left_shift" } 247 | ], 248 | "to_if_alone": [ 249 | { 250 | "key_code": "9", 251 | "modifiers": [ "right_shift" ] 252 | }, 253 | { 254 | "key_code": "0", 255 | "modifiers": [ "right_shift" ] 256 | } 257 | ] 258 | }) 259 | ] 260 | 261 | SIMULTANEOUS_THRESHOLD_MS = 100 262 | SIMULTANEOUS_THRESHOLD_MS_RULE = { "basic.simultaneous_threshold_milliseconds": SIMULTANEOUS_THRESHOLD_MS } 263 | 264 | VIM_KEYS_MODE = "vim_keys_mode" 265 | VIM_KEYS_MOUSE_MODE = "vim_keys_mouse_mode" 266 | VIM_KEYS_SCROLL_MODE = "vim_keys_mode_scroll" 267 | VIM_KEYS_ARROW_MODE = "vim_keys_mode_arrows" 268 | 269 | VIM_SUBMODES = [VIM_KEYS_MOUSE_MODE, VIM_KEYS_SCROLL_MODE, VIM_KEYS_ARROW_MODE] 270 | VIM_KEYS_AFTER_UP = [ 271 | set_var(mode, 0) 272 | for mode in [VIM_KEYS_MODE] + VIM_SUBMODES 273 | ] 274 | 275 | VIM_SUBMODES_OFF = [ 276 | var_is_set(mode, 0) 277 | for mode in VIM_SUBMODES 278 | ] 279 | 280 | def basic_vim_rules(key, to, modifiers=(), extra_conditions=(), strict=True): 281 | if key.upper() == key: 282 | modifiers = ["left_shift", "right_shift"] + list(modifiers) 283 | key = key.lower() 284 | else: 285 | modifiers = [] 286 | return [ 287 | basic_rule({ 288 | "from": single_key(key, modifiers=modifiers), 289 | "to": [to], 290 | "conditions": [ 291 | var_is_set(VIM_KEYS_MODE), 292 | ] + list(extra_conditions) 293 | }), 294 | basic_rule({ 295 | "from": simultaneous_keys([VIM_MODE_KEY, key], after_up=VIM_KEYS_AFTER_UP, modifiers=modifiers, strict=strict), 296 | "to_if_alone": [ 297 | set_var(VIM_KEYS_MODE, 1), 298 | to, 299 | ], 300 | "conditions": list(extra_conditions), 301 | "parameters": SIMULTANEOUS_THRESHOLD_MS_RULE, 302 | }), 303 | ] 304 | 305 | def vim_enter_submode_rules(key, mode, modifiers=()): 306 | if key.upper() == key: 307 | modifiers = ["left_shift", "right_shift"] + list(modifiers) 308 | key = key.lower() 309 | else: 310 | modifiers = [] 311 | return [ 312 | basic_rule({ 313 | "from": single_key(key, modifiers=modifiers), 314 | "to": [ 315 | set_var(mode, 1), 316 | ], 317 | "conditions": [ 318 | var_is_set(VIM_KEYS_MODE), 319 | ], 320 | "to_after_key_up": [ 321 | set_var(mode, 0), 322 | ] 323 | }), 324 | basic_rule({ 325 | "from": simultaneous_keys([VIM_MODE_KEY, key], after_up=VIM_KEYS_AFTER_UP, modifiers=modifiers), 326 | "to": [ 327 | set_var(VIM_KEYS_MODE, 1), 328 | set_var(mode, 1), 329 | ], 330 | "parameters": SIMULTANEOUS_THRESHOLD_MS_RULE, 331 | }), 332 | ] 333 | 334 | def vim_submode_rules(mode, mode_key, key, to, modifiers=(), extra_conditions=(), strict=True): 335 | if key.upper() == key: 336 | modifiers = ["left_shift", "right_shift"] + list(modifiers) 337 | key = key.lower() 338 | else: 339 | modifiers = [] 340 | extra_conditions = list(extra_conditions) 341 | return [ 342 | *basic_vim_rules(key, to, extra_conditions=[var_is_set(mode)] + extra_conditions, modifiers=modifiers, strict=strict), 343 | basic_rule({ 344 | "from": simultaneous_keys([VIM_MODE_KEY, mode_key, key], after_up=VIM_KEYS_AFTER_UP, modifiers=modifiers, strict=strict), 345 | "to": [ 346 | set_var(VIM_KEYS_MODE, 1), 347 | set_var(mode, 1), 348 | to, 349 | ], 350 | "parameters": SIMULTANEOUS_THRESHOLD_MS_RULE, 351 | "conditions": extra_conditions 352 | }), 353 | ] 354 | 355 | 356 | def vim_scroll_rules(key, to, modifiers=(), strict=True): 357 | return vim_submode_rules(VIM_KEYS_SCROLL_MODE, SCROLL, key, to, modifiers=modifiers, strict=strict) 358 | 359 | def vim_mouse_rules(key, to, modifiers=(), strict=True): 360 | return vim_submode_rules(VIM_KEYS_MOUSE_MODE, MOUSE, key, to, modifiers=modifiers, extra_conditions=[var_is_set(VIM_KEYS_SCROLL_MODE, 0)], strict=strict) 361 | 362 | 363 | vim_keys_rules = [ 364 | *vim_enter_submode_rules(SCROLL, VIM_KEYS_SCROLL_MODE), 365 | *vim_scroll_rules(DOWN, { "mouse_key": { "vertical_wheel": MOUSE_SCROLL_SPEED }}), 366 | *vim_scroll_rules(UP, { "mouse_key": { "vertical_wheel": -MOUSE_SCROLL_SPEED }}), 367 | *vim_scroll_rules(LEFT, { "mouse_key": { "horizontal_wheel": MOUSE_SCROLL_SPEED }}), 368 | *vim_scroll_rules(RIGHT, { "mouse_key": { "horizontal_wheel": -MOUSE_SCROLL_SPEED }}), 369 | # *vim_enter_submode_rules(ARROW, VIM_KEYS_ARROW_MODE), 370 | *vim_enter_submode_rules(MOUSE, VIM_KEYS_MOUSE_MODE), 371 | *vim_mouse_rules(DOWN, { "mouse_key": { "y": MOUSE_SPEED }}, strict=False), 372 | *vim_mouse_rules(UP, { "mouse_key": { "y": -MOUSE_SPEED }}, strict=False), 373 | *vim_mouse_rules(LEFT, { "mouse_key": { "x": -MOUSE_SPEED }}, strict=False), 374 | *vim_mouse_rules(RIGHT, { "mouse_key": { "x": MOUSE_SPEED }}, strict=False), 375 | *vim_mouse_rules(LEFT_CLICK, { "pointing_button": "button1" }), 376 | *vim_mouse_rules(MIDDLE_CLICK, { "pointing_button": "button3" }), 377 | *vim_mouse_rules(RIGHT_CLICK, { "pointing_button": "button2" }), 378 | *vim_mouse_rules(LEFT_CLICK_2, { "pointing_button": "button1" }), 379 | *vim_mouse_rules(MIDDLE_CLICK_2, { "pointing_button": "button3" }), 380 | *vim_mouse_rules(RIGHT_CLICK_2, { "pointing_button": "button2" }), 381 | *basic_vim_rules(FAST, { "mouse_key": { "speed_multiplier": MOUSE_FAST_MULTIPLIER } }), 382 | *basic_vim_rules(SLOW, { "mouse_key": { "speed_multiplier": MOUSE_SLOW_MULTIPLIER } }), 383 | *basic_vim_rules(DOWN, { "key_code": "down_arrow" }, extra_conditions=VIM_SUBMODES_OFF), 384 | *basic_vim_rules(UP, { "key_code": "up_arrow" }, extra_conditions=VIM_SUBMODES_OFF), 385 | *basic_vim_rules(LEFT, { "key_code": "left_arrow" }, extra_conditions=VIM_SUBMODES_OFF), 386 | *basic_vim_rules(RIGHT, { "key_code": "right_arrow" }, extra_conditions=VIM_SUBMODES_OFF), 387 | # these are just not that much easier than using arrows and holding option or command 388 | # *basic_vim_rules("f", { "key_code": "right_arrow", "modifiers": ["option"] }, extra_conditions=VIM_SUBMODES_OFF), 389 | # *basic_vim_rules("w", { "key_code": "right_arrow", "modifiers": ["option"] }, extra_conditions=VIM_SUBMODES_OFF), 390 | # *basic_vim_rules("b", { "key_code": "left_arrow", "modifiers": ["option"] }, extra_conditions=VIM_SUBMODES_OFF), 391 | # *basic_vim_rules("J", { "key_code": "down_arrow", "modifiers": ["option"] }, extra_conditions=VIM_SUBMODES_OFF), 392 | # *basic_vim_rules("K", { "key_code": "up_arrow", "modifiers": ["option"] }, extra_conditions=VIM_SUBMODES_OFF), 393 | # *basic_vim_rules("H", { "key_code": "left_arrow", "modifiers": ["left_command"] }, extra_conditions=VIM_SUBMODES_OFF), 394 | # *basic_vim_rules("L", { "key_code": "right_arrow", "modifiers": ["left_command"] }, extra_conditions=VIM_SUBMODES_OFF), 395 | # *basic_vim_rules("g", { "key_code": "up_arrow", "modifiers": ["left_command"] }, extra_conditions=VIM_SUBMODES_OFF), 396 | # *basic_vim_rules("G", { "key_code": "down_arrow", "modifiers": ["left_command"] }, extra_conditions=VIM_SUBMODES_OFF), 397 | ] 398 | 399 | complex_rules = [ 400 | # { 401 | # "description": "Mouse Mode", 402 | # "manipulators": mouse_mode_rules, 403 | # }, 404 | { 405 | "description": f"Tab: tab to switch apps", 406 | "manipulators": tab_app_manager_rules, 407 | }, 408 | { 409 | "description": f"Vim Keys: Semicolon to enable", 410 | "manipulators": vim_keys_rules, 411 | }, 412 | { 413 | "description": "Caps Lock to Control, Escape on single press.", 414 | "manipulators": caps_lock_rules, 415 | }, 416 | # { 417 | # "description": "Right Command to Escape.", 418 | # "manipulators": right_command_rules, 419 | # }, 420 | # { 421 | # "description": "semicolon = arrows", 422 | # "manipulators": arrow_rules, 423 | # }, 424 | { 425 | "description": "Better Shifting: Parentheses on shift keys", 426 | "manipulators": shift_rules, 427 | }, 428 | # { 429 | # "description": f"Vim mode rules: hold {VIM_MODE_KEY} to enable", 430 | # "manipulators": vim_keys_rules, 431 | # }, 432 | { 433 | "description": "Change caps + space to backspace", 434 | "manipulators": [ 435 | basic_rule({ 436 | # use left control since we map caps to that 437 | "from": single_key("spacebar", [ "left_control" ]), 438 | "to": [ { "key_code": "delete_or_backspace" } ], 439 | }), 440 | ] 441 | }, 442 | ] 443 | 444 | path = os.path.join( 445 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 446 | "config/karabiner/karabiner.json" 447 | ) 448 | with open(path, "r") as f: 449 | data = json.load(f) 450 | with open(path, "w") as f: 451 | assert len(data['profiles']) == 1 452 | profile = data['profiles'][0] 453 | profile['simple_modifications'] = simple_rules 454 | profile['complex_modifications']['rules'] = complex_rules 455 | json.dump(data, f, indent=4) 456 | 457 | with open(os.path.realpath(__file__).replace('.py', '.json'), 'w') as f: 458 | json.dump({ 459 | "title": "Jeff Wu's karabiner settings", 460 | "rules": complex_rules, 461 | }, f, indent=2) 462 | -------------------------------------------------------------------------------- /spacemacs: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | ;; This file is loaded by Spacemacs at startup. 3 | ;; It must be stored in your home directory. 4 | 5 | ;; TODO: 6 | ;; - explore using layouts to mitigate global buffers issue? 7 | ;; - find-file-at-point (gf) should automatically choose when there's only one result 8 | ;; SEE: https://github.com/syl20bnr/spacemacs/issues/4837 9 | ;; - get python autocomplete working properly: https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/python 10 | ;; - figure out shell within emacs (https://github.com/syl20bnr/spacemacs/tree/master/layers/shell) 11 | ;; - make "tab" not bring up helm completion-at-point when there's nothing to complete 12 | ;; - alternative to minibufexpl 13 | 14 | (defun dotspacemacs/layers () 15 | "Configuration Layers declaration. 16 | You should not put any user code in this function besides modifying the variable 17 | values." 18 | (setq-default 19 | ;; Base distribution to use. This is a layer contained in the directory 20 | ;; `+distribution'. For now available distributions are `spacemacs-base' 21 | ;; or `spacemacs'. (default 'spacemacs) 22 | dotspacemacs-distribution 'spacemacs 23 | ;; List of additional paths where to look for configuration layers. 24 | ;; Paths must have a trailing slash (i.e. `~/.mycontribs/') 25 | dotspacemacs-configuration-layer-path '() 26 | ;; List of configuration layers to load. If it is the symbol `all' instead 27 | ;; of a list then all discovered layers will be installed. 28 | dotspacemacs-configuration-layers 29 | '( 30 | 31 | ;; ---------------------------------------------------------------- 32 | ;; Example of useful layers you may want to use right away. 33 | ;; Uncomment some layer names and press (Vim style) or 34 | ;; (Emacs style) to install them. 35 | ;; ---------------------------------------------------------------- 36 | (auto-completion 37 | :variables 38 | auto-completion-return-key-behavior 'complete 39 | auto-completion-tab-key-behavior 'cycle 40 | auto-completion-complete-with-key-sequence nil 41 | auto-completion-complete-with-key-sequence-delay 0.1 42 | auto-completion-private-snippets-directory nil 43 | auto-completion-enable-snippets-in-popup t 44 | auto-completion-enable-help-tooltip t 45 | auto-completion-enable-sort-by-usage t 46 | ) 47 | emacs-lisp 48 | git 49 | fasd 50 | ;; markdown 51 | org 52 | ;; (shell :variables 53 | ;; shell-default-height 30 54 | ;; shell-default-position 'bottom) 55 | osx 56 | ranger 57 | ;; spell-checking 58 | syntax-checking 59 | (version-control 60 | :variables 61 | version-control-global-margin nil 62 | ) 63 | python 64 | rust 65 | javascript 66 | react 67 | ) 68 | ;; List of additional packages that will be installed without being 69 | ;; wrapped in a layer. If you need some configuration for these 70 | ;; packages, then consider creating a layer. You can also put the 71 | ;; configuration in `dotspacemacs/user-config'. 72 | dotspacemacs-additional-packages '() 73 | ;; A list of packages and/or extensions that will not be install and loaded. 74 | dotspacemacs-excluded-packages '() 75 | ;; If non-nil spacemacs will delete any orphan packages, i.e. packages that 76 | ;; are declared in a layer which is not a member of 77 | ;; the list `dotspacemacs-configuration-layers'. (default t) 78 | dotspacemacs-delete-orphan-packages t 79 | )) 80 | 81 | (defun dotspacemacs/init () 82 | "Initialization function. 83 | This function is called at the very startup of Spacemacs initialization 84 | before layers configuration. 85 | You should not put any user code in there besides modifying the variable 86 | values." 87 | ;; This setq-default sexp is an exhaustive list of all the supported 88 | ;; spacemacs settings. 89 | (setq-default 90 | ;; If non nil ELPA repositories are contacted via HTTPS whenever it's 91 | ;; possible. Set it to nil if you have no way to use HTTPS in your 92 | ;; environment, otherwise it is strongly recommended to let it set to t. 93 | ;; This variable has no effect if Emacs is launched with the parameter 94 | ;; `--insecure' which forces the value of this variable to nil. 95 | ;; (default t) 96 | dotspacemacs-elpa-https t 97 | ;; Maximum allowed time in seconds to contact an ELPA repository. 98 | dotspacemacs-elpa-timeout 5 99 | ;; If non nil then spacemacs will check for updates at startup 100 | ;; when the current branch is not `develop'. (default t) 101 | dotspacemacs-check-for-update t 102 | ;; One of `vim', `emacs' or `hybrid'. Evil is always enabled but if the 103 | ;; variable is `emacs' then the `holy-mode' is enabled at startup. `hybrid' 104 | ;; uses emacs key bindings for vim's insert mode, but otherwise leaves evil 105 | ;; unchanged. (default 'vim) 106 | dotspacemacs-editing-style 'vim 107 | ;; If non nil output loading progress in `*Messages*' buffer. (default nil) 108 | dotspacemacs-verbose-loading nil 109 | ;; Specify the startup banner. Default value is `official', it displays 110 | ;; the official spacemacs logo. An integer value is the index of text 111 | ;; banner, `random' chooses a random text banner in `core/banners' 112 | ;; directory. A string value must be a path to an image format supported 113 | ;; by your Emacs build. 114 | ;; If the value is nil then no banner is displayed. (default 'official) 115 | dotspacemacs-startup-banner 'official 116 | ;; List of items to show in the startup buffer. If nil it is disabled. 117 | ;; Possible values are: `recents' `bookmarks' `projects'. 118 | ;; (default '(recents projects)) 119 | dotspacemacs-startup-lists '(recents projects) 120 | ;; Number of recent files to show in the startup buffer. Ignored if 121 | ;; `dotspacemacs-startup-lists' doesn't include `recents'. (default 5) 122 | dotspacemacs-startup-recent-list-size 5 123 | ;; Default major mode of the scratch buffer (default `text-mode') 124 | dotspacemacs-scratch-mode 'text-mode 125 | ;; List of themes, the first of the list is loaded when spacemacs starts. 126 | ;; Press T n to cycle to the next theme in the list (works great 127 | ;; with 2 themes variants, one dark and one light) 128 | dotspacemacs-themes '(spacemacs-dark 129 | spacemacs-light 130 | ) 131 | ;; solarized-light 132 | ;; solarized-dark 133 | ;; leuven 134 | ;; monokai 135 | ;; zenburn) 136 | ;; If non nil the cursor color matches the state color in GUI Emacs. 137 | dotspacemacs-colorize-cursor-according-to-state t 138 | ;; Default font. `powerline-scale' allows to quickly tweak the mode-line 139 | ;; size to make separators look not too crappy. 140 | dotspacemacs-default-font '("Source Code Pro" 141 | :size 13 142 | :weight normal 143 | :width normal 144 | :powerline-scale 1.1) 145 | ;; The leader key 146 | dotspacemacs-leader-key "SPC" 147 | ;; The leader key accessible in `emacs state' and `insert state' 148 | ;; (default "M-m") 149 | dotspacemacs-emacs-leader-key "M-m" 150 | ;; Major mode leader key is a shortcut key which is the equivalent of 151 | ;; pressing ` m`. Set it to `nil` to disable it. (default ",") 152 | dotspacemacs-major-mode-leader-key "," 153 | ;; Major mode leader key accessible in `emacs state' and `insert state'. 154 | ;; (default "C-M-m) 155 | dotspacemacs-major-mode-emacs-leader-key "C-M-m" 156 | ;; These variables control whether separate commands are bound in the GUI to 157 | ;; the key pairs C-i, TAB and C-m, RET. 158 | ;; Setting it to a non-nil value, allows for separate commands under 159 | ;; and TAB or and RET. 160 | ;; In the terminal, these pairs are generally indistinguishable, so this only 161 | ;; works in the GUI. (default nil) 162 | dotspacemacs-distinguish-gui-tab nil 163 | ;; (Not implemented) dotspacemacs-distinguish-gui-ret nil 164 | ;; The command key used for Evil commands (ex-commands) and 165 | ;; Emacs commands (M-x). 166 | ;; By default the command key is `:' so ex-commands are executed like in Vim 167 | ;; with `:' and Emacs commands are executed with ` :'. 168 | dotspacemacs-command-key ":" 169 | ;; If non nil `Y' is remapped to `y$'. (default t) 170 | dotspacemacs-remap-Y-to-y$ t 171 | ;; Name of the default layout (default "Default") 172 | dotspacemacs-default-layout-name "Default" 173 | ;; If non nil the default layout name is displayed in the mode-line. 174 | ;; (default nil) 175 | dotspacemacs-display-default-layout nil 176 | ;; If non nil then the last auto saved layouts are resume automatically upon 177 | ;; start. (default nil) 178 | dotspacemacs-auto-resume-layouts nil 179 | ;; Location where to auto-save files. Possible values are `original' to 180 | ;; auto-save the file in-place, `cache' to auto-save the file to another 181 | ;; file stored in the cache directory and `nil' to disable auto-saving. 182 | ;; (default 'cache) 183 | dotspacemacs-auto-save-file-location 'cache 184 | ;; Maximum number of rollback slots to keep in the cache. (default 5) 185 | dotspacemacs-max-rollback-slots 5 186 | ;; If non nil then `ido' replaces `helm' for some commands. For now only 187 | ;; `find-files' (SPC f f), `find-spacemacs-file' (SPC f e s), and 188 | ;; `find-contrib-file' (SPC f e c) are replaced. (default nil) 189 | dotspacemacs-use-ido nil 190 | ;; If non nil, `helm' will try to minimize the space it uses. (default nil) 191 | dotspacemacs-helm-resize nil 192 | ;; if non nil, the helm header is hidden when there is only one source. 193 | ;; (default nil) 194 | dotspacemacs-helm-no-header nil 195 | ;; define the position to display `helm', options are `bottom', `top', 196 | ;; `left', or `right'. (default 'bottom) 197 | dotspacemacs-helm-position 'bottom 198 | ;; If non nil the paste micro-state is enabled. When enabled pressing `p` 199 | ;; several times cycle between the kill ring content. (default nil) 200 | dotspacemacs-enable-paste-micro-state t 201 | ;; Which-key delay in seconds. The which-key buffer is the popup listing 202 | ;; the commands bound to the current keystroke sequence. (default 0.4) 203 | dotspacemacs-which-key-delay 0.4 204 | ;; Which-key frame position. Possible values are `right', `bottom' and 205 | ;; `right-then-bottom'. right-then-bottom tries to display the frame to the 206 | ;; right; if there is insufficient space it displays it at the bottom. 207 | ;; (default 'bottom) 208 | dotspacemacs-which-key-position 'bottom 209 | ;; If non nil a progress bar is displayed when spacemacs is loading. This 210 | ;; may increase the boot time on some systems and emacs builds, set it to 211 | ;; nil to boost the loading time. (default t) 212 | dotspacemacs-loading-progress-bar t 213 | ;; If non nil the frame is fullscreen when Emacs starts up. (default nil) 214 | ;; (Emacs 24.4+ only) 215 | dotspacemacs-fullscreen-at-startup nil 216 | ;; If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen. 217 | ;; Use to disable fullscreen animations in OSX. (default nil) 218 | dotspacemacs-fullscreen-use-non-native nil 219 | ;; If non nil the frame is maximized when Emacs starts up. 220 | ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil. 221 | ;; (default nil) (Emacs 24.4+ only) 222 | dotspacemacs-maximized-at-startup nil 223 | ;; A value from the range (0..100), in increasing opacity, which describes 224 | ;; the transparency level of a frame when it's active or selected. 225 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 226 | dotspacemacs-active-transparency 90 227 | ;; A value from the range (0..100), in increasing opacity, which describes 228 | ;; the transparency level of a frame when it's inactive or deselected. 229 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 230 | dotspacemacs-inactive-transparency 90 231 | ;; If non nil unicode symbols are displayed in the mode line. (default t) 232 | dotspacemacs-mode-line-unicode-symbols t 233 | ;; If non nil smooth scrolling (native-scrolling) is enabled. Smooth 234 | ;; scrolling overrides the default behavior of Emacs which recenters the 235 | ;; point when it reaches the top or bottom of the screen. (default t) 236 | dotspacemacs-smooth-scrolling t 237 | ;; If non nil line numbers are turned on in all `prog-mode' and `text-mode' 238 | ;; derivatives. If set to `relative', also turns on relative line numbers. 239 | ;; (default nil) 240 | dotspacemacs-line-numbers nil 241 | ;; If non-nil smartparens-strict-mode will be enabled in programming modes. 242 | ;; (default nil) 243 | dotspacemacs-smartparens-strict-mode nil 244 | ;; Select a scope to highlight delimiters. Possible values are `any', 245 | ;; `current', `all' or `nil'. Default is `all' (highlight any scope and 246 | ;; emphasis the current one). (default 'all) 247 | dotspacemacs-highlight-delimiters 'all 248 | ;; If non nil advises quit functions to keep server open when quitting. 249 | ;; (default nil) 250 | dotspacemacs-persistent-server nil 251 | ;; List of search tool executable names. Spacemacs uses the first installed 252 | ;; tool of the list. Supported tools are `ag', `pt', `ack' and `grep'. 253 | ;; (default '("ag" "pt" "ack" "grep")) 254 | dotspacemacs-search-tools '("ag" "pt" "ack" "grep") 255 | ;; The default package repository used if no explicit repository has been 256 | ;; specified with an installed package. 257 | ;; Not used for now. (default nil) 258 | dotspacemacs-default-package-repository nil 259 | ;; Delete whitespace while saving buffer. Possible values are `all' 260 | ;; to aggressively delete empty line and long sequences of whitespace, 261 | ;; `trailing' to delete only the whitespace at end of lines, `changed'to 262 | ;; delete only whitespace for changed lines or `nil' to disable cleanup. 263 | ;; (default nil) 264 | dotspacemacs-whitespace-cleanup nil 265 | )) 266 | 267 | (defun dotspacemacs/user-init () 268 | "Initialization function for user code. 269 | It is called immediately after `dotspacemacs/init', before layer configuration 270 | executes. 271 | This function is mostly useful for variables that need to be set 272 | before packages are loaded. If you are unsure, you should try in setting them in 273 | `dotspacemacs/user-config' first." 274 | ; (setq-default rust-enable-racer t) 275 | (setq vc-follow-symlinks t) 276 | (setq-default js2-basic-offset 2 277 | js-indent-level 2 278 | 279 | ;; web-mode 280 | css-indent-offset 2 281 | web-mode-markup-indent-offset 2 282 | web-mode-css-indent-offset 2 283 | web-mode-code-indent-offset 2 284 | web-mode-attr-indent-offset 2 285 | ) 286 | 287 | ; allow for ctrl-z 288 | (setq evil-toggle-key "C-`") 289 | ) 290 | 291 | (defun dotspacemacs/user-config () 292 | "Configuration function for user code. 293 | This function is called at the very end of Spacemacs initialization after 294 | layers configuration. 295 | This is the place where most of your configurations should be done. Unless it is 296 | explicitly specified that a variable should be set before a package is loaded, 297 | you should place you code here." 298 | 299 | (global-company-mode) 300 | ; (setq company-backends-python-mode '((company-anaconda :with company-dabbrev-code :with company-yasnippet))) 301 | ; (spacemacs|disable-company python-mode) 302 | 303 | ;(add-hook 'python-mode-hook 'anaconda-mode) 304 | ;(setq-default dotspacemacs-configuration-layers '((python :variables python-enable-yapf-format-on-save t))) 305 | 306 | ; remap so that ; works as : , much like `nnoremap ; :` 307 | (define-key evil-normal-state-map (kbd ";") 'evil-ex) 308 | 309 | ; configuration for ranger 310 | ;; NOTE: this seems to give a warning in newer versions of spacemacs 311 | ;; (setq-default dotspacemacs-configuration-layers 312 | ;; '(ranger :variables 313 | ;; ranger-show-preview t)) 314 | (setq ranger-ignored-extensions '("mkv" "iso" "mp4")) 315 | (setq ranger-max-preview-size 10) ; in mb 316 | ; (setq ranger-width-preview 0.55) 317 | (setq ranger-show-dotfiles t) 318 | 319 | ;; make auto complete never do helm version 320 | (setq company-idle-delay 0.0) 321 | (setq company-minimum-prefix-length 1) 322 | 323 | ;; ctrl+p behaves like vim ctrl+p 324 | (define-key evil-normal-state-map (kbd "C-p") 'helm-projectile) 325 | (define-key evil-normal-state-map (kbd "C-b") 'helm-mini) 326 | ;; ctrl+j and ctrl+k switch buffers 327 | ;; (define-key evil-normal-state-map (kbd "C-j") 'spacemacs/previous-useful-buffer) 328 | ;; (define-key evil-normal-state-map (kbd "C-k") 'spacemacs/next-useful-buffer) 329 | (define-key evil-normal-state-map (kbd "C-j") 'evil-window-down) 330 | (define-key evil-normal-state-map (kbd "C-k") 'evil-window-up) 331 | (define-key evil-normal-state-map (kbd "C-h") 'evil-window-left) 332 | (define-key evil-normal-state-map (kbd "C-l") 'evil-window-right) 333 | 334 | ;; don't yank to system clipboard by default 335 | (turn-off-pbcopy) 336 | ;; make C-c yank to system clipboard 337 | (evil-define-operator yank-to-clipboard (beg end type register yank-handler) 338 | (turn-on-pbcopy) 339 | (evil-yank beg end type register yank-handler) 340 | (turn-off-pbcopy) 341 | ) 342 | (define-key evil-normal-state-map (kbd "C-c") 'yank-to-clipboard) 343 | 344 | ;; https://github.com/abo-abo/avy 345 | ;; https://github.com/abo-abo/avy/wiki/defcustom 346 | ;; let non-homerow keys be used for avy 347 | (setq avy-keys (number-sequence ?a ?z)) 348 | 349 | ;; spaceline customization 350 | (setq powerline-default-separator 'bar) 351 | (setq spaceline-highlight-face-func 'spaceline-highlight-face-modified) ;; sets color to tell you if buffer is modified 352 | ;; (setq spaceline-evil-state-p nil) 353 | 354 | ;; try: (describe-variable 'spaceline-left) 355 | ; (spaceline-toggle-buffer-id-on) 356 | (spaceline-toggle-buffer-size-off) 357 | (spaceline-toggle-buffer-position-off) 358 | (spaceline-toggle-major-mode-off) ;; tells you e.g. what language is being edited 359 | (spaceline-toggle-minor-modes-off) 360 | (spaceline-toggle-buffer-encoding-abbrev-off) 361 | (spaceline-toggle-new-version-off) ;; tells you when spacemacs itself needs to be updated 362 | ;; stupid that this is necessary... 363 | (spaceline-compile) 364 | 365 | ;; swap qq with qz 366 | (spacemacs/set-leader-keys "qq" 'spacemacs/frame-killer) 367 | (spacemacs/set-leader-keys "qz" 'spacemacs/prompt-kill-emacs) 368 | 369 | ;; fix line number spacing in iterm: https://github.com/syl20bnr/spacemacs/issues/5609 370 | (unless (display-graphic-p) 371 | (setq linum-format (concat linum-format " "))) 372 | 373 | ;; (add-to-list projectile-globally-ignored-directories "node_modules") 374 | 375 | ;; prevents tabbing on empty lines: https://github.com/syl20bnr/spacemacs/issues/4478 376 | ;; still not good enough though since it doesn't help if you're tabbed over... 377 | (setq tab-always-indent t) 378 | 379 | ) 380 | 381 | ;; Do not write anything past this comment. This is where Emacs will 382 | ;; auto-generate custom variable definitions. 383 | (custom-set-variables 384 | ;; custom-set-variables was added by Custom. 385 | ;; If you edit it by hand, you could mess it up, so be careful. 386 | ;; Your init file should contain only one such instance. 387 | ;; If there is more than one, they won't work right. 388 | '(column-number-mode t) 389 | '(menu-bar-mode nil)) 390 | (custom-set-faces 391 | ;; custom-set-faces was added by Custom. 392 | ;; If you edit it by hand, you could mess it up, so be careful. 393 | ;; Your init file should contain only one such instance. 394 | ;; If there is more than one, they won't work right. 395 | '(company-tooltip-common ((t (:inherit company-tooltip :weight bold :underline nil)))) 396 | '(company-tooltip-common-selection ((t (:inherit company-tooltip-selection :weight bold :underline nil))))) 397 | -------------------------------------------------------------------------------- /gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | name = Jeff Wu 3 | email = wuthefwasthat@gmail.com 4 | [core] 5 | # editor = vim -V9/tmp/myVim.log 6 | editor = nvim 7 | 8 | # pager = "if which icdiff > /dev/null; then PAG='git difftool --no-prompt --extcmd=\"icdiff\"'; else PAG='less'; fi; $PAG" 9 | pager = "if which delta > /dev/null; then PAG='delta -s'; else PAG='less'; fi; $PAG" 10 | excludesfile = ~/.gitignore_global 11 | 12 | # [interactive] 13 | # diffFilter = delta --color-only -s 14 | [delta] 15 | navigate = true # use n and N to move between diff sections 16 | # syntax-theme = zenburn 17 | minus-style = "#eeaaaa" bold "#440000" 18 | minus-emph-style = "#eeaaaa" bold "#440000" 19 | minus-non-emph-style = "#eeaa88" bold "#444422" 20 | plus-style = "#aaeeaa" bold "#004400" 21 | plus-emph-style = "#aaeeaa" bold "#004400" 22 | plus-non-emph-style = "#aaee88" bold "#444422" 23 | [alias] 24 | # TODO: DIFF TOOL, ACTUALLY MAYBE ... https://difftastic.wilfred.me.uk/git.html 25 | 26 | # https://github.com/jeffkaufman/icdiff 27 | # configuration 28 | # icdiff = "!f() { git difftool --no-prompt --extcmd=\"icdiff $(git config --get icdiff.options)\" \"$@\" | less -R; }; f" 29 | # differ = "!f() { if which icdiff > /dev/null; then echo icdiff; else echo diff; fi; }; f" 30 | 31 | # main = "!f() { git symbolic-ref refs/remotes/origin/HEAD | sed \"s@^refs/remotes/origin/@@\"; }; f" 32 | main = "!f() { git remote show origin | sed -n '/HEAD branch/s/.*: //p'; }; f" 33 | delta = "!f() { git diff \"$@\" | delta -s; }; f" 34 | differ = "!f() { if which delta > /dev/null; then echo delta; else echo diff; fi; }; f" 35 | 36 | # editor = config --get core.editor 37 | editor = "!f() { if [ \"$ZED_TERM\" = \"true\" ]; then echo "zed -p"; else echo $(git config --get core.editor); fi; }; f" 38 | 39 | # editor = ! echo "emacsclient -c" 40 | alias = "!f() { pattern=$@; git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e 's/ / = /' | awk -v pat=\"$pattern\" '{ if ($0 ~ pat) print }' | sort -u; }; f" 41 | which = "!f() { pattern=$@; git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e 's/ / = /' | awk -v pat=\"$pattern\" -F '=' '{ if ($1 ~ pat) print $0 }' | sort -u; }; f" 42 | 43 | linecount = "!f() { git ls-files $@ | grep -v package-lock.json | grep -v Pipfile.lock | xargs cat | wc -l; }; f" 44 | linecounts = "!f() { for f in $(git ls-files $@ | grep -v package-lock.json | grep -v Pipfile.lock); do echo $(wc -l $f); done; }; f" 45 | 46 | # utils 47 | root = rev-parse --show-toplevel 48 | # executes command at git root 49 | rooted = "!git" 50 | # functions screw up directory: see https://stackoverflow.com/questions/26243145/git-aliases-operate-in-the-wrong-directory 51 | relative = "!f() { if [ -n \"$GIT_PREFIX\" ]; then echo \"$GIT_PREFIX\"; else echo \".\"; fi; }; f" 52 | # chains multiple commands (note: after first one, can't have spaces, for now) 53 | chain = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; if [ $# -eq 0 ]; then return 0; fi; git $1; shift; git chain $@; }; f" 54 | 55 | 56 | # setup 57 | clo = clone --recursive 58 | in = '!git init && git commit -m "root" --allow-empty' 59 | # https://github.com/$1.git 60 | # git@github.com:$1.git 61 | 62 | # branch management 63 | b = branch -vv --sort=committerdate 64 | bb = rev-parse --abbrev-ref HEAD 65 | # bb = branch --show-current # works in newer version of git 66 | ba = branch -vv -a 67 | co = checkout 68 | coo = "!f() { git fetch origin $@; git checkout $@; }; f" 69 | com = "!f() { git checkout $(git main) $@; }; f" 70 | cop = checkout -p 71 | new = checkout -b 72 | bd = branch -D 73 | bdm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d" 74 | # delete a branch (default to current branch). if current branch deleted, checkout main 75 | bx = "!f() { \ 76 | local onbranch=$(git bb); \ 77 | local branch=${1:-$onbranch}; \ 78 | local mainbranch=$(git main); \ 79 | if [ \"$branch\" = \"$mainbranch\" ]; then \ 80 | echo \"Can't delete $mainbranch!\"; \ 81 | return 1; \ 82 | fi; \ 83 | if [ \"$branch\" = \"$onbranch\" ]; then \ 84 | git checkout $mainbranch; \ 85 | fi && \ 86 | git tag -f shelved/$branch $branch && \ 87 | git branch -D $branch; \ 88 | shift; \ 89 | if [ $# -gt 0 ]; then git bx \"$@\"; fi; \ 90 | }; f" 91 | # delete remote branch 92 | bxr = "!f() { \ 93 | local onbranch=$(git bb); \ 94 | local branch=${1:-$onbranch}; \ 95 | git push origin :$branch; \ 96 | }; f" 97 | # Remove branches that have already been merged with main, a.k.a. ‘delete merged’ 98 | done = "!f() { \ 99 | local mybranch=$(git bb); \ 100 | local mainbranch=$(git main); \ 101 | if [ \"$mybranch\" != \"$mainbranch\" ]; then git checkout $mainbranch; git reset --hard $mybranch; fi; \ 102 | git fetch; git rebase origin/$mainbranch; git push origin $mainbranch; \ 103 | if [ \"$mybranch\" != \"$mainbranch\" ]; then git branch -D $mybranch; git push origin :$mybranch; fi; \ 104 | }; f" 105 | 106 | rmc = "rm --cached" 107 | 108 | # remotes 109 | # f = "!f() { git chain 'fetch --all --prune' $@; }; f" 110 | f = "!f() { \ 111 | if [ \"$(git root)\" = \"$HOME/openai/openai\" ]; then \ 112 | git fetch origin "refs/heads/${OPENAI_USER}*:refs/remotes/origin/${OPENAI_USER}*"; \ 113 | git fetch origin master; \ 114 | git chain $@; \ 115 | else \ 116 | git chain 'fetch --all --prune' $@; \ 117 | fi; \ 118 | }; f" 119 | pu = "push -u" 120 | put = "push --tags" 121 | pun = "push --no-verify" 122 | puf = "push -u --force-with-lease" 123 | pufn = "push -u --force-with-lease --no-verify" 124 | pufback = "!f() { local nback=${1:-1}; git puf origin HEAD~${nback}:$(git b --show-current); }; f" 125 | puback = "!f() { local nback=${1:-1}; git pu origin HEAD~${nback}:$(git b --show-current); }; f" 126 | pl = "pull" 127 | plr = "pull --rebase" 128 | pla = "!f() { git pull; git submodule foreach git pull origin $(git main); }; f" 129 | rmp = "!f(){ remote=${1:-origin}; git remote prune $remote; }; f" 130 | track = "!f(){ branch=$(git bb); cmd=\"git branch $branch -u ${1:-origin}/${2:-$branch}\"; echo $cmd; $cmd; }; f" 131 | untrack = "!f(){ branch=$(git bb); cmd=\"git branch --unset-upstream ${1:-$branch}\"; echo $cmd; $cmd; }; f" 132 | # todo: get autocomplete for this 133 | # todo: get better prompt 134 | # i = !repl git 135 | i = "!f(){ \ 136 | while true; do \ 137 | read -e -p \"git $ \" line; \ 138 | if [ -z \"$line\" ]; then continue; fi; \ 139 | if [ \"$line\" == \"q\" ]; then break; fi; \ 140 | if [ \"${line:0:1}\" == \"!\" ]; then \ 141 | eval \"${line:1}\"; \ 142 | else \ 143 | eval \"git $line\"; \ 144 | fi; \ 145 | done }; f" 146 | 147 | remoteuser = "!f() { \ 148 | remote=${1:-origin}; \ 149 | git_remote=$(git remote -v | head -n 1 | cut -f 2 -d ':'); \ 150 | echo $(git remote get-url $remote | cut -f 2 -d ':' | cut -f 1 -d '/'); \ 151 | }; f" 152 | 153 | remoterepo = "!f() { \ 154 | remote=${1:-origin}; \ 155 | git_remote=$(git remote -v | head -n 1 | cut -f 2 -d ':'); \ 156 | git_repo=$(git remote get-url $remote | cut -f 2 -d ':' | cut -f 2 -d '/'); \ 157 | git_repo=${git_repo::$((${#git_repo}-4))}; \ 158 | echo $git_repo; \ 159 | }; f" 160 | 161 | # github 162 | pr = "!git push; hub pull-request" 163 | # pr = "!f() { \ 164 | # local remote=${1:-origin}; \ 165 | # local mainbranch=$(git main); \ 166 | # git push; \ 167 | # git_user=$(git remoteuser); \ 168 | # git_repo=$(git remoterepo); \ 169 | # cur_branch=$(git bb); \ 170 | # echo open \"https://github.com/$git_user/$git_repo/compare/$mainbranch...$cur_branch\"; \ 171 | # # open \"https://github.com/$git_user/$git_repo/pull/create?base=$git_user%3A$mainbranch&head=$git_user%3A$cur_branch\"; \n\ 172 | # open \"https://github.com/$git_user/$git_repo/compare/$mainbranch...$cur_branch\"; \ 173 | # }; f" 174 | try = "!f() { \ 175 | if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; \ 176 | while ! git $@; do sleep 1; done; \ 177 | }; f" 178 | prm = "!f() { \ 179 | local remote=${1-origin}; \ 180 | local branch=${2:-$(git bb)}; \ 181 | local merge_method=${3:-merge}; \ 182 | local GITHUB_TOKEN=$(cat ~/.github_token); \ 183 | local user=$(git remoteuser $remote); \ 184 | local repo=$(git remoterepo $remote); \ 185 | echo https://api.github.com/repos/$user/$repo/pulls; \ 186 | prnum=$(curl -s -X GET -H \"Authorization: token $GITHUB_TOKEN\" https://api.github.com/repos/$user/$repo/pulls | jq '.[] | select(.head.ref==\"'$branch'\") | .number'); \ 187 | echo https://api.github.com/repos/$user/$repo/pulls/$prnum/merge; \ 188 | curl -s -X PUT -H \"Authorization: token $GITHUB_TOKEN\" -d '{\"merge_method\": \"'$merge_method'\"}' https://api.github.com/repos/$user/$repo/pulls/$prnum/merge | tee /dev/tty | grep '\"merged\": true'; \ 189 | exit $?; \ 190 | }; f" 191 | prr = "!f() { local remote=${1:-origin}; local branch=${2:-$(git bb)}; git prm $remote $branch rebase; }; f" 192 | prs = "!f() { local remote=${1:-origin}; local branch=${2:-$(git bb)}; git prm $remote $branch squash; }; f" 193 | trypr = "!f() { \ 194 | local remote=${1-origin}; \ 195 | local branch=${2:-$(git bb)}; \ 196 | local mainbranch=$(git main); \ 197 | local merge_method=${3:-rebase}; \ 198 | git try prm $remote $branch $merge_method; \ 199 | if [ \"$branch\" != \"$mainbranch\" ]; then \ 200 | if [ \"$branch\" == \"$(git bb)\" ]; then \ 201 | git checkout $mainbranch; \ 202 | fi; \ 203 | git branch -D $branch; git push origin :$branch; \ 204 | fi; \ 205 | }; f" 206 | donepr = "!f() { \ 207 | local remote=${1-origin}; \ 208 | local mybranch=${2:-$(git bb)}; \ 209 | local mainbranch=$(git main); \ 210 | local merge_method=${3:-rebase}; \ 211 | git prm $remote $mybranch $merge_method || echo fail to merge && exit 1; \ 212 | if [ \"$mybranch\" != \"$mainbranch\" ]; then git checkout $mainbranch; git branch -D $mybranch; git push origin :$mybranch; fi; \ 213 | }; f" 214 | doneprr = "!f() { local remote=${1:-origin}; git donepr $remote rebase; }; f" 215 | doneprs = "!f() { local remote=${1:-origin}; git donepr $remote squash; }; f" 216 | h = "!f() { hash=${1:-$(git bb)}; hub browse -- tree/$hash; }; f" 217 | hi = "!hub browse -- issues" 218 | hin = "!hub browse -- issues/new" 219 | hp = "!f() { pr=$1; if [ -z \"$1\" ]; then hub browse -- pulls; else hub browse -- pull/$pr ; fi; }; f" 220 | hf = "!f() { local mainbranch=$(git main); hub browse -- find/$mainbranch; }; f" 221 | hop = "!f() { local mainbranch=$(git main); hub browse -- blob/$mainbranch/$(git find \"$@\" | head -n 1); }; f" 222 | # hub log 223 | hl = "!f() { hash=${1:-$(git rev-parse HEAD)}; hub browse -- commits/$hash; }; f" 224 | # hub show 225 | hs = "!f() { hash=${1:-$(git rev-parse HEAD)}; hub browse -- commit/$hash; }; f" 226 | 227 | # does commit contain another (HEAD vs $1) or ($1 vs $2) 228 | has = "!f() { \ 229 | if [[ $# -eq 1 ]]; then \ 230 | up=$1; down=HEAD; \ 231 | elif [[ $# -eq 2 ]]; then \ 232 | up=$2; down=$1; \ 233 | else echo \"⚠️ Usage: ghas OR ghas \"; \ 234 | fi; \ 235 | if $(git merge-base --is-ancestor $up $down); then \ 236 | echo \"✅ Yes, $down has $up\" && exit 0; \ 237 | else echo \"❌ No, $down does not have $up\" && exit 1; \ 238 | fi; \ 239 | }; f" 240 | issue = "!hub issue" 241 | fork = "!hub fork" 242 | 243 | # working tree 244 | a = add 245 | aahelper = "!git add .; git add -u ." 246 | aa = "!f() { git chain 'aahelper' $@; }; f" 247 | aac = "!f() { git aahelper; git ac $@; }; f" 248 | ap = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; local dir=${1:-.}; git add -p $dir; }; f" 249 | # cleanup 250 | cle = clean -f -d 251 | # discard 252 | xx = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; local dir=${1:-.}; git checkout -- $dir; }; f" 253 | # unstage 254 | z = "!f(){ if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; local dir=${1:-.}; git reset HEAD $dir; }; f" 255 | 256 | # committing (optionally with message) 257 | c = "!f() { if [ $# -eq 0 ]; then git commit -v; else git commit -m \"$*\"; fi; }; f" 258 | # commit "squash" 259 | cs = "!f() { if [ $# -eq 0 ]; then git commit -v --amend; else git commit --amend -m \"$*\"; fi; }; f" 260 | # commit "fixup" 261 | cf = commit -v --amend --no-edit 262 | # add then commit variants 263 | ac = "!f() { if [ $# -eq 0 ]; then git commit -v -a; else git commit -a -m \"$*\"; fi; }; f" 264 | acs = "!f() { if [ $# -eq 0 ]; then git commit -v -a --amend; else git commit -a --amend -m \"$*\"; fi; }; f" 265 | acf = "!f() { git chain 'commit -v -a --amend --no-edit' $@; }; f" 266 | 267 | # cherry-pick 268 | cp = cherry-pick 269 | cpa = cherry-pick --abort 270 | cpc = cherry-pick --continue 271 | 272 | # rebase 273 | rb = rebase 274 | rbi = rebase -i 275 | rbin = "!f() { local n=${1:-1}; git rebase -i HEAD~$n; }; f" 276 | rba = rebase --abort 277 | rbs = rebase --skip 278 | rbc = "!git add .; git add -u .; git rebase --continue" 279 | rbo = "!f(){ local branch=$(git bb); git rebase origin/$branch $@; }; f" 280 | rboi = "!f(){ local branch=$(git bb); git rebase origin/$branch -i $@; }; f" 281 | rbm = "!f(){ local mainbranch=$(git main); git rebase $mainbranch $@; }; f" 282 | rbmi = rbm -i 283 | rbom = "!f(){ local mainbranch=$(git main); git rebase origin/$mainbranch $@; }; f" 284 | rbomi = rbom -i 285 | from = "!f() { git chain f rbom $@; }; f" 286 | fro = "!f() { git chain f rbo $@; }; f" 287 | 288 | # merge 289 | m = merge 290 | ma = merge --abort 291 | 292 | # open merge conflicts (good for rebase/cherry-pick/merge too) 293 | mop = "!f() { $(git editor) $(git diff --name-only --diff-filter=U); }; f" 294 | 295 | # diffs 296 | d = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git $(git differ) $@; }; f" 297 | dc = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git $(git differ) --cached $@; }; f" 298 | dcs = "!git --no-pager -c color.diff=always diff --stat --cached" 299 | ds = "!git --no-pager -c color.diff=always diff --stat" 300 | dso = "!f(){ local branch=$(git bb); git diff --stat origin/$branch $@; }; f" 301 | dsop = "!f() { $(git editor) $(git --no-pager -c color.diff=always diff --stat --name-only $1); }; f" 302 | dsom = "!f() { local mainbranch=$(git main); git --no-pager -c color.diff=always diff --stat origin/$mainbranch;}; f" 303 | dsm = "!f() { local mainbranch=$(git main); git --no-pager -c color.diff=always diff --stat $mainbranch;}; f" 304 | df = "!f() { git diff --name-only $@; }; f" 305 | mb = "!f() { echo $(git merge-base HEAD origin/$(git main)); }; f" 306 | dmb = "!f() { local merge_base=$(git mb); if [ $? -ne 0 ]; then echo "Error: Could not find merge base with origin/master"; return 1; fi; git diff $@ $merge_base; }; f" 307 | dfmb = "!f() { git dmb --name-only; }; f" 308 | dsmb = "!f() { git dmb --stat; }; f" 309 | dfom = "!f() { local mainbranch=$(git main); git diff --name-only origin/$mainbranch; }; f" 310 | dcf = "!f() { git diff --cached --name-only $@; }; f" 311 | dop = "!f() { $(git editor) $(git df); }; f" 312 | dcop = "!f() { $(git editor) $(git diff --cached --name-only $@); }; f" 313 | dm = "!f(){ local mainbranch=$(git main); if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git $(git differ) $mainbranch; }; f" 314 | dom = "!f(){ local mainbranch=$(git main); if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git $(git differ) origin/$mainbranch; }; f" 315 | do = "!f(){ if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; local branch=$(git bb); git $(git differ) origin/$branch $@; }; f" 316 | du = "!git $(git differ) @{upstream}" 317 | 318 | # status 319 | s = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git chain 'status --short' $@; }; f" 320 | sh = show 321 | sho = "!f(){ local branch=$(git bb); git show origin/$branch $@; }; f" 322 | shom = "!f() { local mainbranch=$(git main); git show origin/$mainbranch; }; f" 323 | shs = "!git --no-pager show --stat" 324 | shso = "!f(){ local branch=$(git bb); git --no-pager show --stat origin/$branch $@; }; f" 325 | shsom = "!f() { local mainbranch=$(git main); git --no-pager show --stat origin/$mainbranch; }; f" 326 | shop = "!f() { $(git editor) $(git show --pretty=\"format:\" --name-only $1); }; f" 327 | 328 | 329 | # tree 330 | l = "!f() { \ 331 | if [ $# -eq 0 ]; then \ 332 | if [ \"$(git bb)\" == \"$(git main)\" ]; then \ 333 | git log --graph --color --pretty='%C(yellow)%h%C(reset) %Cred%cd%C(reset) %C(bold blue)%an%C(reset) %s%C(bold yellow)%d%C(reset)' --decorate --date=relative $@; \ 334 | else \ 335 | git --no-pager log --graph --color --pretty='%C(yellow)%h%C(reset) %Cred%cd%C(reset) %C(bold blue)%an%C(reset) %s%C(bold yellow)%d%C(reset)' --decorate --date=relative $(git mb)~1..HEAD $@; \ 336 | fi \ 337 | else \ 338 | git log --graph --color --pretty='%C(yellow)%h%C(reset) %Cred%cd%C(reset) %C(bold blue)%an%C(reset) %s%C(bold yellow)%d%C(reset)' --decorate --date=relative $@; \ 339 | fi \ 340 | }; f" 341 | ls = log --color --pretty=format:'%C(yellow)%h%C(reset) %Cred%cd%C(reset) %C(bold blue)%an%C(reset) %s%C(bold yellow)%d%C(reset)' --decorate --date=relative --numstat 342 | lo = "!f(){ local branch=$(git bb); git log origin/$branch $@; }; f" 343 | lom = "!f() { local mainbranch=$(git main); git log origin/$mainbranch; }; f" 344 | lg = log 345 | hash = rev-parse HEAD 346 | shash = rev-parse --short HEAD 347 | rl = reflog show --date=relative 348 | 349 | # file tools 350 | find = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git ls-files | grep -i $@; }; f" 351 | op = "!f() { \ 352 | if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; \ 353 | files=$(git ls-files | grep -i \"$@\"); \ 354 | if [ -n \"$files\" ]; then \ 355 | $(git editor) $files; \ 356 | else \ 357 | echo \"No files to open matching pattern: $@\"; \ 358 | fi; \ 359 | }; f" 360 | # open edited 361 | eop = "! $(git editor) $(git ls-files --modified)" 362 | 363 | 364 | g = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git --no-pager grep \"$1\" $2; }; f" 365 | gcolor = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git --no-pager --color=always grep \"$1\" $2; }; f" 366 | gi = "!f() { if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; git --no-pager grep -i \"$1\" $2; }; f" 367 | # grep and open 368 | gop = "!f(){ if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; $(git editor) $(git grep --name-only \"$1\" $2); }; f" 369 | giop = "!f(){ if [ -n \"$GIT_PREFIX\" ]; then cd \"$GIT_PREFIX\"; fi; $(git editor) $(git grep -i --name-only \"$1\" $2); }; f" 370 | # only works with vim for now (uses format `+lineno file`), and no multi-select 371 | # could make it work though! needs e.g. vim-fetch, fzf -m, and cut -d \":\" -f 1-3 instead of awk (`file:lineno:lineno` format) 372 | zg = "!f() { \ 373 | rg --color=always --column --line-number --no-heading . | fzf --ansi --delimiter : --preview 'bat --theme=$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub) --color=always {1} --highlight-line {2}' --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' | awk -F: '{ printf \"%s +%s\\n\", $1, $2 }' | xargs $(git editor);\ 374 | }; f" 375 | 376 | 377 | tree = ls-tree -r HEAD 378 | 379 | # reset 380 | rs = reset 381 | rso = "!f(){ local branch=$(git bb); git reset origin/$branch $@; }; f" 382 | rsm = "!git reset $(git main)" 383 | rsom = "!git reset origin/$(git main)" 384 | rsh = reset --hard 385 | rsho = "!f(){ local branch=$(git bb); git reset --hard origin/$branch $@; }; f" 386 | rshom = "!git reset --hard origin/$(git main)" 387 | rshm = "!git reset --hard $(git main)" 388 | # rewind 389 | rw = "!f() { local n=${1:-1}; git reset HEAD~$n; }; f" 390 | rwh = "!f() { local n=${1:-1}; git reset --hard HEAD~$n; }; f" 391 | # revert 392 | rv = "!f() { local hash=${1:-HEAD}; git revert $hash; }; f" 393 | rva = revert --abort 394 | rvc = revert --continue 395 | 396 | # stash 397 | # TODO: reimplement this using branches 398 | # $ git config --global alias.stsh 'stash --keep-index' 399 | # git config --global alias.staash 'stash --include-untracked' 400 | # git config --global alias.staaash 'stash --all' 401 | st = "!f() { git chain stash $@; }; f" 402 | stl = stash list 403 | sta = stash apply 404 | std = stash drop 405 | sts = stash save 406 | stp = stash pop 407 | 408 | # tags 409 | t = tag 410 | td = tag -d 411 | 412 | # bisection 413 | bs = bisect 414 | bsb = bisect bad 415 | bsg = bisect good 416 | bsr = bisect reset 417 | bss = bisect start 418 | 419 | # submodules 420 | smi = submodule init 421 | sma = submodule add 422 | smu = submodule update 423 | sms = submodule sync 424 | 425 | # fuzzy commands (require fzf) 426 | # get commit hash 427 | zh = "!f() { \ 428 | local target=$1; \ 429 | local commit=\"\"; \ 430 | if fzf --help 2>&1 | grep --quiet '\\-\\-ansi'; then \ 431 | commit=$(git l $target | fzf --preview 'git --no-pager show --color {2}' --ansi | sed 's/.*\\*[^ ]*//g' | awk '{ print $1 }'); \ 432 | else \ 433 | commit=$(git log --color --graph --pretty='%h %cd %an %s%d' --decorate --date=relative $target | fzf --preview 'git --no-pager show --color {2}' | cut -d '*' -f 2 | awk '{ print $1 }'); \ 434 | fi; \ 435 | echo \"$commit\"; \ 436 | }; f" 437 | # get file 438 | zf = "!f() { \ 439 | local file=$(git ls-files $(git rev-parse --show-toplevel) | fzf -m --preview 'cat {1}'); \ 440 | if [[ -z $file ]]; then return 1; fi; \ 441 | echo \"$file\"; \ 442 | }; f" 443 | # get branch 444 | # consider: g branch -a --format '%(refname); \ 445 | zb = "!f() { \ 446 | local branch=$(git b | sed 's/^* //; s/^ //' | grep -v 'remotes/' | fzf --tac -m --preview 'git l {1}' | awk '{ print $1 }'); \ 447 | if [[ -z $branch ]]; then return 1; fi; \ 448 | echo \"$branch\"; \ 449 | }; f" 450 | zba = "!f() { \ 451 | local branch=$(git b -a | sed 's/^* //; s/^ //' | fzf --tac -m --preview 'git l {1}' | awk '{ print $1 }'); \ 452 | if [[ -z $branch ]]; then return 1; fi; \ 453 | echo \"$branch\"; \ 454 | }; f" 455 | zbx = "!f() { local branch=$(git zb); if [[ -z $branch ]]; then return 1; fi; git bx $branch; }; f" 456 | # fuzzy open 457 | zop = "!f() { \ 458 | local file=$(git zf); \ 459 | if [[ -z $file ]]; then return 1; fi; \ 460 | $(git editor) $file; \ 461 | echo $(git editor) $file; \ 462 | }; f" 463 | # fuzzy grep (does only one file) 464 | zgop = "!f() { rg --color ansi --vimgrep $@ | fzf --ansi --preview '~/.preview.sh {}' | pyp 'z = x.split(\":\"); print(f\"+{z[1]} -c \\\"normal {z[2]}|\\\" {shlex.quote(z[0])}\")' | xargs -o vim; }; f" 465 | # fuzzy checkout (could be much improved, have tags, branches, remotes) 466 | zc = "!f() { \ 467 | local branch=$(git zb); \ 468 | if [[ -z $branch ]]; then return 1; fi; \ 469 | git checkout $branch; \ 470 | echo git checkout $branch; \ 471 | }; f" 472 | zch = "!f() { \ 473 | local commit=$(git zh); \ 474 | if [[ -z $commit ]]; then return 1; fi; \ 475 | git checkout $commit; \ 476 | echo git checkout $commit; \ 477 | }; f" 478 | # fuzzy show 479 | # see: https://gist.github.com/junegunn/f4fca918e937e6bf5bad 480 | zsh = "!f() { \ 481 | git log --graph --color=always --abbrev=7 --format='%C(auto)%h %an %C(blue)%s %C(yellow)%cr' $@ | fzf --ansi --no-sort --reverse --tiebreak=index \ 482 | --preview \"f() { set -- \\$(echo -- \\$@ | grep -o '[a-f0-9]\\{7\\}'); [ \\$# -eq 0 ] || git show --color=always \\$1 $filter; }; f {}\" \ 483 | --preview-window=right:60% \ 484 | --height 80%; \ 485 | }; f" 486 | zshs = "!f() { \ 487 | git log --graph --color=always --abbrev=7 --format='%C(auto)%h %an %C(blue)%s %C(yellow)%cr' $@ | fzf --ansi --no-sort --reverse --tiebreak=index \ 488 | --preview \"f() { set -- \\$(echo -- \\$@ | grep -o '[a-f0-9]\\{7\\}'); [ \\$# -eq 0 ] || git show --color=always --stat \\$1 $filter; }; f {}\" \ 489 | --preview-window=right:60% \ 490 | --height 80%; \ 491 | }; f" 492 | # fuzzy diff 493 | zd = "!f() { \ 494 | local commit=$(git zh); \ 495 | if [[ -z $commit ]]; then return 1; fi; \ 496 | git $(git differ) $commit; \ 497 | echo git $(git differ) $commit; \ 498 | }; f" 499 | # TODO: make a single command that lists 500 | # commits, tags, branches, remotes 501 | # use in the fuzzy stuff 502 | 503 | # miscellaneous 504 | # Find commits by commit message 505 | fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=\"$@\"; }; f" 506 | # List contributors with number of commits 507 | contributors = shortlog --summary --numbered 508 | # shelf = "!f() { git tag | grep shelved } ; f" 509 | 510 | 511 | [color] 512 | # diff = always 513 | ui = true 514 | [push] 515 | default = current 516 | [rerere] 517 | enabled = true 518 | # [branch] 519 | # autosetupmerge = always 520 | # autosetuprebase = always 521 | [merge] 522 | conflictstyle = zdiff3 523 | [rebase] 524 | autosquash = true 525 | autostash = true 526 | [init] 527 | defaultBranch = main 528 | [fetch] 529 | fsckObjects = true 530 | [transfer] 531 | fsckObjects = true 532 | [receive] 533 | fsckObjects = true 534 | [gc] 535 | auto = 256 536 | # [safe] 537 | # directory = /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core 538 | # directory = /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask 539 | --------------------------------------------------------------------------------