Last active
January 21, 2016 01:16
-
-
Save mkroman/d40f3d85a2bd545c5002 to your computer and use it in GitHub Desktop.
My personal favorite and minimal .zshrc for servers
This file contains 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
# This is free and unencumbered software released into the public domain. | |
# | |
# Anyone is free to copy, modify, publish, use, compile, sell, or | |
# distribute this software, either in source code form or as a compiled | |
# binary, for any purpose, commercial or non-commercial, and by any | |
# means. | |
# | |
# In jurisdictions that recognize copyright laws, the author or authors | |
# of this software dedicate any and all copyright interest in the | |
# software to the public domain. We make this dedication for the benefit | |
# of the public at large and to the detriment of our heirs and | |
# successors. We intend this dedication to be an overt act of | |
# relinquishment in perpetuity of all present and future rights to this | |
# software under copyright law. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
# OTHER DEALINGS IN THE SOFTWARE. | |
# | |
# For more information, please refer to <http://unlicense.org> | |
## Zsh modules | |
# Load and initialize the `colors' environment variable with ANSI colors | |
autoload -Uz colors && colors | |
# Load and initialize tab-completion | |
autoload -Uz compinit && compinit | |
setopt completealiases | |
zstyle ':completion:*' menu select | |
# Load the url-quote-magic module that automagically adds quotes when a | |
# URL is inserted as an argument | |
autoload -Uz url-quote-magic && zle -N self-insert url-quote-magic | |
## Zsh options | |
# Automatically push `cd' dirs to the stack` | |
setopt autopushd pushdminus pushdsilent pushdtohome | |
# Allow commands like `..' to act like `cd ..' | |
setopt autocd | |
# Enable variable substitution in PROMPT and RPROMPT | |
setopt prompt_subst | |
## Environment | |
# History options | |
export HISTFILE=~/.history HISTSIZE=2000 SAVEHIST=2000 | |
# Set the left part of the prompt. | |
export PROMPT="%F{cyan}%n@%m%f %~ %# " | |
# Print a grey ¬ when trying to preserve a partial line | |
export PROMPT_EOL_MARK="%F{59}¬%f" | |
# Set the default browser | |
export BROWSER=chromium | |
# Set the default editor | |
export EDITOR=vim | |
# Print the wall-time for a process when it runs for a longer period of time | |
export REPORTTIME=4 | |
# Initialize rbenv if it's installed locally | |
if [ -e ~/.rbenv/bin/rbenv ]; then | |
export PATH="${HOME}/.rbenv/bin:${PATH}" | |
eval "$(rbenv init -)" | |
fi | |
# Load directory colors for `ls' | |
[ -e ~/.dircolors ] && eval "$(dircolors)" | |
# Add ~/.bin to the PATH stack if the directory exists | |
[ -d ~/.bin ] && export PATH="${HOME}/.bin:${PATH}" | |
# Set The GOPATH if the ~/.go directory exists | |
[ -d ~/.go ] && export GOPATH="${HOME}/.go" | |
# Use GPG as a SSH agent | |
[ -e ~/.gnupg ] && export SSH_AUTH_SOCK="${HOME}/.gnupg/S.gpg-agent.ssh" | |
## Aliases | |
# Unix aliases | |
alias ls='ls --color=auto -F' | |
alias ll='ls -l' | |
alias grep='grep --color=auto' | |
alias gdb='gdb -q' | |
# Git aliases | |
alias gush='git push' | |
alias gushh='git push origin master' | |
alias gash='git stash' | |
alias gasha='git stash apply' | |
alias gush='git push' | |
alias gushh='git push origin master' | |
alias gul='git pull' | |
alias gull='git pull origin master' | |
alias ga='git commit --amend' | |
# Bind keys according to terminfo - zsh doesn't do this by itself | |
[[ -n "${terminfo[kbs]}" ]] && bindkey -M emacs "${terminfo[kbs]}" backward-delete-char | |
[[ -n "${terminfo[khome]}" ]] && bindkey -M emacs "${terminfo[khome]}" beginning-of-line | |
[[ -n "${terminfo[kend]}" ]] && bindkey -M emacs "${terminfo[kend]}" end-of-line | |
[[ -n "${terminfo[kich1]}" ]] && bindkey -M emacs "${terminfo[kich1]}" overwrite-mode | |
[[ -n "${terminfo[kdch1]}" ]] && bindkey -M emacs "${terminfo[kdch1]}" delete-char | |
[[ -n "${terminfo[kcuu1]}" ]] && bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-history | |
[[ -n "${terminfo[kcud1]}" ]] && bindkey -M emacs "${terminfo[kcud1]}" down-line-or-history | |
[[ -n "${terminfo[kcub1]}" ]] && bindkey -M emacs "${terminfo[kcub1]}" backward-char | |
[[ -n "${terminfo[kcuf1]}" ]] && bindkey -M emacs "${terminfo[kcuf1]}" forward-char | |
# Run in emacs mode | |
bindkey -e | |
# Finally, make sure the terminal is in application mode, when zle is | |
# active. Only then are the values from $terminfo valid. | |
function zle-line-init() { | |
echoti smkx | |
} | |
function zle-line-finish() { | |
echoti rmkx | |
} | |
zle -N zle-line-init | |
zle -N zle-line-finish | |
## Miscellaneous functions | |
# Usage: `lvlc <stream url>` | |
function lvlc { | |
livestreamer $* best | |
} | |
# Usage: `mkdiff <file1> <file2>` | |
function mkdiff { | |
diff -udrP "$1" "$2" > diff.$(date "+%Y-%m-%d")."$1" | |
} | |
# Usage: `mkcd <path>` | |
function mkcd { | |
mkdir -p "$*" | |
cd "$*" | |
} | |
[ -e ~/.zshrc.local ] && source ~/.zshrc.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment