Last active
January 26, 2018 20:03
-
-
Save nicinabox/09b4ccf29d1952e741bd26d1cd1d9b39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## iTerm | |
| I can't remember exactly why I started using this over the built in Terminal, but it's very customizable and feature rich. | |
| ## zsh | |
| Originally I switched to zsh to try something different from bash. Now I rely on features like [hook functions](http://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions) and [syntax highlighting](https://github.com/zsh-users/zsh-syntax-highlighting). | |
| I use [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) with [pure-prompt](https://github.com/sindresorhus/pure). | |
| ### zsh hooks | |
| One that I've come to rely on a lot is automatically sourcing a `.env` file in the current directory. This is for setting environment variables and secrets specific to a project and also keep them out of git. | |
| ``` | |
| function source_env() { | |
| if [[ -f .env ]]; then | |
| source .env | |
| fi | |
| } | |
| add-zsh-hook chpwd source_env | |
| ``` | |
| While in Austin I did a similar one for virtualenv. It looks for a `.venv` file including the name of the thing you want to work on and calls `workon` and `deactivate` automatically when you move in and out of directories that have that defined. | |
| ## tmux | |
| tmux does window and pane management within a single terminal window (it's a Terminal MUltipleXer). It takes some practice move around and get configured in a useful way, but it's incredibly powerful and has become absolutely essential in my workflow. Restoring a detached session has saved me many times after accidentally closing a terminal tab. | |
| ## dotfiles | |
| As you start to build up state with a bunch of config files it's helpful to have them in a place you can carry them around. I keep mine in git and symlink the source dotfiles to their respective places (home directory usually). | |
| This way I can tweak gitconfig/tmux/vim/zshrc and have it available and up to date across machines. | |
| ## git aliases | |
| Some common ones I use daily or frequently: | |
| st = status | |
| ci = commit | |
| br = branch | |
| co = checkout | |
| cp = cherry-pick | |
| Pretty logging: | |
| lg = log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr %an)%Creset' --abbrev-commit --date=relative | |
| Logging with graph: | |
| lol = log --graph --decorate --pretty=oneline --abbrev-commit | |
| Latest tag: | |
| latest-tag = describe --tags --abbrev=0 | |
| Logging after the latest tag (latest tag to HEAD) | |
| lg-latest = "!f() { \ | |
| git log `git latest-tag`..HEAD --format='%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s' --date=relative; \ | |
| }; f" | |
| Cleanup locally merged branches | |
| br-clean = "!f() { \ | |
| git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; \ | |
| }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment