diff --git a/README.md b/README.md index cd9ce80..bc32089 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,16 @@ Welcome to my world. This is a collection of vim, tmux, and zsh configurations. ## Contents -+ Initial setup -+ vim setup and neovim setup -+ zsh setup -+ tmux configuration -+ git configuration -+ OSX configuration -+ Homebrew -+ Node.js ++ [Initial Setup and Installation](#initial-setup-and-installation) ++ [ZSH Setup](#zsh-setup) ++ [Vim and Neovim Setup](#vim-and-neovim-setup) ++ [Tmux Configuration](#tmux-configuration) ++ [Git configuration](#git-configuration) ++ [OSX configuration](osx-configuration) ++ [Homebrew](#homebrew) ++ [Node Installation](#node-installation) -## Initial setup and installation +## Initial Setup and Installation If on OSX, you will need to install the XCode CLI tools before continuing. To do so, open a terminal and type @@ -33,7 +33,45 @@ cd ~/.dotfiles Next, the isntall script will perform a check to see if it is running on an OSX machine. If so, it will install Homebrew if it is not currently installed and will install the homebrew packages listed in [`brew.sh`](install/brew.sh). Then, it will run [`installosx.sh`](installosx.sh) and change some OSX configurations. This file is pretty well documented and so it is advised that you __read through and comment out any changes you do not want__. Next, the script will call [`install/nvm.sh`](install/nvm.sh) to install Node.js (stable) using nvm. -## vim and neovim setup +## ZSH Setup + +ZSH is configured in the `zshrc.symlink` file, which will be symlinked to the home directory. The following occurs in this file: + +* set the `EDITOR` to nvim +* Load any `~/.terminfo` setup +* Set the `CODE_DIR` variable, pointing to the location where the code projects exist for exclusive autocompletion with the `c` command +* Recursively search the `$DOTFILES/zsh` directory for files ending in .zsh and source them +* source a `~/.localrc` if it exists so that additional configurations can be made that won't be kept track of in this dotfiles repo. This is good for things like API keys, etc. +* Add the `~/bin` and `$DOTFILES/bin` directories to the path +* Setup NVM, RVM, and hub if they exist +* Set the base16 colorscheme to use for both the terminal (iTerm2) and vim/neovim by exporting the `$THEME` and `$BACKGROUND` environment variables +* And more... + +### Prompt + +The prompt is meant to be simple while still providing a lot of information to the user, particularly about the status of the git project, if the PWD is a git project. This prompt sets `precmd`, `PROMPT` and `RPROMPT`. + +![](http://nicknisi.com/share/prompt.png) + +The `precmd` shows the current working directory in it and the `RPROMPT` shows the git and suspended jobs info. + +#### Prompt Git Info + +The git info shown on the `RPROMPT` displays the current branch name, and whether it is clean or dirty. + +![](http://nicknisi.com/share/git-branch-state.png) + +Additionally, there are ⇣ and ⇡ arrows that indicate whether a commit has happened and needs to be pushed (⇡), and whether commits have happened on the remote branch that need to be pulled (⇣). + +![](http://nicknisi.com/share/git-arrows.png) + +#### Suspended Jobs + +The prompt will also display a ✱ character in the `RPROMPT` indicating that there is a suspended job that exists in the background. This is helpful in keeping track of putting vim in the background by pressing CTRL-Z. + +![](http://nicknisi.com/share/suspended-jobs.png) + +## Vim and Neovim Setup vim and neovim should just work once the correct plugins are installed. To install the plugins, you will need to open vim/neovim in the following way: diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh index 1f5818f..1518267 100644 --- a/zsh/prompt.zsh +++ b/zsh/prompt.zsh @@ -1,23 +1,13 @@ # heavily inspired by the wonderful pure theme # https://github.com/sindresorhus/pure -# For my own and others sanity -# git: -# %b => current branch -# %a => current action (rebase/merge) -# prompt: -# %F => color dict -# %f => reset color -# %~ => current path -# %* => time -# %n => username -# %m => shortname host -# %(?..) => prompt conditional - %(condition.true.false) - +# needed to get things like current git branch autoload -Uz vcs_info zstyle ':vcs_info:*' enable git # You can add hg too if needed: `git hg` -zstyle ':vcs_info:git*' formats ' %b' -zstyle ':vcs_info:git*' actionformats ' %b|%a' +zstyle ':vcs_info:git*' use-simple true +zstyle ':vcs_info:git*' max-exports 2 +zstyle ':vcs_info:git*' formats ' %b' 'x%R' +zstyle ':vcs_info:git*' actionformats ' %b|%a' 'x%R' autoload colors && colors @@ -34,23 +24,35 @@ git_dirty() { fi } -git_prompt_info() { - ref=$(/usr/bin/git symbolic-ref HEAD 2>/dev/null) || return -# echo "(%{\e[0;33m%}${ref#refs/heads/}%{\e[0m%})" - echo "${ref#refs/heads/}" +# get the status of the current branch and it's remote +# If there are changes upstream, display a ⇣ +# If there are changes that have been committed but not yet pushed, display a ⇡ +git_arrows() { + # do nothing if there is no upstream configured + command git rev-parse --abbrev-ref @'{u}' &>/dev/null || return + + local arrows="" + local status + arrow_status="$(command git rev-list --left-right --count HEAD...@'{u}' 2>/dev/null)" + + # do nothing if the command failed + (( !$? )) || return + + # split on tabs + arrow_status=(${(ps:\t:)arrow_status}) + local left=${arrow_status[1]} right=${arrow_status[2]} + + (( ${right:-0} > 0 )) && arrows+="%F{011}⇣%f" + (( ${left:-0} > 0 )) && arrows+="%F{012}⇡%f" + + echo $arrows } -needs_push() { - if [[ $(git cherry -v @{upstream} 2>/dev/null) == "" ]] - then - echo "" - else - echo "%{$fg_bold[magenta]%}☁%f " - fi -} # indicate a job (for example, vim) has been backgrounded +# If there is a job in the background, display a ✱ suspended_jobs() { + local sj sj=$(jobs 2>/dev/null | tail -n 1) if [[ $sj == "" ]]; then echo "" @@ -61,8 +63,8 @@ suspended_jobs() { precmd() { vcs_info - print -P '\n%F{207}%~' + print -P '\n%F{205}%~' } -export PROMPT='%(?.%F{magenta}.%F{red})❯%f ' -export RPROMPT='`git_dirty`%F{241}$vcs_info_msg_0_%f `needs_push``suspended_jobs`' +export PROMPT='%(?.%F{205}.%F{red})❯%f ' +export RPROMPT='`git_dirty`%F{241}$vcs_info_msg_0_%f `git_arrows``suspended_jobs`' diff --git a/zsh/zshrc.symlink b/zsh/zshrc.symlink index 411c43b..474e8fe 100644 --- a/zsh/zshrc.symlink +++ b/zsh/zshrc.symlink @@ -7,11 +7,12 @@ export REPORTTIME=10 [[ -e ~/.terminfo ]] && export TERMINFO_DIRS=~/.terminfo:/usr/share/terminfo # define the code directory +# This is where my code exists and where I want the `c` autocomplete to work from exclusively if [[ -d ~/code ]]; then export CODE_DIR=~/code fi -# load all zsh config files +# source all .zsh files inside of the zsh/ directory for config ($ZSH/**/*.zsh) source $config if [[ -a ~/.localrc ]]; then @@ -25,7 +26,7 @@ compinit for config ($ZSH/**/*completion.sh) source $config -export EDITOR='vim' +export EDITOR='nvim' export PATH=/usr/local/bin:$PATH