Skip to content

Instantly share code, notes, and snippets.

@kouphax
Last active August 29, 2015 14:28

Revisions

  1. kouphax revised this gist Aug 25, 2015. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions .tmux.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    set-window-option -g mode-keys vi
    set-option -g mouse-select-pane on
    set-option -g mouse-select-window on
    set-window-option -g mode-mouse on

    set-option -g default-command "reattach-to-user-namespace -l zsh"

    # Use vim keybindings in copy mode
    setw -g mode-keys vi

    # Setup 'v' to begin selection as in Vim
    bind-key -t vi-copy v begin-selection
    bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

    # Update default binding of `Enter` to also use copy-pipe
    unbind -t vi-copy Enter
    bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"

    # Bind ']' to use pbpaste
    bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
  2. kouphax created this gist Aug 25, 2015.
    72 changes: 72 additions & 0 deletions billy-elliot.zsh-theme
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,72 @@
    function draw() {
    local divider_row=''
    local divider_char='-'
    for i in `seq 1 $COLUMNS`; do
    divider_row=$divider_row$divider_char
    done
    echo $divider_row
    }

    local ret_status="%(?:%{$fg_bold[green]%}⚒ :%{$fg_bold[red]%}⚒ %s)"

    #PROMPT='$(draw)
    #%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
    PROMPT='$(draw)
    ${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
    ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
    ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
    ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
    ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

    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]%}"

    # 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
    else
    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
    echo "[$COLOR~]"
    fi
    fi
    }

    RPROMPT='${return_status}$(git_time_since_commit)$(git_prompt_status)%{$reset_color%}'
    28,655 changes: 28,655 additions & 0 deletions com.googlecode.iterm2.plist
    28,655 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.