My dotfiles and $HOME
Cloning
In your $HOME, do this:
git init . git remote add -t \* -f origin git@github.com:amontalenti/home.git git checkout master
You may hit conflicts with your existing .bashrc or .profile. Just move those to another directory and let it run.
Shell
I use zsh. For years, I used bash out of habit. I still keep my .bashrc and associated bash files around, for the rare case where I'm forced to use bash.
My bash environment is covered in these files:
| file | description |
|---|---|
| ~/.bashrc | pulls everything together |
| ~/.bash_aliases | handy shortcuts |
| ~/.bash_env | sets up my environment the way I like |
| ~/.bash_functions | when an alias doesn't cut it |
With zsh, I took a different approach. I have a simple .zshrc that implements
the equivalent of .bash_env, and then my prompt is implemented via an
oh-my-zsh theme that outsources most of its work to a Python script called
zshprompt.
| file | description |
|---|---|
| ~/.zshrc | pulls everything together |
| ~/.oh-my-zsh/themes/am.zsh-theme | theme that provides my left and right prompt |
| ~/opt/bin/zshprompt | Python script to generate prompt |
| ~/.bash_functions | I use these across zsh and bash |
| ~/.bash_aliases | I use these across zsh and bash |
The zshprompt script supports shortened paths, git branches, Python
virtualenvs, and last process exit code. Here is what it looks like:
Here's the guide:
- path =
~/repos/ptrack/streamparse - virtualenv =
ptrack+streamparse - branch =
feature/visitor-metrics
The right prompt auto-hides when you are writing a long command, and the path compresses
uses a shortening approach (thus ~/r/p/streamparse). You can also see the exit status
of 1 in red of the false command.
Editor
I use vim for text editing. I tend to use vim for editing all sorts of files, including:
- Python
- JavaScript
- CSS and LESS
- Clojure
- JSON and XML
- reStructuredText
- Markdown
- bash
- Dockerfile
- Thrift files
- configuration files
My vim configuration is a bit customized, as I use vim as a kind of UNIX IDE. However, I don't go crazy remapping things; in general, I'm pretty happy with vim's default mappings and have learned to love them. Most of these customizations are just to make editing typical files for me nicer.
Some nice IDE-like plugins for me include:
- NERDTree, for file navigation
- numbers, for better line number support
- ctrlp, for quick file opening
- fugitive, for git integration
- Gundo, for undo history
- Goyo, for distraction-free writing
- rope-vim, for Python refactoring support
- Taglist, for old-style code outlines / navigations
- tagbar, for improved code outlines / navigations
- vim-less, for editing LESS CSS files
- vim-jinja, for enhanced Jinja syntax highlighting
- vim-flake8, for Python syntax checking
- vim-virtualenv, for Python virtualenv support
- vim-fireplace, for Clojure interaction with nREPL
- vim-clojure-static, for Clojure basic editing support
- vim-sexp-ext, for Clojure text motions over S-expressions
- rainbow_parentheses, for Clojure paren highlighting
- vim-markdown, improved Markdown syntax handling
- vim-livedown, for live preview of Markdown files
- js-lib-syntax, adds some support for JS frameworks
- yajs, yet another Javascript syntax
- whitespace, to kill trailing whitespace in files
I then have a couple of plugins that just expand the vim vocabulary a little. These include:
- repeat, just makes the
.command more flexible and scriptable - surround, adds a noun to vim for "surroundings", useful for quoting and parens
These are referenced via git's submodule facility, because this seemed like the cleanest thing. Therefore, after cloning this repo, make sure you also clone the submodules as such:
git submodule init git submodule update
Then you will have all of the above.
Terminal and Editor Colors
In vim, I use the Mustang color scheme. Yes, I know about Solarized, and yes, I recognize that it is this new hotness with all of its fancy marketing pages, but honestly that color scheme will make me blind or make me want to murder my computer.
Mustang uses nice muted colors while still having enough contrast for scanning big chunks of code. I think it's very zen hacker like.
In tmux and screen, I use a matrix-like green-on-black color scheme. I do this so I can intimidate Parse.ly interns and make them think that learning UNIX will rewire their brain.
Unfortunately, there is some trickery with UNIX color schemes for terminals.
The first thing you have to learn about is that most terminals do not automatically place themselves in 256 color mode -- of course, they should, but this is UNIX. The software is Free and your time is worthless.
The answer is to be very mindful of two parts of your environment that will dramatically affect the way colors display. These are:
TERMenvironmental variable- Color palette of your terminal emulator
Let's cover these in turn. The TERM environmental variable should be
xterm-256color. Except when it shouldn't, which is when it's running under
tmux or screen (of course). In these environments, it should be
screen-256color. If this isn't set appropriately, programs like vim won't
use your fancy color scheme and you will be sad.
Finally, the color scheme will render differently depending on your color palette. What's going on here is that your terminal emulator can translate the colors being generated by vim and other programs, and translates them to actual pixel colors on your screen. (It's just yet another level of indirection.) I find that most of the default palettes are way too bright and loud. With gnome-terminal (Linux) and iTerm (OS X), I have been picking the Tango palettes, which are a tad muted and relatively standard across platforms.
Scripts
I put some scripts in ~/opt/bin that just make my life easier. Most
of these are bash scripts, some are little Python scripts as well. Some
of these are just meant to work around some UNIX annoyances.
Terminal Management
Originally, I used GNU screen for all my terminal management, so my
.screenrc is included here. However, I have now switched to
tmux, since I came across a nice book about it and it convinced me.
Funny enough, I was able to port over most of my customizations of
screen to tmux pretty straightforwardly. See .tmux.conf for that.
I also use a clever little tool called tmuxp, which is a Python frontend on tmux which allows you to save / re-open tmux "sessions".
Version Control
I used to use Mercurial, now I primarily use git. I don't customize
these too heavily, but my .hgrc and .gitconfig are included
here anyway.