├── .github └── workflows │ ├── dynamic-readme.yml │ └── dynamic-security.yml ├── .gitignore ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README-ES.md ├── README.md ├── SECURITY.md ├── agignore ├── aliases ├── asdfrc ├── bin ├── bundler-search ├── clear-port ├── git-ca ├── git-co-upstream-pr ├── git-create-branch ├── git-ctags ├── git-current-branch ├── git-delete-branch ├── git-merge-branch ├── git-rename-branch ├── git-trust-bin ├── git-up ├── replace ├── tat └── whats-in-port ├── ctags ├── ctags.d └── config.ctags ├── gemrc ├── git_template ├── hooks │ ├── commit-msg │ ├── ctags │ ├── post-checkout │ ├── post-commit │ ├── post-merge │ ├── post-rewrite │ ├── pre-commit │ ├── pre-push │ └── prepare-commit-msg └── info │ └── exclude ├── gitconfig ├── gitignore ├── gitmessage ├── hooks └── post-up ├── hushlogin ├── psqlrc ├── railsrc ├── rcrc ├── rspec ├── tmux.conf ├── vim ├── ftplugin │ ├── css.vim │ ├── gitcommit.vim │ ├── go.vim │ ├── markdown.vim │ ├── sass.vim │ └── scss.vim └── plugin │ └── ctags.vim ├── vimrc ├── vimrc.bundles ├── zprofile ├── zsh ├── completion │ ├── _ag │ ├── _bundler │ ├── _g │ ├── _production │ ├── _rspec │ └── _staging ├── configs │ ├── color.zsh │ ├── editor.zsh │ ├── history.zsh │ ├── homebrew.zsh │ ├── keybindings.zsh │ ├── options.zsh │ ├── post │ │ ├── completion.zsh │ │ └── path.zsh │ └── prompt.zsh └── functions │ ├── _git_delete_branch │ ├── change-extension │ ├── envup │ ├── g │ └── mcd ├── zshenv └── zshrc /.github/workflows/dynamic-readme.yml: -------------------------------------------------------------------------------- 1 | name: update-templates 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | update-templates: 11 | permissions: 12 | contents: write 13 | pull-requests: write 14 | pages: write 15 | uses: thoughtbot/templates/.github/workflows/dynamic-readme.yaml@main 16 | secrets: 17 | token: ${{ secrets.GITHUB_TOKEN }} 18 | -------------------------------------------------------------------------------- /.github/workflows/dynamic-security.yml: -------------------------------------------------------------------------------- 1 | name: update-security 2 | 3 | on: 4 | push: 5 | paths: 6 | - SECURITY.md 7 | branches: 8 | - main 9 | workflow_dispatch: 10 | 11 | jobs: 12 | update-security: 13 | permissions: 14 | contents: write 15 | pull-requests: write 16 | pages: write 17 | uses: thoughtbot/templates/.github/workflows/dynamic-security.yaml@main 18 | secrets: 19 | token: ${{ secrets.GITHUB_TOKEN }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | !bin 2 | vim/bundle/ 3 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | @purinkle 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of conduct 2 | 3 | By participating in this project, you agree to abide by the 4 | [thoughtbot code of conduct][1]. 5 | 6 | [1]: https://thoughtbot.com/open-source-code-of-conduct 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LICENSE 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2009-2016 thoughtbot, inc. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README-ES.md: -------------------------------------------------------------------------------- 1 | Los dotfiles de thoughtbot 2 | ========================== 3 | 4 |  5 | 6 | Requerimientos 7 | -------------- 8 | 9 | Establece zsh como tu shell de inicio de sesión: 10 | 11 | chsh -s $(which zsh) 12 | 13 | Instalar 14 | -------- 15 | 16 | Clona en tu laptop: 17 | 18 | git clone git@github.com:thoughtbot/dotfiles.git ~/dotfiles 19 | 20 | (o [haz un fork y mantenlo actualizado](http://robots.thoughtbot.com/keeping-a-github-fork-updated)). 21 | 22 | Instala [rcm](https://github.com/thoughtbot/rcm): 23 | 24 | brew install rcm 25 | 26 | Instala los dotfiles: 27 | 28 | env RCRC=$HOME/dotfiles/rcrc rcup 29 | 30 | Después de la instalación inicial, puedes ejecutarlo sin establecer la variable `RCRC` 31 | (`rcup` establecerá un enlace simbólico (symlink) del repo `rcrc` hacia `~/.rcrc` para futuras 32 | ejecuciones de `rcup`). [Ve el ejemplo](https://github.com/thoughtbot/dotfiles/blob/master/rcrc). 33 | 34 | Este comando creará enlaces simbólicos (symlinks) para los archivos de configuración en tu 35 | directorio principal. 36 | 37 | Establecer la variable de entorno le dice a `rcup` que use las opciones de 38 | configuración preestablecidas: 39 | 40 | * Excluye los archivos `README.md`, `README-ES.md` y `LICENSE`, que son parte 41 | del repositorio `dotfiles`, pero no necesitan enlazarse simbólicamente. 42 | * Le da precedencia a las modificaciones personales que por defecto están en 43 | `~/dotfiles-local` 44 | * Por favor configura el archivo `rcrc` en caso de que quieras hacer 45 | modificaciones personales en un directorio distinto. 46 | 47 | 48 | Actualizar 49 | ---------- 50 | 51 | De vez en cuando deberías descargar las actualizaciones de estos dotfiles, y ejectuar 52 | 53 | rcup 54 | 55 | para ligar cualquier nuevo archivo e instalar los nuevos plugins de vim. **Nota** _Debes_ ejecutar 56 | `rcup` después de descargar para asegurarte que todos los archivos de los plugins 57 | estén instalados adecuadamente. Puedes ejecutar `rcup` con seguridad muchas veces 58 | para actualizar pronto y muy seguido! 59 | 60 | 61 | Haz tus propias modificaciones 62 | ------------------------------ 63 | 64 | Crea un directorio para tus modificaciones personales: 65 | 66 | mkdir ~/dotfiles-local 67 | 68 | Pon tus modificaciones en `~/dotfiles-local` anexado con `.local`: 69 | 70 | * `~/dotfiles-local/aliases.local` 71 | * `~/dotfiles-local/git_template.local/*` 72 | * `~/dotfiles-local/gitconfig.local` 73 | * `~/dotfiles-local/psqlrc.local` (proveemos `.psqlrc.local` en blanco para prevenir que `psql` 74 | arroje un error, pero debes sobreescribir el archivo con tu propia copia) 75 | * `~/dotfiles-local/tmux.conf.local` 76 | * `~/dotfiles-local/vimrc.local` 77 | * `~/dotfiles-local/vimrc.bundles.local` 78 | * `~/dotfiles-local/zshrc.local` 79 | * `~/dotfiles-local/zsh/configs/*` 80 | 81 | Por ejemplo, tu `~/dotfiles-local/aliases.local` tal vez se vea así: 82 | 83 | # Productivity 84 | alias todo='$EDITOR ~/.todo' 85 | 86 | Tu `~/dotfiles-local/gitconfig.local` tal vez se vea así: 87 | 88 | [alias] 89 | l = log --pretty=colored 90 | [pretty] 91 | colored = format:%Cred%h%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset 92 | [user] 93 | name = Dan Croak 94 | email = dan@thoughtbot.com 95 | 96 | Tu `~/dotfiles-local/vimrc.local` tal vez se vea así: 97 | 98 | " Color scheme 99 | colorscheme github 100 | highlight NonText guibg=#060606 101 | highlight Folded guibg=#0A0A0A guifg=#9090D0 102 | 103 | Si prefieres prevenir la instalación de un plugin predeterminado de vim en `.vimrc.bundles`, 104 | puedes ignorarlo sacándolo con `UnPlug` en tu `~/.vimrc.bundles.local`. 105 | 106 | " Don't install vim-scripts/tComment 107 | UnPlug 'tComment' 108 | 109 | `UnPlug` puede ser usado para instalar tu propio fork de un plugin o para instalar 110 | un plugin compartido con opciones personalizadas distintas. 111 | 112 | " Only load vim-coffee-script if a Coffeescript buffer is created 113 | UnPlug 'vim-coffee-script' 114 | Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' } 115 | 116 | " Use a personal fork of vim-run-interactive 117 | UnPlug 'vim-run-interactive' 118 | Plug '$HOME/plugins/vim-run-interactive' 119 | 120 | Para extender tus `git` hooks, crea scripts ejecutables en 121 | `~/dotfiles-local/git_template.local/hooks/*` files. 122 | 123 | Tu `~/dotfiles-local/zshrc.local` tal vez se vea así: 124 | 125 | # load pyenv if available 126 | if command -v pyenv &>/dev/null ; then 127 | eval "$(pyenv init -)" 128 | fi 129 | 130 | Tu `~/dotfiles-local/vimrc.bundles.local` tal vez se vea así: 131 | 132 | Plug 'Lokaltog/vim-powerline' 133 | Plug 'stephenmckinney/vim-solarized-powerline' 134 | 135 | Configuraciones de zsh 136 | ---------------------- 137 | 138 | Configuraciones adicionales para zsh pueden ir en el directorio `~/dotfiles-local/zsh/configs`. Este 139 | tiene dos subdirectorios especiales: `pre` para archivos que deben ser cargados primero y `post` 140 | para archivos que deben cargarse al final. 141 | 142 | Por ejemplo, `~/dotfiles-local/zsh/configs/pre/virtualenv` hace uso de varias características 143 | de shell que tal vez se vean afectadas por tu configuración, por lo tanto cárgalo primero: 144 | 145 | # Load the virtualenv wrapper 146 | . /usr/local/bin/virtualenvwrapper.sh 147 | 148 | Establecer una vinculación clave puede ocurrir en `~/dotfiles-local/zsh/configs/keys`: 149 | 150 | # Grep anywhere with ^G 151 | bindkey -s '^G' ' | grep ' 152 | 153 | Algunos cambios, como `chpwd`, deben ocurrir en `~/dotfiles-local/zsh/configs/post/chpwd`: 154 | 155 | # Show the entries in a directory whenever you cd in 156 | function chpwd { 157 | ls 158 | } 159 | 160 | Este directorio está a la mano para combinar dotfiles de múltiples equipos; un equipo 161 | puede agregar el archivo `virtualenv`, otro el archivo `keys` y un tercero el archivo `chpwd`. 162 | 163 | El archivo `~/dotfiles-local/zshrc.local` se carga después de `~/dotfiles-local/zsh/configs`. 164 | 165 | Configuraciones de vim 166 | ---------------------- 167 | 168 | Similar al directorio de configuración para zsh descrito arriba, vim 169 | automáticamente descarga los archivos en el directorio `~/dotfiles-local/vim/plugin`. Sin embargo, este no 170 | tiene el mismo soporte para los subdirectorios `pre` ni `post` que tiene nuestro `zshrc`. 171 | 172 | Este es un ejemplo `~/dotfiles-local/vim/plugin/c.vim`. Se carga cada vez que inicia vim, 173 | sin importar de nombre del archivo: 174 | 175 | # Indent C programs according to BSD style(9) 176 | set cinoptions=:0,t0,+4,(4 177 | autocmd BufNewFile,BufRead *.[ch] setlocal sw=0 ts=8 noet 178 | 179 | ¿Qué viene incluido? 180 | ----------------- 181 | 182 | Configuración [vim](http://www.vim.org/): 183 | 184 | * [fzf](https://github.com/junegunn/fzf.vim) para hallazgo difuso de archivos/buffer/tags. 185 | * [Rails.vim](https://github.com/tpope/vim-rails) para una mejor navegación de la estructura 186 | de archivos de Rails via `gf` y `:A` (alterno), `:Rextract` parciales,`:Rinvert` migraciones, etc. 187 | * Ejecuta muchos tipos de pruebas [desde vim]([https://github.com/janko-m/vim-test) 188 | * Establece `<leader>` a un sólo espacio. 189 | * Navega entre los últimos dos archivos con espacio-espacio 190 | * Resaltado de sintaxis para Markdown, HTML, JavaScript, Ruby, Go, Elixir, y más. 191 | * Usa [Ag](https://github.com/ggreer/the_silver_searcher) en lugar de Grep cuando esté disponible. 192 | * Map `<leader>ct` para re-indexar [Exuberant Ctags](http://ctags.sourceforge.net/). 193 | * Usa [vim-mkdir](https://github.com/pbrisbin/vim-mkdir) para crear automáticamente directorios 194 | no existentes antes de escribir el buffer. 195 | * Usa [vim-plug](https://github.com/junegunn/vim-plug) para administrar plugins. 196 | 197 | [tmux](http://robots.thoughtbot.com/a-tmux-crash-course) 198 | configuración: 199 | 200 | * Mejora la resolición del color. 201 | * Eliminar desechos administrativos(bombre de sesión, nombre de host, tiempo) en la barra de estatus. 202 | * Establece el prefijo a `Ctrl+s` 203 | * Suaviza el color de la barra de estatus de un verde chillante a un gris claro. 204 | 205 | Configuración para [git](http://git-scm.com/): 206 | 207 | * Agrega el alias `create-branch` para crear branches. 208 | * Agrega el alias `delete-branch` para borrar branches. 209 | * Agrega el alias `merge-branch` para fusionar los branches en master. 210 | * Agrega el alias `up` para buscar y rebasar `origin/master` en el branch. 211 | Usa `git up -i` para rebases interactivos. 212 | * Agrega el hook `post-{checkout,commit,merge}` para re-indexar tus ctags. 213 | * Agrega `pre-commit` y `prepare-commit-msg` stubs que delegan hacia tu 214 | configuración local. 215 | * Agrega el alias `trust-bin` para anexar el `bin/` de un proyecto al `$PATH`. 216 | 217 | Configuración de [Ruby](https://www.ruby-lang.org/en/): 218 | 219 | * Agrega binstubs confiables al `PATH`. 220 | * Descarga el administrador de versiones ASDF. 221 | 222 | Alias de Shell y scripts: 223 | 224 | * `b` para `bundle`. 225 | * `g` sin argumentos es `git status` y con argumentos funciona como `git`. 226 | * `migrate` para `bin/rails db:migrate db:rollback && bin/rails db:migrate db:test:prepare`. 227 | * `mcd` para crear un directorio e ir a él. 228 | * `replace foo bar **/*.rb` para buscar y reemplazar en una lista dada de archivos. 229 | * `tat` para adjuntar a una sesión de tmux llamada igual que el directorio actual. 230 | * `v` para `$VISUAL`. 231 | 232 | Gracias 233 | ------- 234 | 235 | Gracias [Contribuyentes](https://github.com/thoughtbot/dotfiles/contributors)! 236 | Además, gracias a Corey Haines, Gary Bernhardt, y otros por compartir sus dotfiles 237 | y otros scripts de shell que derivaron en la inspiración para los artículos 238 | en este proyecto. 239 | 240 | Licencia 241 | -------- 242 | 243 | dotfiles está protegida por copyright © 2009-2017 thoughtbot. Es un software gratis, y tal vez 244 | redistribuido bajo los términos especificados en el archivo de la [`LICENCIA`] 245 | [`LICENCIA`]: /LICENSE 246 | 247 | Acerca de thoughtbot 248 | -------------------- 249 | 250 |  251 | 252 | dotfiles es mantenido y creado por thoughtbot, inc. 253 | Los nombres y los logos de thoughtbot son marca registrada de thoughtbot, inc. 254 | 255 | Amamos el código de fuente abiarta! 256 | Ve [nuestros otros proyectos][community]. 257 | Estamos [disponibles para ser contratados][hire]. 258 | 259 | [community]: https://thoughtbot.com/community?utm_source=github 260 | [hire]: https://thoughtbot.com/hire-us?utm_source=github 261 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # thoughtbot dotfiles 2 | 3 |  4 | 5 | ## Requirements 6 | 7 | Set zsh as your login shell: 8 | 9 | chsh -s $(which zsh) 10 | 11 | ## Install 12 | 13 | Clone onto your laptop: 14 | 15 | git clone git@github.com:thoughtbot/dotfiles.git ~/dotfiles 16 | 17 | (Or, [fork and keep your fork 18 | updated](http://robots.thoughtbot.com/keeping-a-github-fork-updated)). 19 | 20 | Install [rcm](https://github.com/thoughtbot/rcm): 21 | 22 | brew install rcm 23 | 24 | Install the dotfiles: 25 | 26 | env RCRC=$HOME/dotfiles/rcrc rcup 27 | 28 | After the initial installation, you can run `rcup` without the one-time variable 29 | `RCRC` being set (`rcup` will symlink the repo's `rcrc` to `~/.rcrc` for future 30 | runs of `rcup`). [See 31 | example](https://github.com/thoughtbot/dotfiles/blob/master/rcrc). 32 | 33 | This command will create symlinks for config files in your home directory. 34 | Setting the `RCRC` environment variable tells `rcup` to use standard 35 | configuration options: 36 | 37 | - Exclude the `README.md`, `README-ES.md` and `LICENSE` files, which are part of 38 | the `dotfiles` repository but do not need to be symlinked in. 39 | - Give precedence to personal overrides which by default are placed in 40 | `~/dotfiles-local` 41 | - Please configure the `rcrc` file if you'd like to make personal 42 | overrides in a different directory 43 | 44 | ## Update 45 | 46 | From time to time you should pull down any updates to these dotfiles, and run 47 | 48 | rcup 49 | 50 | to link any new files and install new vim plugins. **Note** You _must_ run 51 | `rcup` after pulling to ensure that all files in plugins are properly installed, 52 | but you can safely run `rcup` multiple times so update early and update often! 53 | 54 | ## Make your own customizations 55 | 56 | Create a directory for your personal customizations: 57 | 58 | mkdir ~/dotfiles-local 59 | 60 | Put your customizations in `~/dotfiles-local` appended with `.local`: 61 | 62 | - `~/dotfiles-local/aliases.local` 63 | - `~/dotfiles-local/git_template.local/*` 64 | - `~/dotfiles-local/gitconfig.local` 65 | - `~/dotfiles-local/psqlrc.local` (we supply a blank `.psqlrc.local` to prevent `psql` from 66 | throwing an error, but you should overwrite the file with your own copy) 67 | - `~/dotfiles-local/tmux.conf.local` 68 | - `~/dotfiles-local/vimrc.local` 69 | - `~/dotfiles-local/vimrc.bundles.local` 70 | - `~/dotfiles-local/zshrc.local` 71 | - `~/dotfiles-local/zsh/configs/*` 72 | 73 | For example, your `~/dotfiles-local/aliases.local` might look like this: 74 | 75 | # Productivity 76 | alias todo='$EDITOR ~/.todo' 77 | 78 | Your `~/dotfiles-local/gitconfig.local` might look like this: 79 | 80 | [alias] 81 | l = log --pretty=colored 82 | [pretty] 83 | colored = format:%Cred%h%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset 84 | [user] 85 | name = Dan Croak 86 | email = dan@thoughtbot.com 87 | 88 | Your `~/dotfiles-local/vimrc.local` might look like this: 89 | 90 | " Color scheme 91 | colorscheme github 92 | highlight NonText guibg=#060606 93 | highlight Folded guibg=#0A0A0A guifg=#9090D0 94 | 95 | If you don't wish to install a vim plugin from the default set of vim plugins in 96 | `.vimrc.bundles`, you can ignore the plugin by calling it out with `UnPlug` in 97 | your `~/.vimrc.bundles.local`. 98 | 99 | " Don't install vim-scripts/tComment (notice the username of the plugin is 100 | removed) 101 | 102 | UnPlug 'tComment' 103 | 104 | `UnPlug` can be used to install your own fork of a plugin or to install a shared 105 | plugin with different custom options. 106 | 107 | " Only load vim-coffee-script if a Coffeescript buffer is created 108 | UnPlug 'vim-coffee-script' 109 | Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' } 110 | 111 | " Use a personal fork of vim-run-interactive 112 | UnPlug 'vim-run-interactive' 113 | Plug '$HOME/plugins/vim-run-interactive' 114 | 115 | To extend your `git` hooks, create executable scripts in 116 | `~/dotfiles-local/git_template.local/hooks/*` files. 117 | 118 | Your `~/dotfiles-local/zshrc.local` might look like this: 119 | 120 | # load pyenv if available 121 | if which pyenv &>/dev/null ; then 122 | eval "$(pyenv init -)" 123 | fi 124 | 125 | Your `~/dotfiles-local/vimrc.bundles.local` might look like this: 126 | 127 | Plug 'Lokaltog/vim-powerline' 128 | Plug 'stephenmckinney/vim-solarized-powerline' 129 | 130 | ## zsh Configurations 131 | 132 | Additional zsh configuration can go under the `~/dotfiles-local/zsh/configs` directory. This 133 | has two special subdirectories: `pre` for files that must be loaded first, and 134 | `post` for files that must be loaded last. 135 | 136 | For example, `~/dotfiles-local/zsh/configs/pre/virtualenv` makes use of various shell 137 | features which may be affected by your settings, so load it first: 138 | 139 | # Load the virtualenv wrapper 140 | . /usr/local/bin/virtualenvwrapper.sh 141 | 142 | Setting a key binding can happen in `~/dotfiles-local/zsh/configs/keys`: 143 | 144 | # Grep anywhere with ^G 145 | bindkey -s '^G' ' | grep ' 146 | 147 | Some changes, like `chpwd`, must happen in `~/dotfiles-local/zsh/configs/post/chpwd`: 148 | 149 | # Show the entries in a directory whenever you cd in 150 | function chpwd { 151 | ls 152 | } 153 | 154 | This directory is handy for combining dotfiles from multiple teams; one team 155 | can add the `virtualenv` file, another `keys`, and a third `chpwd`. 156 | 157 | The `~/dotfiles-local/zshrc.local` is loaded after `~/dotfiles-local/zsh/configs`. 158 | 159 | ## vim Configurations 160 | 161 | Similarly to the zsh configuration directory as described above, vim 162 | automatically loads all files in the `~/dotfiles-local/vim/plugin` directory. This does not 163 | have the same `pre` or `post` subdirectory support that our `zshrc` has. 164 | 165 | This is an example `~/dotfiles-local/vim/plugin/c.vim`. It is loaded every time vim starts, 166 | regardless of the file name: 167 | 168 | # Indent C programs according to BSD style(9) 169 | set cinoptions=:0,t0,+4,(4 170 | autocmd BufNewFile,BufRead *.[ch] setlocal sw=0 ts=8 noet 171 | 172 | ## What's in it? 173 | 174 | [vim](http://www.vim.org/) configuration: 175 | 176 | - [fzf](https://github.com/junegunn/fzf.vim) for fuzzy file/buffer/tag finding. 177 | - [Rails.vim](https://github.com/tpope/vim-rails) for enhanced navigation of 178 | Rails file structure via `gf` and `:A` (alternate), `:Rextract` partials, 179 | `:Rinvert` migrations, etc. 180 | - Run many kinds of tests [from vim]([https://github.com/janko-m/vim-test) 181 | - Set `<leader>` to a single space. 182 | - Switch between the last two files with space-space. 183 | - Syntax highlighting for Markdown, HTML, JavaScript, Ruby, Go, Elixir, more. 184 | - Use [Ag](https://github.com/ggreer/the_silver_searcher) instead of Grep when 185 | available. 186 | - Map `<leader>ct` to re-index ctags. 187 | - Use [vim-mkdir](https://github.com/pbrisbin/vim-mkdir) for automatically 188 | creating non-existing directories before writing the buffer. 189 | - Use [vim-plug](https://github.com/junegunn/vim-plug) to manage plugins. 190 | 191 | [tmux](http://robots.thoughtbot.com/a-tmux-crash-course) 192 | configuration: 193 | 194 | - Improve color resolution. 195 | - Remove administrative debris (session name, hostname, time) in status bar. 196 | - Set prefix to `Ctrl+s` 197 | - Soften status bar color from harsh green to light gray. 198 | 199 | [git](http://git-scm.com/) configuration: 200 | 201 | - Adds a `co-upstream-pr $PR_NUMBER $LOCAL_BRANCH_NAME` subcommand to checkout remote upstream branch into a local branch. 202 | - Adds a `create-branch` alias to create feature branches. 203 | - Adds a `delete-branch` alias to delete feature branches. 204 | - Adds a `merge-branch` alias to merge feature branches into master. 205 | - Adds an `up` alias to fetch and rebase `origin/master` into the feature 206 | branch. Use `git up -i` for interactive rebases. 207 | - Adds `post-{checkout,commit,merge}` hooks to re-index your ctags. 208 | - Adds `pre-commit` and `prepare-commit-msg` stubs that delegate to your local 209 | config. 210 | - Adds `trust-bin` alias to append a project's `bin/` directory to `$PATH`. 211 | 212 | [Ruby](https://www.ruby-lang.org/en/) configuration: 213 | 214 | - Add trusted binstubs to the `PATH`. 215 | - Load the ASDF version manager. 216 | 217 | [Rails](https://rubyonrails.org) 218 | 219 | - Adds [railsrc][] with the following options to integrate with [Suspenders][]. 220 | 221 | ``` 222 | --database=postgresql 223 | --skip-test 224 | -m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb 225 | ``` 226 | 227 | If you want to skip this file altogether, run `rails new my_app --no_rc`. 228 | 229 | [railsrc]: https://github.com/rails/rails/blob/7f7f9df8641e35a076fe26bd097f6a1b22cb4e2d/railties/lib/rails/generators/rails/app/USAGE#L5C1-L7 230 | [Suspenders]: https://github.com/thoughtbot/suspenders 231 | 232 | Shell aliases and scripts: 233 | 234 | - `...` for quicker navigation to the parent's parent directory. 235 | - `b` for `bundle`. 236 | - `g` with no arguments is `git status` and with arguments acts like `git`. 237 | - `migrate` for `bin/rails db:migrate db:rollback && bin/rails db:migrate db:test:prepare`. 238 | - `mcd` to make a directory and change into it. 239 | - `replace foo bar **/*.rb` to find and replace within a given list of files. 240 | - `tat` to attach to tmux session named the same as the current directory. 241 | - `v` for `$VISUAL`. 242 | 243 | ## Thanks 244 | 245 | Thank you, [contributors](https://github.com/thoughtbot/dotfiles/contributors)! 246 | Also, thank you to Corey Haines, Gary Bernhardt, and others for sharing your 247 | dotfiles and other shell scripts from which we derived inspiration for items 248 | in this project. 249 | 250 | ## License 251 | 252 | dotfiles is copyright © 2009 thoughtbot. It is free software, and may be 253 | redistributed under the terms specified in the [`LICENSE`] file. 254 | 255 | [`LICENSE`]: /LICENSE 256 | 257 | <!-- START /templates/footer.md --> 258 | ## About thoughtbot 259 | 260 |  261 | 262 | This repo is maintained and funded by thoughtbot, inc. 263 | The names and logos for thoughtbot are trademarks of thoughtbot, inc. 264 | 265 | We love open source software! 266 | See [our other projects][community]. 267 | We are [available for hire][hire]. 268 | 269 | [community]: https://thoughtbot.com/community?utm_source=github 270 | [hire]: https://thoughtbot.com/hire-us?utm_source=github 271 | 272 | <!-- END /templates/footer.md --> 273 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | <!-- START /templates/security.md --> 2 | # Security Policy 3 | 4 | ## Supported Versions 5 | 6 | Only the the latest version of this project is supported at a given time. If 7 | you find a security issue with an older version, please try updating to the 8 | latest version first. 9 | 10 | If for some reason you can't update to the latest version, please let us know 11 | your reasons so that we can have a better understanding of your situation. 12 | 13 | ## Reporting a Vulnerability 14 | 15 | For security inquiries or vulnerability reports, visit 16 | <https://thoughtbot.com/security>. 17 | 18 | If you have any suggestions to improve this policy, visit <https://thoughtbot.com/security>. 19 | <!-- END /templates/security.md --> 20 | -------------------------------------------------------------------------------- /agignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | -------------------------------------------------------------------------------- /aliases: -------------------------------------------------------------------------------- 1 | # Unix 2 | alias ll="ls -al" 3 | alias ln="ln -v" 4 | alias mkdir="mkdir -p" 5 | alias e="$EDITOR" 6 | alias v="$VISUAL" 7 | 8 | # Bundler 9 | alias b="bundle" 10 | 11 | # Rails 12 | alias migrate="bin/rails db:migrate db:rollback && bin/rails db:migrate db:test:prepare" 13 | alias s="rspec" 14 | 15 | # Pretty print the path 16 | alias path='echo $PATH | tr -s ":" "\n"' 17 | 18 | # Easier navigation: ..., ...., ....., and - 19 | alias ...="cd ../.." 20 | alias ....="cd ../../.." 21 | alias .....="cd ../../../.." 22 | alias -- -="cd -" 23 | 24 | # Include custom aliases 25 | if [[ -f ~/.aliases.local ]]; then 26 | source ~/.aliases.local 27 | fi 28 | -------------------------------------------------------------------------------- /asdfrc: -------------------------------------------------------------------------------- 1 | legacy_version_file = yes 2 | -------------------------------------------------------------------------------- /bin/bundler-search: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Search your bundle for the provided pattern 4 | # Requires bundler 1.8+ for execution as a bundler subcommand. 5 | # Examples: 6 | # bundle search Kernel.warn 7 | # bundle search current_user clearance 8 | # bundle search "Change your password" clearance 9 | # 10 | # Arguments: 11 | # 1. What to search for 12 | # 2. Which gem names to search (defaults to all gems) 13 | 14 | pattern="$1"; shift 15 | ag "$pattern" $(bundle show --paths "$@") 16 | -------------------------------------------------------------------------------- /bin/clear-port: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Kills the process running on the provided port 4 | # 5 | # clear-port 3000 6 | 7 | if [ -n "$1" ]; then 8 | port_num="$(lsof -ti4TCP:"$1")" 9 | if [ $? -eq 0 ]; then 10 | kill "$port_num" 11 | fi 12 | else 13 | echo >&2 Usage: clear-port port-number 14 | exit 1 15 | fi 16 | -------------------------------------------------------------------------------- /bin/git-ca: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git commit --amend -v --date="$(date +%Y-%m-%dT%H:%M:%S)" 4 | -------------------------------------------------------------------------------- /bin/git-co-upstream-pr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | pull_request_number=$1 6 | local_branch_name=$2 7 | 8 | if [ -z "$pull_request_number" -o -z "$local_branch_name" ]; then 9 | echo "usage: git co-upstream-pr <pull_request_number> <local_branch_name>" 10 | exit 1 11 | fi 12 | 13 | if git remote -v | grep -q upstream; then 14 | git fetch upstream "pull/$pull_request_number/head:$local_branch_name" 15 | git checkout "$local_branch_name" 16 | else 17 | cat <<HELP 18 | You don't have an upstream remote set. 19 | Use: 20 | git remote add upstream {upstream_remote_url} 21 | 22 | to set the reference and then try again. 23 | HELP 24 | fi 25 | -------------------------------------------------------------------------------- /bin/git-create-branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | git push origin "HEAD:refs/heads/$1" 6 | git fetch origin 7 | git branch --track "$1" "origin/$1" 8 | cd . 9 | git checkout "$1" 10 | -------------------------------------------------------------------------------- /bin/git-ctags: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | [ -f .git/hooks/ctags ] || git init 6 | .git/hooks/ctags 7 | -------------------------------------------------------------------------------- /bin/git-current-branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | git rev-parse --abbrev-ref HEAD 6 | -------------------------------------------------------------------------------- /bin/git-delete-branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | git push origin :refs/heads/"$1" 6 | git branch --delete "$1" 7 | -------------------------------------------------------------------------------- /bin/git-merge-branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if git symbolic-ref --short refs/remotes/origin/HEAD >/dev/null; then 6 | main_branch="$(git symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@')" "$@" 7 | else 8 | echo "You don't have a primary branch reference set for your origin remote. 9 | Use: 10 | git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/{name_of_your_primary_branch} 11 | 12 | to set the reference and then try merging again." 13 | 14 | exit 1 15 | fi 16 | 17 | git fetch origin 18 | line_count=$(git diff origin/$main_branch..$main_branch | wc -l) 19 | 20 | if [ $line_count -gt 0 ]; then 21 | printf "failed: $main_branch is not up to date with origin/$main_branch\n" 22 | exit 1 23 | fi 24 | 25 | git checkout $main_branch 26 | git merge "@{-1}" 27 | -------------------------------------------------------------------------------- /bin/git-rename-branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | old=$(git current-branch) 6 | git branch -m "$old" "$1" 7 | git push origin --set-upstream "$1" 8 | git push origin --delete "$old" 9 | -------------------------------------------------------------------------------- /bin/git-trust-bin: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p .git/safe 4 | -------------------------------------------------------------------------------- /bin/git-up: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | git fetch origin 6 | 7 | if git symbolic-ref --short refs/remotes/origin/HEAD >/dev/null; then 8 | git rebase "$(git symbolic-ref --short refs/remotes/origin/HEAD)" "$@" 9 | else 10 | echo "You don't have a primary branch reference set for your origin remote. 11 | Use: 12 | git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/{name_of_your_primary_branch} 13 | 14 | to set the reference and then try rebasing again." 15 | fi 16 | -------------------------------------------------------------------------------- /bin/replace: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Find and replace by a given list of files. 4 | # 5 | # replace foo bar **/*.rb 6 | 7 | find_this="$1" 8 | shift 9 | replace_with="$1" 10 | shift 11 | 12 | if command -v rg &>/dev/null ; then 13 | items=$(rg -l --color never "$find_this" "$@") 14 | else 15 | items=$(ag -l --nocolor "$find_this" "$@") 16 | fi 17 | 18 | temp="${TMPDIR:-/tmp}/replace_temp_file.$" 19 | IFS=#39;\n' 20 | for item in $items; do 21 | sed "s/$find_this/$replace_with/g" "$item" > "$temp" && mv "$temp" "$item" 22 | done 23 | -------------------------------------------------------------------------------- /bin/tat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Attach or create tmux session named the same as current directory. 4 | 5 | path_name="$(basename "$PWD" | tr . -)" 6 | session_name=${1-$path_name} 7 | 8 | not_in_tmux() { 9 | [ -z "$TMUX" ] 10 | } 11 | 12 | session_exists() { 13 | tmux has-session -t "=$session_name" 14 | } 15 | 16 | create_detached_session() { 17 | (TMUX='' tmux new-session -Ad -s "$session_name") 18 | } 19 | 20 | create_if_needed_and_attach() { 21 | if not_in_tmux; then 22 | tmux new-session -As "$session_name" 23 | else 24 | if ! session_exists; then 25 | create_detached_session 26 | fi 27 | tmux switch-client -t "$session_name" 28 | fi 29 | } 30 | 31 | create_if_needed_and_attach 32 | -------------------------------------------------------------------------------- /bin/whats-in-port: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # List process running on provided port 4 | # 5 | # whats-in-port 3000 6 | # 7 | # output: 8 | # COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 9 | # ruby 25583 root 11u IPv4 0xee20607697a79bf7 0t0 TCP *:irdmi (LISTEN) 10 | 11 | if [ -n "$1" ]; then 12 | lsof -ni4TCP:"$1" 13 | else 14 | echo >&2 Usage: whats-in-port port-number 15 | exit 1 16 | fi 17 | -------------------------------------------------------------------------------- /ctags: -------------------------------------------------------------------------------- 1 | --regex-ruby=/(^|[:;])[ \t]*([A-Z][[:alnum:]_]+) *=/\2/c,class,constant/ 2 | --regex-ruby=/^[ \t]*attr_(reader|writer|accessor) (:[a-z0-9_]+, )*:([a-z0-9_]+)/\3/A,attr/ 3 | --langdef=Elixir 4 | --langmap=Elixir:.ex.exs 5 | --regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/f,functions,functions (def ...)/ 6 | --regex-Elixir=/^[ \t]*defcallback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/c,callbacks,callbacks (defcallback ...)/ 7 | --regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegates,delegates (defdelegate ...)/ 8 | --regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exceptions,exceptions (defexception ...)/ 9 | --regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementations,implementations (defimpl ...)/ 10 | --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)\(/\2/a,macros,macros (defmacro ...)/ 11 | --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operators,operators (e.g. "defmacro a <<< b")/ 12 | --regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,modules,modules (defmodule ...)/ 13 | --regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocols,protocols (defprotocol...)/ 14 | --regex-Elixir=/^[ \t]*Record\.defrecord[ \t]+:([a-zA-Z0-9_]+)/\1/r,records,records (defrecord...)/ 15 | --regex-Elixir=/^[ \t]*test[ \t]+\"([a-z_][a-zA-Z0-9_?! ]*)\"*/\1/t,tests,tests (test ...)/ 16 | --exclude=bower_components 17 | --exclude=node_modules 18 | --exclude=vendor 19 | --languages=-javascript 20 | --langdef=js 21 | --langmap=js:.js 22 | --langmap=js:+.jsx 23 | --regex-js=/[ \t.]([A-Z][A-Z0-9._$]+)[ \t]*[=:][ \t]*([0-9"'\[\{]|null)/\1/n,constant/ 24 | -------------------------------------------------------------------------------- /ctags.d/config.ctags: -------------------------------------------------------------------------------- 1 | --regex-ruby=/(^|[:;])[ \t]*([A-Z][[:alnum:]_]+) *=/\2/c,class,constant/ 2 | --exclude=bower_components 3 | --exclude=node_modules 4 | --exclude=vendor 5 | --languages=-javascript 6 | --langdef=js 7 | --langmap=js:.js 8 | --langmap=js:+.jsx 9 | --regex-js=/[ \t.]([A-Z][A-Z0-9._$]+)[ \t]*[=:][ \t]*([0-9"'\[\{]|null)/\1/n,constant/ 10 | -------------------------------------------------------------------------------- /gemrc: -------------------------------------------------------------------------------- 1 | gem: --no-document 2 | -------------------------------------------------------------------------------- /git_template/hooks/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | local_hook="$HOME"/.git_template.local/hooks/commit-msg 4 | 5 | if [ -f "$local_hook" ]; then 6 | . "$local_hook" 7 | fi 8 | -------------------------------------------------------------------------------- /git_template/hooks/ctags: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | PATH="/usr/local/bin:$PATH" 6 | dir="$(git rev-parse --git-dir)" 7 | trap 'rm -f "$dir/$.tags"' EXIT 8 | git ls-files | \ 9 | "${CTAGS:-ctags}" --tag-relative=yes -L - -f"$dir/$.tags" --languages=-javascript,sql 10 | mv "$dir/$.tags" "$dir/tags" 11 | -------------------------------------------------------------------------------- /git_template/hooks/post-checkout: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | local_hook="$HOME"/.git_template.local/hooks/post-checkout 4 | 5 | if [ -f "$local_hook" ]; then 6 | . "$local_hook"; 7 | fi 8 | 9 | .git/hooks/ctags >/dev/null 2>&1 & 10 | -------------------------------------------------------------------------------- /git_template/hooks/post-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | local_hook="$HOME"/.git_template.local/hooks/post-commit 4 | 5 | if [ -f "$local_hook" ]; then 6 | . "$local_hook"; 7 | fi 8 | 9 | .git/hooks/ctags >/dev/null 2>&1 & 10 | -------------------------------------------------------------------------------- /git_template/hooks/post-merge: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | local_hook="$HOME"/.git_template.local/hooks/post-merge 4 | 5 | if [ -f "$local_hook" ]; then 6 | . "$local_hook"; 7 | fi 8 | 9 | .git/hooks/ctags >/dev/null 2>&1 & 10 | -------------------------------------------------------------------------------- /git_template/hooks/post-rewrite: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | case "$1" in 3 | rebase) exec .git/hooks/post-merge ;; 4 | esac 5 | -------------------------------------------------------------------------------- /git_template/hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | local_hook="$HOME"/.git_template.local/hooks/pre-commit 4 | 5 | if [ -f "$local_hook" ]; then 6 | . "$local_hook" 7 | fi 8 | -------------------------------------------------------------------------------- /git_template/hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | local_hook="$HOME"/.git_template.local/hooks/pre-push 4 | 5 | if [ -f "$local_hook" ]; then 6 | . "$local_hook" 7 | fi 8 | -------------------------------------------------------------------------------- /git_template/hooks/prepare-commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | local_hook="$HOME"/.git_template.local/hooks/prepare-commit-msg 4 | 5 | if [ -f "$local_hook" ]; then 6 | . "$local_hook" 7 | fi 8 | -------------------------------------------------------------------------------- /git_template/info/exclude: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | # *.[oa] 6 | # *~ 7 | -------------------------------------------------------------------------------- /gitconfig: -------------------------------------------------------------------------------- 1 | [init] 2 | defaultBranch = main 3 | templatedir = ~/.git_template 4 | [push] 5 | default = current 6 | [color] 7 | ui = auto 8 | [alias] 9 | aa = add --all 10 | ap = add --patch 11 | branches = for-each-ref --sort=-committerdate --format=\"%(color:blue)%(authordate:relative)\t%(color:red)%(authorname)\t%(color:white)%(color:bold)%(refname:short)\" refs/remotes 12 | ci = commit -v 13 | co = checkout 14 | pf = push --force-with-lease 15 | st = status 16 | [core] 17 | excludesfile = ~/.gitignore 18 | autocrlf = input 19 | [merge] 20 | ff = only 21 | [commit] 22 | template = ~/.gitmessage 23 | [fetch] 24 | prune = true 25 | [rebase] 26 | autosquash = true 27 | [include] 28 | path = ~/.gitconfig.local 29 | [diff] 30 | colorMoved = zebra 31 | -------------------------------------------------------------------------------- /gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.sw[nop] 3 | .DS_Store 4 | .bundle 5 | .byebug_history 6 | .env 7 | .git/ 8 | /bower_components/ 9 | /log 10 | /node_modules/ 11 | /tmp 12 | db/*.sqlite3 13 | log/*.log 14 | rerun.txt 15 | tmp/**/* 16 | /tags 17 | -------------------------------------------------------------------------------- /gitmessage: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 50-character subject line 4 | # 5 | # 72-character wrapped longer description. This should answer: 6 | # 7 | # * Why was this change necessary? 8 | # * How does it address the problem? 9 | # * Are there any side effects? 10 | # 11 | # Include a link to the ticket, if any. 12 | # 13 | # Add co-authors if you worked on this code with others: 14 | # 15 | # Co-authored-by: Full Name <email@example.com> 16 | # Co-authored-by: Full Name <email@example.com> 17 | -------------------------------------------------------------------------------- /hooks/post-up: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | touch "$HOME"/.psqlrc.local 4 | 5 | if [ -e "$HOME"/.vim/autoload/plug.vim ]; then 6 | vim -E -s +PlugUpgrade +qa 7 | else 8 | curl -fLo "$HOME"/.vim/autoload/plug.vim --create-dirs \ 9 | https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 10 | fi 11 | 12 | vim -u "$HOME"/.vimrc.bundles +PlugUpdate +PlugClean! +qa 13 | 14 | reset -Q 15 | 16 | if [ -f "$HOME/.git_template/HEAD" ] && \ 17 | [ "$(cat "$HOME/.git_template/HEAD")" = "ref: refs/heads/main" ]; then 18 | echo "Removing ~/.git_template/HEAD in favor of defaultBranch" >&2 19 | rm -f ~/.git_template/HEAD 20 | fi 21 | 22 | # detect old OS X broken /etc/zshenv and suggest rename 23 | if grep -qw path_helper /etc/zshenv 2>/dev/null; then 24 | dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) 25 | 26 | cat <<MSG >&2 27 | Warning: \`/etc/zshenv' configuration file on your system may cause unexpected 28 | PATH changes on subsequent invocations of the zsh shell. The solution is to 29 | rename the file to \`zprofile': 30 | sudo mv /etc/{zshenv,zprofile} 31 | 32 | (called from ${dir}/post-up:${LINENO}) 33 | 34 | MSG 35 | fi 36 | -------------------------------------------------------------------------------- /hushlogin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thoughtbot/dotfiles/07bff4faab635a461a49b37705a5961f7dbcf123/hushlogin -------------------------------------------------------------------------------- /psqlrc: -------------------------------------------------------------------------------- 1 | -- Official docs: http://www.postgresql.org/docs/9.3/static/app-psql.html 2 | -- Unofficial docs: http://robots.thoughtbot.com/improving-the-command-line-postgres-experience 3 | 4 | -- Don't display the "helpful" message on startup. 5 | \set QUIET 1 6 | \pset null '[NULL]' 7 | 8 | -- http://www.postgresql.org/docs/9.3/static/app-psql.html#APP-PSQL-PROMPTING 9 | \set PROMPT1 '%[%033[1m%]%M %n@%/%R%[%033[0m%]%# ' 10 | -- PROMPT2 is printed when the prompt expects more input, like when you type 11 | -- SELECT * FROM<enter>. %R shows what type of input it expects. 12 | \set PROMPT2 '[more] %R > ' 13 | 14 | -- Show how long each query takes to execute 15 | \timing 16 | 17 | -- Use best available output format 18 | \x auto 19 | \set VERBOSITY verbose 20 | \set HISTFILE ~/.psql_history- :DBNAME 21 | \set HISTCONTROL ignoredups 22 | \set COMP_KEYWORD_CASE upper 23 | \unset QUIET 24 | 25 | -- psql can't check for a file's existence, so we'll provide an empty local 26 | -- file that users can override with their custom dotfiles. To set your own 27 | -- personal settings, place your own file in ~/.psqlrc.local 28 | \i ~/.psqlrc.local 29 | -------------------------------------------------------------------------------- /railsrc: -------------------------------------------------------------------------------- 1 | --database=postgresql 2 | --skip-test 3 | --skip-rubocop 4 | -m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb 5 | -------------------------------------------------------------------------------- /rcrc: -------------------------------------------------------------------------------- 1 | EXCLUDES="*.md LICENSE CODEOWNERS" 2 | DOTFILES_DIRS="$HOME/dotfiles-local $HOME/dotfiles" 3 | COPY_ALWAYS="git_template/HEAD" 4 | -------------------------------------------------------------------------------- /rspec: -------------------------------------------------------------------------------- 1 | --colour 2 | --order random 3 | -------------------------------------------------------------------------------- /tmux.conf: -------------------------------------------------------------------------------- 1 | # improve colors 2 | set -g default-terminal 'screen-256color' 3 | 4 | # act like vim 5 | setw -g mode-keys vi 6 | bind-key h select-pane -L 7 | bind-key j select-pane -D 8 | bind-key k select-pane -U 9 | bind-key l select-pane -R 10 | bind-key -r C-h select-window -t :- 11 | bind-key -r C-l select-window -t :+ 12 | 13 | set -g prefix2 C-s 14 | 15 | # start window numbers at 1 to match keyboard order with tmux window order 16 | set -g base-index 1 17 | set-window-option -g pane-base-index 1 18 | 19 | # renumber windows sequentially after closing any of them 20 | set -g renumber-windows on 21 | 22 | # soften status bar color from harsh green to light gray 23 | set -g status-style bg='#666666',fg='#aaaaaa' 24 | 25 | # remove administrative debris (session name, hostname, time) in status bar 26 | set -g status-left '' 27 | set -g status-right '' 28 | 29 | # increase scrollback lines 30 | set -g history-limit 10000 31 | 32 | # prefix -> back-one-character 33 | bind-key C-b send-prefix 34 | # prefix-2 -> forward-incremental-history-search 35 | bind-key C-s send-prefix -2 36 | 37 | # don't suspend-client 38 | unbind-key C-z 39 | 40 | # Local config 41 | if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local' 42 | -------------------------------------------------------------------------------- /vim/ftplugin/css.vim: -------------------------------------------------------------------------------- 1 | setlocal iskeyword+=- 2 | -------------------------------------------------------------------------------- /vim/ftplugin/gitcommit.vim: -------------------------------------------------------------------------------- 1 | " Automatically wrap at 72 characters and spell check commit messages 2 | autocmd BufNewFile,BufRead PULLREQ_EDITMSG set syntax=gitcommit 3 | setlocal textwidth=72 4 | setlocal spell 5 | -------------------------------------------------------------------------------- /vim/ftplugin/go.vim: -------------------------------------------------------------------------------- 1 | let g:go_fmt_command = "goimports" 2 | 3 | setlocal listchars=tab:\ \ ,trail:·,nbsp:· 4 | setlocal noexpandtab 5 | 6 | compiler go 7 | -------------------------------------------------------------------------------- /vim/ftplugin/markdown.vim: -------------------------------------------------------------------------------- 1 | " Enable spellchecking 2 | setlocal spell 3 | 4 | " Automatically wrap at 80 characters 5 | setlocal textwidth=80 6 | -------------------------------------------------------------------------------- /vim/ftplugin/sass.vim: -------------------------------------------------------------------------------- 1 | setlocal iskeyword+=- 2 | -------------------------------------------------------------------------------- /vim/ftplugin/scss.vim: -------------------------------------------------------------------------------- 1 | setlocal iskeyword+=- 2 | -------------------------------------------------------------------------------- /vim/plugin/ctags.vim: -------------------------------------------------------------------------------- 1 | " Exclude Javascript files in :Rtags via rails.vim due to warnings when parsing 2 | let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'" 3 | 4 | " Index ctags from any project, including those outside Rails 5 | function! ReindexCtags() 6 | let l:ctags_hook_file = "$(git rev-parse --show-toplevel)/.git/hooks/ctags" 7 | let l:ctags_hook_path = system("echo " . l:ctags_hook_file) 8 | let l:ctags_hook_path = substitute(l:ctags_hook_path, '\n\+#39;, '', '') 9 | 10 | if filereadable(expand(l:ctags_hook_path)) 11 | exec '!'. l:ctags_hook_file 12 | else 13 | exec "!ctags -R ." 14 | endif 15 | endfunction 16 | 17 | " to stop this mapping from being added, put this in $MYVIMRC: 18 | " let g:thoughtbot_ctags_mappings_enabled = 0 19 | let g:thoughtbot_ctags_mappings_enabled = get(g:, 'thoughtbot_ctags_mappings_enabled', 1) 20 | if g:thoughtbot_ctags_mappings_enabled != 0 21 | nmap <Leader>ct :call ReindexCtags()<CR> 22 | endif 23 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | set encoding=utf-8 2 | 3 | " Leader 4 | let mapleader = " " 5 | 6 | set backspace=2 " Backspace deletes like most programs in insert mode 7 | set nobackup 8 | set nowritebackup 9 | set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287 10 | set history=50 11 | set ruler " show the cursor position all the time 12 | set showcmd " display incomplete commands 13 | set incsearch " do incremental searching 14 | set laststatus=2 " Always display the status line 15 | set autowrite " Automatically :write before running commands 16 | set modelines=0 " Disable modelines as a security precaution 17 | set nomodeline 18 | 19 | " Switch syntax highlighting on, when the terminal has colors 20 | " Also switch on highlighting the last used search pattern. 21 | if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") 22 | syntax on 23 | endif 24 | 25 | if filereadable(expand("~/.vimrc.bundles")) 26 | source ~/.vimrc.bundles 27 | endif 28 | 29 | " Load matchit.vim, but only if the user hasn't installed a newer version. 30 | if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' 31 | runtime! macros/matchit.vim 32 | endif 33 | 34 | filetype plugin indent on 35 | 36 | augroup vimrcEx 37 | autocmd! 38 | 39 | " When editing a file, always jump to the last known cursor position. 40 | " Don't do it for commit messages, when the position is invalid, or when 41 | " inside an event handler (happens when dropping a file on gvim). 42 | autocmd BufReadPost * 43 | \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("quot;) | 44 | \ exe "normal g`\"" | 45 | \ endif 46 | 47 | " Set syntax highlighting for specific file types 48 | autocmd BufRead,BufNewFile *.md set filetype=markdown 49 | autocmd BufRead,BufNewFile .{jscs,jshint,eslint}rc set filetype=json 50 | autocmd BufRead,BufNewFile 51 | \ aliases.local, 52 | \zshenv.local,zlogin.local,zlogout.local,zshrc.local,zprofile.local, 53 | \*/zsh/configs/* 54 | \ set filetype=sh 55 | autocmd BufRead,BufNewFile gitconfig.local set filetype=gitconfig 56 | autocmd BufRead,BufNewFile tmux.conf.local set filetype=tmux 57 | autocmd BufRead,BufNewFile vimrc.local set filetype=vim 58 | augroup END 59 | 60 | " ALE linting events 61 | augroup ale 62 | autocmd! 63 | 64 | if g:has_async 65 | autocmd VimEnter * 66 | \ set updatetime=1000 | 67 | \ let g:ale_lint_on_text_changed = 0 68 | autocmd CursorHold * call ale#Queue(0) 69 | autocmd CursorHoldI * call ale#Queue(0) 70 | autocmd InsertEnter * call ale#Queue(0) 71 | autocmd InsertLeave * call ale#Queue(0) 72 | else 73 | echoerr "The thoughtbot dotfiles require NeoVim or Vim 8" 74 | endif 75 | augroup END 76 | 77 | " When the type of shell script is /bin/sh, assume a POSIX-compatible 78 | " shell for syntax highlighting purposes. 79 | let g:is_posix = 1 80 | 81 | " Softtabs, 2 spaces 82 | set tabstop=2 83 | set shiftwidth=2 84 | set shiftround 85 | set expandtab 86 | 87 | " Display extra whitespace 88 | set list listchars=tab:»·,trail:·,nbsp:· 89 | 90 | " Use one space, not two, after punctuation. 91 | set nojoinspaces 92 | 93 | " Use The Silver Searcher https://github.com/ggreer/the_silver_searcher 94 | if executable('ag') 95 | " Use Ag over Grep 96 | set grepprg=ag\ --nogroup\ --nocolor 97 | 98 | " Use ag in fzf for listing files. Lightning fast and respects .gitignore 99 | let $FZF_DEFAULT_COMMAND = 'ag --literal --files-with-matches --nocolor --hidden -g ""' 100 | 101 | nnoremap \ :Ag<SPACE> 102 | endif 103 | 104 | " Make it obvious where 80 characters is 105 | set textwidth=80 106 | set colorcolumn=+1 107 | 108 | " Numbers 109 | set number 110 | set numberwidth=5 111 | 112 | " Tab completion 113 | " will insert tab at beginning of line, 114 | " will use completion if not at beginning 115 | set wildmode=list:longest,list:full 116 | function! InsertTabWrapper() 117 | let col = col('.') - 1 118 | if !col || getline('.')[col - 1] !~ '\k' 119 | return "\<Tab>" 120 | else 121 | return "\<C-p>" 122 | endif 123 | endfunction 124 | inoremap <Tab> <C-r>=InsertTabWrapper()<CR> 125 | inoremap <S-Tab> <C-n> 126 | 127 | " Switch between the last two files 128 | nnoremap <Leader><Leader> <C-^> 129 | 130 | " vim-test mappings 131 | nnoremap <silent> <Leader>t :TestFile<CR> 132 | nnoremap <silent> <Leader>s :TestNearest<CR> 133 | nnoremap <silent> <Leader>l :TestLast<CR> 134 | nnoremap <silent> <Leader>a :TestSuite<CR> 135 | nnoremap <silent> <Leader>gt :TestVisit<CR> 136 | 137 | " Run commands that require an interactive shell 138 | nnoremap <Leader>r :RunInInteractiveShell<Space> 139 | 140 | " Treat <li> and <p> tags like the block tags they are 141 | let g:html_indent_tags = 'li\|p' 142 | 143 | " Set tags for vim-fugitive 144 | set tags^=.git/tags 145 | 146 | " Open new split panes to right and bottom, which feels more natural 147 | set splitbelow 148 | set splitright 149 | 150 | " Quicker window movement 151 | nnoremap <C-j> <C-w>j 152 | nnoremap <C-k> <C-w>k 153 | nnoremap <C-h> <C-w>h 154 | nnoremap <C-l> <C-w>l 155 | 156 | " Move between linting errors 157 | nnoremap ]r :ALENextWrap<CR> 158 | nnoremap [r :ALEPreviousWrap<CR> 159 | 160 | " Map Ctrl + p to open fuzzy find (FZF) 161 | nnoremap <c-p> :Files<cr> 162 | 163 | " Set spellfile to location that is guaranteed to exist, can be symlinked to 164 | " Dropbox or kept in Git and managed outside of thoughtbot/dotfiles using rcm. 165 | set spellfile=$HOME/.vim-spell-en.utf-8.add 166 | 167 | " Autocomplete with dictionary words when spell check is on 168 | set complete+=kspell 169 | 170 | " Always use vertical diffs 171 | set diffopt+=vertical 172 | 173 | " Local config 174 | if filereadable($HOME . "/.vimrc.local") 175 | source ~/.vimrc.local 176 | endif 177 | -------------------------------------------------------------------------------- /vimrc.bundles: -------------------------------------------------------------------------------- 1 | if &compatible 2 | set nocompatible 3 | end 4 | 5 | " Remove declared plugins 6 | function! s:UnPlug(plug_name) 7 | if has_key(g:plugs, a:plug_name) 8 | call remove(g:plugs, a:plug_name) 9 | endif 10 | endfunction 11 | command! -nargs=1 UnPlug call s:UnPlug(<args>) 12 | 13 | let g:has_async = v:version >= 800 || has('nvim') 14 | 15 | call plug#begin('~/.vim/bundle') 16 | 17 | " Define bundles via Github repos 18 | Plug 'christoomey/vim-run-interactive' 19 | 20 | " If fzf has already been installed via Homebrew, use the existing fzf 21 | " Otherwise, install fzf. The `--all` flag makes fzf accessible outside of vim 22 | if executable("brew") 23 | let g:brew_fzf_path = trim(system("brew --prefix fzf")) 24 | endif 25 | 26 | if exists("g:brew_fzf_path") && isdirectory(g:brew_fzf_path) 27 | Plug g:brew_fzf_path 28 | else 29 | Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } 30 | endif 31 | 32 | Plug 'junegunn/fzf.vim' 33 | Plug 'elixir-lang/vim-elixir' 34 | Plug 'fatih/vim-go' 35 | Plug 'janko-m/vim-test' 36 | Plug 'pangloss/vim-javascript' 37 | Plug 'pbrisbin/vim-mkdir' 38 | Plug 'slim-template/vim-slim' 39 | Plug 'tpope/vim-bundler' 40 | Plug 'tpope/vim-endwise' 41 | Plug 'tpope/vim-eunuch' 42 | Plug 'tpope/vim-fugitive' 43 | Plug 'tpope/vim-projectionist' 44 | Plug 'tpope/vim-rails' 45 | Plug 'tpope/vim-rake' 46 | Plug 'tpope/vim-repeat' 47 | Plug 'tpope/vim-rhubarb' 48 | Plug 'tpope/vim-surround' 49 | Plug 'vim-ruby/vim-ruby' 50 | Plug 'vim-scripts/tComment' 51 | 52 | if g:has_async 53 | Plug 'dense-analysis/ale' 54 | endif 55 | 56 | if filereadable(expand("~/.vimrc.bundles.local")) 57 | source ~/.vimrc.bundles.local 58 | endif 59 | 60 | call plug#end() 61 | -------------------------------------------------------------------------------- /zprofile: -------------------------------------------------------------------------------- 1 | if [ -d "/opt/homebrew" ]; then 2 | eval "$(/opt/homebrew/bin/brew shellenv)" 3 | elif [ -d "~/.linuxbrew" ]; then 4 | eval "$(~/.linuxbrew/bin/brew shellenv)" 5 | elif [ -d "/home/linuxbrew" ]; then 6 | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 7 | fi 8 | -------------------------------------------------------------------------------- /zsh/completion/_ag: -------------------------------------------------------------------------------- 1 | #compdef ag 2 | 3 | if (( CURRENT == 2 )); then 4 | compadd $(cut -f 1 tmp/tags .git/tags 2>/dev/null) 5 | else; 6 | _files 7 | fi 8 | -------------------------------------------------------------------------------- /zsh/completion/_bundler: -------------------------------------------------------------------------------- 1 | #compdef bundle 2 | 3 | local curcontext="$curcontext" state line _gems _opts ret=1 4 | 5 | _arguments -C -A "-v" -A "--version" \ 6 | '(- 1 *)'{-v,--version}'[display version information]' \ 7 | '1: :->cmds' \ 8 | '*:: :->args' && ret=0 9 | 10 | case $state in 11 | cmds) 12 | _values "bundle command" \ 13 | "install[Install the gems specified by the Gemfile or Gemfile.lock]" \ 14 | "update[Update dependencies to their latest versions]" \ 15 | "package[Package the .gem files required by your application]" \ 16 | "exec[Execute a script in the context of the current bundle]" \ 17 | "config[Specify and read configuration options for bundler]" \ 18 | "check[Determine whether the requirements for your application are installed]" \ 19 | "list[Show all of the gems in the current bundle]" \ 20 | "show[Show the source location of a particular gem in the bundle]" \ 21 | "console[Start an IRB session in the context of the current bundle]" \ 22 | "open[Open an installed gem in the editor]" \ 23 | "lock[Generate a lockfile for your dependencies]" \ 24 | "viz[Generate a visual representation of your dependencies]" \ 25 | "init[Generate a simple Gemfile, placed in the current directory]" \ 26 | "gem[Create a simple gem, suitable for development with bundler]" \ 27 | "help[Describe available tasks or one specific task]" \ 28 | "platform[Displays platform compatibility information]" \ 29 | "outdated[Show all of the outdated gems in the current bundle]" \ 30 | "clean[Cleans up unused gems in your bundler directory]" 31 | ret=0 32 | ;; 33 | args) 34 | case $line[1] in 35 | help) 36 | _values 'commands' 'install' 'update' 'package' 'exec' 'config' 'check' 'list' 'show' 'console' 'open' 'lock' 'viz' 'init' 'gem' 'help' 'platform' 'outdated' 'clean' && ret=0 37 | ;; 38 | install) 39 | _arguments \ 40 | '(--no-color)--no-color[disable colorization in output]' \ 41 | '(--local)--local[do not attempt to connect to rubygems.org]' \ 42 | '(--quiet)--quiet[only output warnings and errors]' \ 43 | '(--gemfile)--gemfile=-[use the specified gemfile instead of Gemfile]:gemfile' \ 44 | '(--system)--system[install to the system location]' \ 45 | '(--deployment)--deployment[install using defaults tuned for deployment environments]' \ 46 | '(--frozen)--frozen[do not allow the Gemfile.lock to be updated after this install]' \ 47 | '(--path)--path=-[specify a different path than the system default]:path:_files' \ 48 | '(--binstubs)--binstubs=-[generate bin stubs for bundled gems to ./bin]:directory:_files' \ 49 | '(--without)--without=-[exclude gems that are part of the specified named group]:groups' 50 | ret=0 51 | ;; 52 | exec) 53 | _normal && ret=0 54 | ;; 55 | (open|show) 56 | _gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') ) 57 | if [[ $_gems != "" ]]; then 58 | _values 'gems' $_gems && ret=0 59 | fi 60 | ;; 61 | *) 62 | _opts=( $(bundle help $line[1] | sed -e '/^ \[-/!d; s/^ \[\(-[^=]*\)=.*/\1/') ) 63 | _opts+=( $(bundle help $line[1] | sed -e '/^ -/!d; s/^ \(-.\), \[\(-[^=]*\)=.*/\1 \2/') ) 64 | if [[ $_opts != "" ]]; then 65 | _values 'options' $_opts && ret=0 66 | fi 67 | ;; 68 | esac 69 | ;; 70 | esac 71 | 72 | return ret 73 | -------------------------------------------------------------------------------- /zsh/completion/_g: -------------------------------------------------------------------------------- 1 | #compdef g 2 | compdef g=git 3 | -------------------------------------------------------------------------------- /zsh/completion/_production: -------------------------------------------------------------------------------- 1 | #compdef production 2 | compdef production=heroku 3 | -------------------------------------------------------------------------------- /zsh/completion/_rspec: -------------------------------------------------------------------------------- 1 | #compdef rspec 2 | 3 | compadd -P spec/ $(ls spec/**/*_spec.rb | sed -E "s/spec\///g") 4 | -------------------------------------------------------------------------------- /zsh/completion/_staging: -------------------------------------------------------------------------------- 1 | #compdef staging 2 | compdef staging=heroku 3 | -------------------------------------------------------------------------------- /zsh/configs/color.zsh: -------------------------------------------------------------------------------- 1 | # makes color constants available 2 | autoload -U colors 3 | colors 4 | 5 | # enable colored output from ls, etc. on FreeBSD-based systems 6 | export CLICOLOR=1 7 | -------------------------------------------------------------------------------- /zsh/configs/editor.zsh: -------------------------------------------------------------------------------- 1 | export VISUAL=vim 2 | export EDITOR=$VISUAL 3 | -------------------------------------------------------------------------------- /zsh/configs/history.zsh: -------------------------------------------------------------------------------- 1 | setopt hist_ignore_all_dups inc_append_history 2 | HISTFILE=~/.zhistory 3 | HISTSIZE=4096 4 | SAVEHIST=4096 5 | 6 | export ERL_AFLAGS="-kernel shell_history enabled" 7 | -------------------------------------------------------------------------------- /zsh/configs/homebrew.zsh: -------------------------------------------------------------------------------- 1 | # To opt in to Homebrew analytics, `unset` this in ~/.zshrc.local . 2 | # Learn more about what you are opting in to at 3 | # https://docs.brew.sh/Analytics 4 | export HOMEBREW_NO_ANALYTICS=1 5 | -------------------------------------------------------------------------------- /zsh/configs/keybindings.zsh: -------------------------------------------------------------------------------- 1 | # give us access to ^Q 2 | stty -ixon 3 | 4 | # vi mode 5 | bindkey -v 6 | bindkey "^F" vi-cmd-mode 7 | 8 | # handy keybindings 9 | bindkey "^A" beginning-of-line 10 | bindkey "^E" end-of-line 11 | bindkey "^K" kill-line 12 | bindkey "^R" history-incremental-search-backward 13 | bindkey "^P" history-search-backward 14 | bindkey "^Y" accept-and-hold 15 | bindkey "^N" insert-last-word 16 | bindkey "^Q" push-line-or-edit 17 | bindkey -s "^T" "^[Isudo ^[A" # "t" for "toughguy" 18 | -------------------------------------------------------------------------------- /zsh/configs/options.zsh: -------------------------------------------------------------------------------- 1 | # awesome cd movements from zshkit 2 | setopt autocd autopushd pushdminus pushdsilent pushdtohome cdablevars 3 | DIRSTACKSIZE=5 4 | 5 | # Enable extended globbing 6 | setopt extendedglob 7 | 8 | # Allow [ or ] whereever you want 9 | unsetopt nomatch 10 | -------------------------------------------------------------------------------- /zsh/configs/post/completion.zsh: -------------------------------------------------------------------------------- 1 | # load our own completion functions 2 | fpath=(~/.zsh/completion /usr/local/share/zsh/site-functions $fpath) 3 | 4 | # completion; use cache if updated within 24h 5 | autoload -Uz compinit 6 | if [[ -n $HOME/.zcompdump(#qN.mh+24) ]]; then 7 | compinit -d $HOME/.zcompdump; 8 | else 9 | compinit -C; 10 | fi; 11 | 12 | # disable zsh bundled function mtools command mcd 13 | # which causes a conflict. 14 | compdef -d mcd 15 | -------------------------------------------------------------------------------- /zsh/configs/post/path.zsh: -------------------------------------------------------------------------------- 1 | # ensure dotfiles bin directory is loaded first 2 | PATH="$HOME/.bin:/usr/local/sbin:$PATH" 3 | 4 | # Try loading ASDF from the regular home dir location 5 | if [ -f "$HOME/.asdf/asdf.sh" ]; then 6 | . "$HOME/.asdf/asdf.sh" 7 | elif which brew >/dev/null && [ -f "$(brew --prefix asdf)/libexec/asdf.sh" ]; then 8 | . "$(brew --prefix asdf)/libexec/asdf.sh" 9 | fi 10 | 11 | # mkdir .git/safe in the root of repositories you trust 12 | PATH=".git/safe/../../bin:$PATH" 13 | 14 | export -U PATH 15 | -------------------------------------------------------------------------------- /zsh/configs/prompt.zsh: -------------------------------------------------------------------------------- 1 | # modify the prompt to contain git branch name if applicable 2 | git_prompt_info() { 3 | current_branch=$(git current-branch 2> /dev/null) 4 | if [[ -n $current_branch ]]; then 5 | echo " %{$fg_bold[green]%}$current_branch%{$reset_color%}" 6 | fi 7 | } 8 | 9 | setopt promptsubst 10 | 11 | # Allow exported PS1 variable to override default prompt. 12 | if ! env | grep -q '^PS1='; then 13 | PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%c%{$reset_color%}$(git_prompt_info) %# ' 14 | fi 15 | -------------------------------------------------------------------------------- /zsh/functions/_git_delete_branch: -------------------------------------------------------------------------------- 1 | _git_delete_branch () 2 | { 3 | __gitcomp "$(__git_heads)" 4 | } 5 | -------------------------------------------------------------------------------- /zsh/functions/change-extension: -------------------------------------------------------------------------------- 1 | # Change file extensions recursively in current directory 2 | # 3 | # change-extension erb haml 4 | 5 | function change-extension() { 6 | foreach f (**/*.$1) 7 | mv $f $f:r.$2 8 | end 9 | } 10 | -------------------------------------------------------------------------------- /zsh/functions/envup: -------------------------------------------------------------------------------- 1 | # Load .env file into shell session for environment variables 2 | 3 | function envup() { 4 | if [ -f .env ]; then 5 | export $(sed '/^ *#/ d' .env) 6 | else 7 | echo 'No .env file found' 1>&2 8 | return 1 9 | fi 10 | } 11 | -------------------------------------------------------------------------------- /zsh/functions/g: -------------------------------------------------------------------------------- 1 | # No arguments: `git status` 2 | # With arguments: acts like `git` 3 | g() { 4 | if [[ $# -gt 0 ]]; then 5 | git "$@" 6 | else 7 | git status 8 | fi 9 | } 10 | -------------------------------------------------------------------------------- /zsh/functions/mcd: -------------------------------------------------------------------------------- 1 | # Make directory and change into it. 2 | 3 | function mcd() { 4 | mkdir -p "$1" && cd "$1"; 5 | } 6 | -------------------------------------------------------------------------------- /zshenv: -------------------------------------------------------------------------------- 1 | local _old_path="$PATH" 2 | 3 | # Local config 4 | [[ -f ~/.zshenv.local ]] && source ~/.zshenv.local 5 | 6 | if [[ $PATH != $_old_path ]]; then 7 | # `colors` isn't initialized yet, so define a few manually 8 | typeset -AHg fg fg_bold 9 | if [ -t 2 ]; then 10 | fg[red]=#39;\e[31m' 11 | fg_bold[white]=#39;\e[1;37m' 12 | reset_color=#39;\e[m' 13 | else 14 | fg[red]="" 15 | fg_bold[white]="" 16 | reset_color="" 17 | fi 18 | 19 | cat <<MSG >&2 20 | ${fg[red]}Warning:${reset_color} your \`~/.zshenv.local' configuration seems to edit PATH entries. 21 | Please move that configuration to \`.zshrc.local' like so: 22 | ${fg_bold[white]}cat ~/.zshenv.local >> ~/.zshrc.local && rm ~/.zshenv.local${reset_color} 23 | 24 | (called from ${(%):-%N:%i}) 25 | 26 | MSG 27 | fi 28 | 29 | unset _old_path 30 | -------------------------------------------------------------------------------- /zshrc: -------------------------------------------------------------------------------- 1 | # load custom executable functions 2 | for function in ~/.zsh/functions/*; do 3 | source $function 4 | done 5 | 6 | # extra files in ~/.zsh/configs/pre , ~/.zsh/configs , and ~/.zsh/configs/post 7 | # these are loaded first, second, and third, respectively. 8 | _load_settings() { 9 | _dir="$1" 10 | if [ -d "$_dir" ]; then 11 | if [ -d "$_dir/pre" ]; then 12 | for config in "$_dir"/pre/**/*~*.zwc(N-.); do 13 | . $config 14 | done 15 | fi 16 | 17 | for config in "$_dir"/**/*(N-.); do 18 | case "$config" in 19 | "$_dir"/(pre|post)/*|*.zwc) 20 | : 21 | ;; 22 | *) 23 | . $config 24 | ;; 25 | esac 26 | done 27 | 28 | if [ -d "$_dir/post" ]; then 29 | for config in "$_dir"/post/**/*~*.zwc(N-.); do 30 | . $config 31 | done 32 | fi 33 | fi 34 | } 35 | _load_settings "$HOME/.zsh/configs" 36 | 37 | # Local config 38 | [[ -f ~/.zshrc.local ]] && source ~/.zshrc.local 39 | 40 | # aliases 41 | [[ -f ~/.aliases ]] && source ~/.aliases 42 | --------------------------------------------------------------------------------