Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit (zsh files)

  • Loading branch information...
commit c8e07446c0fb53930974b1a686b1dce5f2235d49 0 parents
@jackfranklin authored
67 .zsh/git-prompt/gitstatus.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# change those symbols to whatever you prefer
+symbols = {'ahead of': '', 'behind': '', 'prehash':':'}
+
+from subprocess import Popen, PIPE
+
+gitsym = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE)
+branch, error = gitsym.communicate()
+
+if error.find('fatal: Not a git repository') != -1:
+ import sys
+ sys.exit(0)
+
+branch = branch.strip()[11:]
+
+
+changed_files = [namestat[0] for namestat in Popen(['git','diff','--name-status'], stdout=PIPE).communicate()[0].splitlines()]
+staged_files = [namestat[0] for namestat in Popen(['git','diff', '--staged','--name-status'], stdout=PIPE).communicate()[0].splitlines()]
+nb_changed = len(changed_files) - changed_files.count('U')
+nb_U = staged_files.count('U')
+nb_staged = len(staged_files) - nb_U
+staged = str(nb_staged)
+conflicts = str(nb_U)
+changed = str(nb_changed)
+nb_untracked = len(Popen(['git','ls-files','--others','--exclude-standard'],stdout=PIPE).communicate()[0].splitlines())
+untracked = str(nb_untracked)
+if not nb_changed and not nb_staged and not nb_U and not nb_untracked:
+ clean = '1'
+else:
+ clean = '0'
+
+remote = ''
+
+if not branch: # not on any branch
+ branch = symbols['prehash']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1]
+else:
+ remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].strip()
+ if remote_name:
+ merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].strip()
+ if remote_name == '.': # local
+ remote_ref = merge_name
+ else:
+ remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:])
+ revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE)
+ revlist = revgit.communicate()[0]
+ if revgit.poll(): # fallback to local
+ revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0]
+ behead = revlist.splitlines()
+ ahead = len([x for x in behead if x[0]=='>'])
+ behind = len(behead) - ahead
+ if behind:
+ remote += '%s%s' % (symbols['behind'], behind)
+ if ahead:
+ remote += '%s%s' % (symbols['ahead of'], ahead)
+
+out = '\n'.join([
+ branch,
+ remote,
+ staged,
+ conflicts,
+ changed,
+ untracked,
+ clean])
+print out
+
94 .zsh/git-prompt/zshrc.sh
@@ -0,0 +1,94 @@
+# To install source this file from your .zshrc file
+
+# Change this to reflect your installation directory
+export __GIT_PROMPT_DIR=~/.zsh/git-prompt
+# Initialize colors.
+autoload -U colors
+colors
+
+# Allow for functions in the prompt.
+setopt PROMPT_SUBST
+
+autoload -U add-zsh-hook
+
+add-zsh-hook chpwd chpwd_update_git_vars
+add-zsh-hook preexec preexec_update_git_vars
+add-zsh-hook precmd precmd_update_git_vars
+
+## Function definitions
+function preexec_update_git_vars() {
+ case "$2" in
+ git*)
+ __EXECUTED_GIT_COMMAND=1
+ ;;
+ esac
+}
+
+function precmd_update_git_vars() {
+ if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
+ update_current_git_vars
+ unset __EXECUTED_GIT_COMMAND
+ fi
+}
+
+function chpwd_update_git_vars() {
+ update_current_git_vars
+}
+
+function update_current_git_vars() {
+ unset __CURRENT_GIT_STATUS
+
+ local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
+ _GIT_STATUS=`python ${gitstatus}`
+ __CURRENT_GIT_STATUS=("${(@f)_GIT_STATUS}")
+ GIT_BRANCH=$__CURRENT_GIT_STATUS[1]
+ GIT_REMOTE=$__CURRENT_GIT_STATUS[2]
+ GIT_STAGED=$__CURRENT_GIT_STATUS[3]
+ GIT_CONFLICTS=$__CURRENT_GIT_STATUS[4]
+ GIT_CHANGED=$__CURRENT_GIT_STATUS[5]
+ GIT_UNTRACKED=$__CURRENT_GIT_STATUS[6]
+ GIT_CLEAN=$__CURRENT_GIT_STATUS[7]
+}
+
+
+git_super_status() {
+ if [ -n "$__CURRENT_GIT_STATUS" ]; then
+ STATUS="($GIT_BRANCH"
+ STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}"
+ if [ -n "$GIT_REMOTE" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_REMOTE$GIT_REMOTE%{${reset_color}%}"
+ fi
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR"
+ if [ "$GIT_STAGED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}"
+ fi
+ if [ "$GIT_CONFLICTS" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}"
+ fi
+ if [ "$GIT_CHANGED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}"
+ fi
+ if [ "$GIT_UNTRACKED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}"
+ fi
+ if [ "$GIT_CLEAN" -eq "1" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
+ fi
+ STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
+ echo "$STATUS"
+ fi
+}
+
+# Default values for the appearance of the prompt. Configure at will.
+ZSH_THEME_GIT_PROMPT_PREFIX="("
+ZSH_THEME_GIT_PROMPT_SUFFIX=")"
+ZSH_THEME_GIT_PROMPT_SEPARATOR="|"
+ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}"
+ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}●"
+ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}✖"
+ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}✚"
+ZSH_THEME_GIT_PROMPT_REMOTE=""
+ZSH_THEME_GIT_PROMPT_UNTRACKED=""
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✔"
+
+
1  .zshenv
@@ -0,0 +1 @@
+if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
284 .zshrc
@@ -0,0 +1,284 @@
+######################################################################
+# mako's zshrc file, v0.1
+#
+#
+######################################################################
+# Add this to your .oh-my-zsh theme if you're using those, or directly to your zsh theme :)
+
+# Colors vary depending on time lapsed.
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
+ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
+
+#Customized git status, oh-my-zsh currently does not allow render dirty status before branch
+git_custom_status() {
+ local cb=$(current_branch)
+ if [ -n "$cb" ]; then
+ echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
+ fi
+}
+
+# Determine the time since last commit. If branch is clean,
+# use a neutral color, otherwise colors will vary according to time.
+function git_time_since_commit() {
+ if git rev-parse --git-dir > /dev/null 2>&1; then
+ # Only proceed if there is actually a commit.
+ if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
+ # Get the last commit.
+ last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
+ now=`date +%s`
+ seconds_since_last_commit=$((now-last_commit))
+
+ # Totals
+ MINUTES=$((seconds_since_last_commit / 60))
+ HOURS=$((seconds_since_last_commit/3600))
+
+ # Sub-hours and sub-minutes
+ DAYS=$((seconds_since_last_commit / 86400))
+ SUB_HOURS=$((HOURS % 24))
+ SUB_MINUTES=$((MINUTES % 60))
+
+ if [[ -n $(git status -s 2> /dev/null) ]]; then
+ if [ "$MINUTES" -gt 30 ]; then
+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
+ elif [ "$MINUTES" -gt 10 ]; then
+ COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
+ else
+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
+ fi
+ else
+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
+ fi
+
+ if [ "$HOURS" -gt 24 ]; then
+ echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%})"
+ elif [ "$MINUTES" -gt 60 ]; then
+ echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%})"
+ else
+ echo "($COLOR${MINUTES}m%{$reset_color%})"
+ fi
+ fi
+ fi
+}
+
+# next lets set some enviromental/shell pref stuff up
+# setopt NOHUP
+#setopt NOTIFY
+#setopt NO_FLOW_CONTROL
+setopt APPEND_HISTORY
+# setopt AUTO_LIST # these two should be turned off
+# setopt AUTO_REMOVE_SLASH
+# setopt AUTO_RESUME # tries to resume command of same name
+unsetopt BG_NICE # do NOT nice bg commands
+setopt CORRECT # command CORRECTION
+setopt EXTENDED_HISTORY # puts timestamps in the history
+# setopt HASH_CMDS # turns on hashing
+setopt HIST_ALLOW_CLOBBER
+setopt HIST_REDUCE_BLANKS
+setopt INC_APPEND_HISTORY SHARE_HISTORY
+setopt ALL_EXPORT
+
+setopt MENUCOMPLETE
+# Set/unset shell options
+setopt notify globdots correct pushdtohome cdablevars autolist
+setopt correctall autocd recexact longlistjobs
+setopt autoresume histignoredups pushdsilent noclobber
+setopt autopushd pushdminus extendedglob rcquotes mailwarning
+unsetopt bgnice autoparamslash
+
+# Autoload zsh modules when they are referenced
+zmodload -a zsh/stat stat
+zmodload -a zsh/zpty zpty
+zmodload -a zsh/zprof zprof
+zmodload -ap zsh/mapfile mapfile
+
+source ~/.zsh/git-prompt/zshrc.sh
+# an example prompt
+
+PATH="/usr/local/share/npm/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
+TZ="Europe/London"
+HISTFILE=$HOME/.zhistory
+HISTSIZE=9999
+SAVEHIST=9999
+HOSTNAME="`hostname`"
+PAGER='less'
+EDITOR='vim'
+ autoload colors zsh/terminfo
+ if [[ "$terminfo[colors]" -ge 8 ]]; then
+ colors
+ fi
+ for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
+ eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
+ eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
+ (( count = $count + 1 ))
+ done
+ PR_NO_COLOR="%{$terminfo[sgr0]%}"
+#PS1="[$PR_MAGENTA%n$PR_NO_COLOR@$PR_GREEN%U%m%u$PR_NO_COLOR:$PR_RED%2c$PR_NO_COLOR]%(!.#.$)$(git_super_status) "
+RPS1=""
+PROMPT='$PR_RED%3c$PR_NO_COLOR $(git_super_status) $(git_time_since_commit)
+'
+#LANGUAGE=
+LC_ALL='en_US.UTF-8'
+LANG='en_US.UTF-8'
+LC_CTYPE=C
+DISPLAY=:0
+
+if [ $SSH_TTY ]; then
+ MUTT_EDITOR=vim
+else
+ MUTT_EDITOR=emacsclient.emacs-snapshot
+fi
+
+unsetopt ALL_EXPORT
+# # --------------------------------------------------------------------
+# # aliases
+# # --------------------------------------------------------------------
+alias slrn="slrn -n"
+alias man='LC_ALL=C LANG=C man'
+alias f=finger
+alias ll='ls -al'
+alias ls='ls -G'
+alias v=mvim --remote-silent
+alias offlineimap-tty='offlineimap -u TTY.TTYUI'
+alias hnb-partecs='hnb $HOME/partecs/partecs-hnb.xml'
+alias rest2html-css='rst2html --embed-stylesheet --stylesheet-path=/usr/share/python-docutils/s5_html/themes/default/print.css'
+alias dmesg="sudo dmesg"
+alias pd='cd ~/Dropbox/Sites/postdesk/pd'
+alias pdtheme='cd ~/Dropbox/Sites/postdesk/pd/wp-content/themes/postdesk'
+alias openpwd='open `pwd`'
+alias dropbox='cd ~/Dropbox/'
+alias editzshrc='vi ~/.zshrc'
+alias uniyear2='cd ~/Dropbox/Uni\ Year\ 2'
+cd () {
+ builtin cd "$*"
+ ls
+}
+
+function vim {
+ touch $*;
+ open -a MacVim $*
+}
+
+#if [[ $HOSTNAME == "kamna" ]] {
+# alias emacs='emacs -l ~/.emacs.kamna'
+#}
+
+# alias =clear
+stty erase ^H &>/dev/null
+bindkey "^[[3~" delete-char
+#chpwd() {
+# [[ -t 1 ]] || return
+# case $TERM in
+# sun-cmd) print -Pn "\e]l%~\e\\"
+# ;;
+# *xterm*|screen|rxvt|(dt|k|E)term) print -Pn "\e]2;%~\a"
+# ;;
+# esac
+#}
+
+#chpwd
+
+autoload -U compinit
+compinit
+bindkey '^r' history-incremental-search-backward
+bindkey "^[[5~" up-line-or-history
+bindkey "^[[6~" down-line-or-history
+bindkey "^[[H" beginning-of-line
+bindkey "^[[1~" beginning-of-line
+bindkey "^[[F" end-of-line
+bindkey "^[[4~" end-of-line
+bindkey ' ' magic-space # also do history expansion on space
+bindkey '^I' complete-word # complete on tab, leave expansion to _expand
+
+zstyle ':completion::complete:*' use-cache on
+zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
+
+zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
+zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
+zstyle ':completion:*' menu select=1 _complete _ignored _approximate
+zstyle -e ':completion:*:approximate:*' max-errors \
+ 'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
+zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
+zstyle ':completion:*:processes' command 'ps -axw'
+zstyle ':completion:*:processes-names' command 'ps -awxho command'
+# Completion Styles
+zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
+# list of completers to use
+zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
+
+# allow one error for every three characters typed in approximate completer
+zstyle -e ':completion:*:approximate:*' max-errors \
+ 'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
+
+# insert all expansions for expand completer
+zstyle ':completion:*:expand:*' tag-order all-expansions
+#
+#NEW completion:
+# 1. All /etc/hosts hostnames are in autocomplete
+# 2. If you have a comment in /etc/hosts like #%foobar.domain,
+# then foobar.domain will show up in autocomplete!
+zstyle ':completion:*' hosts $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts | grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}')
+# formatting and messages
+zstyle ':completion:*' verbose yes
+zstyle ':completion:*:descriptions' format '%B%d%b'
+zstyle ':completion:*:messages' format '%d'
+zstyle ':completion:*:warnings' format 'No matches for: %d'
+zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
+zstyle ':completion:*' group-name ''
+
+# match uppercase from lowercase
+zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
+
+# offer indexes before parameters in subscripts
+zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
+
+# command for process lists, the local web server details and host completion
+#zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
+#zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
+zstyle '*' hosts $hosts
+
+# Filename suffixes to ignore during completion (except after rm command)
+zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
+ '*?.old' '*?.pro'
+# the same for old style completion
+#fignore=(.o .c~ .old .pro)
+
+# ignore completion functions (until the _ignored completer)
+zstyle ':completion:*:functions' ignored-patterns '_*'
+zstyle ':completion:*:scp:*' tag-order \
+ files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
+zstyle ':completion:*:scp:*' group-order \
+ files all-files users hosts-domain hosts-host hosts-ipaddr
+zstyle ':completion:*:ssh:*' tag-order \
+ users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
+zstyle ':completion:*:ssh:*' group-order \
+ hosts-domain hosts-host users hosts-ipaddr
+zstyle '*' single-ignored show
+
+
+
+alias sites='cd ~/Dropbox/Sites'
+alias stewdent='cd ~/Dropbox/Sites/stewdent-ip'
+alias gitftpstewdent='git ftp push -s stewdent'
+alias burrstin='cd ~/Dropbox/Sites/burrstin/'
+alias tas='cd ~/Dropbox/Sites/tas'
+
+alias sshvps='ssh root@217.147.82.186'
+alias js='v8'
+alias tasdeploy='cap deploy && cap deploy:assets:upload'
+
+alias minecraftserver='java -Xmx2000M -Xms2000M -jar minecraft_server.jar'
+
+alias sshwebfaction='ssh jackfranklin@jackfranklin.webfactional.com'
+
+function mkdircd
+{
+ command mkdir $1 && cd $1
+}
+
+
+alias pyserver='open http://localhost:8000 && python -m SimpleHTTPServer'
+
+### Added by the Heroku Toolbelt
+export PATH="/usr/local/heroku/bin:$PATH"
Please sign in to comment.
Something went wrong with that request. Please try again.