diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c319f12 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule ".zsh/oh-my/zsh"] + path = .zsh/oh-my/zsh + url = https://github.com/robbyrussell/oh-my-zsh.git +[submodule ".zsh/oh-my-zsh"] + path = .zsh/oh-my-zsh + url = https://github.com/robbyrussell/oh-my-zsh.git diff --git a/.zsh/auto-gopath.sh b/.zsh/auto-gopath.sh new file mode 100644 index 0000000..981b62d --- /dev/null +++ b/.zsh/auto-gopath.sh @@ -0,0 +1,32 @@ +#!/usr/local/bin/zsh + +_autogopath_find_gopath_marker() { + SEARCH_PATH=$1 + if [ -e "${SEARCH_PATH}/.gopath" ]; then + AUTOGOPATH_PATH=${SEARCH_PATH} + return + fi + + if ( test "/" = "${SEARCH_PATH}" ); then + AUTOGOPATH_PATH="" + return + fi + + SEARCH_PATH=$(dirname ${SEARCH_PATH}) + _autogopath_find_gopath_marker ${SEARCH_PATH} +} + +_autogopath_chpwd_handler() { + _autogopath_find_gopath_marker $(pwd) + + if [ -z "$AUTOGOPATH_PATH" ]; then + export GOPATH=$AUTOGOPATH_DEFAULT + else + export GOPATH=$AUTOGOPATH_PATH + fi +} + +autoload -U add-zsh-hook +add-zsh-hook chpwd _autogopath_chpwd_handler + +_autogopath_chpwd_handler diff --git a/.zsh/config-git.zsh b/.zsh/config-git.zsh new file mode 100644 index 0000000..ec09e5f --- /dev/null +++ b/.zsh/config-git.zsh @@ -0,0 +1,7 @@ +function config_public { + git --git-dir=${HOME}/.cfg/public --work-tree=${HOME} $@ +} + +function config_secret { + git --git-dir=${HOME}/.cfg/secret --work-tree=${HOME} $@ +} diff --git a/.zsh/config.sh b/.zsh/config.sh new file mode 100644 index 0000000..49df5ea --- /dev/null +++ b/.zsh/config.sh @@ -0,0 +1,42 @@ +## RVM binaries +export PATH=$HOME/.rvm/bin:$PATH + +## Brew installed binaries +export PATH=/usr/local/sbin:/usr/local/bin:$PATH + +## Make android-sdk known +export PATH=$PATH:$HOME/android-sdk-macosx/platform-tools + +## Activate go using gimme if any go version is available +[ -e ${HOME}/.gimme/envs/latest.env ] && source ${HOME}/.gimme/envs/latest.env + +## Custom scripts +export PATH=$HOME/bin:$PATH +source $HOME/config/zsh/go-binaries.sh + +## Some default settings +export EDITOR=/usr/bin/vim +export AUTOGOPATH_DEFAULT=$HOME/gocode +export ANSIBLE_NOCOWS=1 +export LANG=en_US.UTF-8 +export LC_CTYPE=${LANG} +export TZ="Europe/Berlin" + +## Map alt+← and alt+→ to move cursor word wise +bindkey -e +bindkey '^[[1;9C' forward-word +bindkey '^[[1;9D' backward-word + +## Aliases +alias alpine='docker run --rm -ti alpine /bin/sh' +alias gentex='drm dev -- docker run --rm -ti -v $(pwd):/src luzifer/xetexgen' +alias gometalinter='gometalinter -D aligncheck -D errcheck -e bindata.go' + +## Initialize GPG agent +source ${HOME}/.zsh/gpg-agent.plugin.zsh + +## Load config-git functions +source ${HOME}/.zsh/config-git.zsh + +## Load local-config if available +[ -e ${HOME}/.zsh/local-config.zsh ] && source ${HOME}/.zsh/local-config.zsh diff --git a/.zsh/go-binaries.sh b/.zsh/go-binaries.sh new file mode 100644 index 0000000..eb9bcf6 --- /dev/null +++ b/.zsh/go-binaries.sh @@ -0,0 +1,3 @@ +for godir in $(cat $HOME/.config/godirs); do + export PATH=$PATH:${godir}/bin +done diff --git a/.zsh/gpg-agent.plugin.zsh b/.zsh/gpg-agent.plugin.zsh new file mode 100644 index 0000000..bf36395 --- /dev/null +++ b/.zsh/gpg-agent.plugin.zsh @@ -0,0 +1,20 @@ +local GPG_ENV=$HOME/.gnupg/gpg-agent.env + +function start_agent_nossh { + eval $(/usr/bin/env gpg-agent --quiet --daemon --write-env-file ${GPG_ENV} --allow-preset-passphrase 2> /dev/null) + chmod 600 ${GPG_ENV} +} + +# source settings of old agent, if applicable +if [ -f "${GPG_ENV}" ]; then + source ${GPG_ENV} > /dev/null + export GPG_AGENT_INFO +fi + +# check again if another agent is running using the newly sourced settings +if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then + start_agent_nossh; +fi + +GPG_TTY=$(tty) +export GPG_TTY diff --git a/.zsh/oh-my-custom/luzifer.zsh-theme b/.zsh/oh-my-custom/luzifer.zsh-theme new file mode 100644 index 0000000..353a4b8 --- /dev/null +++ b/.zsh/oh-my-custom/luzifer.zsh-theme @@ -0,0 +1,93 @@ +# luzifer.zsh-theme + +# Use with a dark background and 256-color terminal! +# Meant for people with RVM and git. Tested only on OS X 10.7. + +# You can set your computer name in the ~/.box-name file if you want. + +# Borrowing shamelessly from these oh-my-zsh themes: +# bira +# robbyrussell +# +# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ + +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '⠠⠵' && return + echo '○' +} + +function box_name { + [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST} +} + +function git_describe { + git describe --tags 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo "" +} + +function awsenv_prompt { + local pr=$(awsenv prompt 2>/dev/null) + [ -z "${pr}" ] || echo "${bracket_open} ${pr} ${bracket_close}" +} + +function build_git_prompt { + $( test "${NO_RIGHT}" = "true" ) && return + git branch >/dev/null 2>/dev/null || return + local INDEX=$(command git status --porcelain -b 2> /dev/null) + echo -n "${bracket_open} %{$fg[blue]%}" + local REMOTE=$(command git remote -v | grep fetch) + (echo "$REMOTE" | grep -q bitbucket.org) && echo -n "B " + (echo "$REMOTE" | grep -q github.com) && echo -n "G " + (echo "$REMOTE" | grep -q gitlab.com) && echo -n "L " + echo -n "%{$reset_color%}" + echo -n "$(git_current_branch) " + echo -n "($(git_describe)) " + # Repository status + echo -n "%{$FG[236]%}" + ( echo "$INDEX" | grep -E '^\?\? ' &> /dev/null ) && echo -n "%{$fg[blue]%}" + echo -n "U%{$FG[236]%}" + ( echo "$INDEX" | grep -E '^(A |M ) ' &> /dev/null ) && echo -n "%{$fg[green]%}" + echo -n "A%{$FG[236]%}" + ( echo "$INDEX" | grep -E '^( M|AM| T) ' &> /dev/null ) && echo -n "%{$fg[yellow]%}" + echo -n "M%{$FG[236]%}" + ( echo "$INDEX" | grep -E '^R ' &> /dev/null ) && echo -n "%{$fg[yellow]%}" + echo -n "R%{$FG[236]%}" + ( echo "$INDEX" | grep -E '^( D|D |AD) ' &> /dev/null ) && echo -n "%{$fg[red]%}" + echo -n "D%{$FG[236]%}" + ( git rev-parse --verify refs/stash >/dev/null 2>&1 ) && echo -n "%{$fg[green]%}" + echo -n "S%{$FG[236]%}" + if ( echo "$INDEX" | grep '^## .*ahead.*behind' &> /dev/null ); then + echo -n "%{$fg[red]%}↔" + elif ( echo "$INDEX" | grep '^## .*ahead' &> /dev/null ); then + echo -n "%{$fg[green]%}→" + elif ( echo "$INDEX" | grep '^## .*behind' &> /dev/null ); then + echo -n "%{$fg[yellow]%}←" + else + echo -n "%{$fg[green]%}=" + fi + echo -n "%{$reset_color%} ${bracket_close}" +} + +local current_dir='$($HOME/bin/short_path)' +local git_info='$(build_git_prompt)' + +local bracket_open="%{$FG[239]%}[%{$reset_color%}" +local bracket_close="%{$FG[239]%}]%{$reset_color%}" + +local prompt_part_time="${bracket_open} %T ${bracket_close}" +local prompt_part_user="${bracket_open} %{$FG[040]%}%n%{$reset_color%}%{$FG[239]%}@%{$reset_color%}%{$FG[033]%}$(box_name)%{$reset_color%} ${bracket_close}" +local prompt_part_path="%{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}" +local prompt_part_exit="%(?..${bracket_open} %{$fg[red]%}%?%{${reset_color}%} ${bracket_close})" +local prompt_part_char='$(prompt_char)' + +PROMPT=" +╭─ ${prompt_part_time}${prompt_part_user}$(awsenv_prompt)${prompt_part_exit} ${prompt_part_path} +╰─${prompt_part_char} " + +RPROMPT="${git_info}" + +ZSH_THEME_GIT_PROMPT_PREFIX="" +ZSH_THEME_GIT_PROMPT_SUFFIX="" + +# Format for git_prompt_long_sha() and git_prompt_short_sha() +ZSH_THEME_GIT_PROMPT_SHA_BEFORE="" +ZSH_THEME_GIT_PROMPT_SHA_AFTER="" diff --git a/.zsh/oh-my-zsh b/.zsh/oh-my-zsh new file mode 160000 index 0000000..cc8285b --- /dev/null +++ b/.zsh/oh-my-zsh @@ -0,0 +1 @@ +Subproject commit cc8285b1f708c33338d280bbb5481dc93bafa458 diff --git a/.zsh/zshrc b/.zsh/zshrc new file mode 100644 index 0000000..1dec647 --- /dev/null +++ b/.zsh/zshrc @@ -0,0 +1,87 @@ +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.zsh/oh-my-zsh + +# Set name of the theme to load. +# Look in ~/.oh-my-zsh/themes/ +# Optionally, if you set this to "random", it'll load a random theme each +# time that oh-my-zsh is loaded. +ZSH_THEME="luzifer" + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to use hyphen-insensitive completion. Case +# sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_ZSH_DAYS=13 + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +HIST_STAMPS="yyyy-mm-dd" + +# Would you like to use another custom folder than $ZSH/custom? +ZSH_CUSTOM=$HOME/.zsh/oh-my-custom + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(docker git github golang osx zsh_reload z) + +# User configuration + +export PATH=$HOME/bin:/usr/local/bin:$PATH +# export MANPATH="/usr/local/man:$MANPATH" + +source $ZSH/oh-my-zsh.sh + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# ssh +# export SSH_KEY_PATH="~/.ssh/dsa_id" + +# Set personal aliases, overriding those provided by oh-my-zsh libs, +# plugins, and themes. Aliases can be placed here, though oh-my-zsh +# users are encouraged to define aliases within the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" + +source $HOME/.zsh/config.sh +source $HOME/.zsh/auto-gopath.sh diff --git a/.zshrc b/.zshrc new file mode 120000 index 0000000..a693074 --- /dev/null +++ b/.zshrc @@ -0,0 +1 @@ +.zsh/zshrc \ No newline at end of file