Skip to content

Instantly share code, notes, and snippets.

@cutedogspark
Forked from yorkxin/.zshrc
Created September 25, 2017 03:14
Show Gist options
  • Select an option

  • Save cutedogspark/bdbb35b703692d512ee8e09d047abeba to your computer and use it in GitHub Desktop.

Select an option

Save cutedogspark/bdbb35b703692d512ee8e09d047abeba to your computer and use it in GitHub Desktop.

Revisions

  1. Yu-Cheng Chuang revised this gist Sep 9, 2013. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions yaci-agnoster.zsh-theme
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    # # README
    #
    # In order for this theme to render correctly, you will need a
    # [Powerline-patched font](https://gist.github.com/1595572).
    # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
    #
    # In addition, I recommend the
    # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
    @@ -25,8 +25,9 @@
    ### Segment drawing
    # A few utility functions to make it easy and re-usable to draw segmented prompts

    # Powerline special glyphs: https://powerline.readthedocs.org/en/latest/fontpatching.html#glyph-table
    CURRENT_BG='NONE'
    SEGMENT_SEPARATOR=''
    SEGMENT_SEPARATOR='\ue0b0'

    # Begin a segment
    # Takes two arguments, background and foreground. Both can be omitted,
    @@ -79,7 +80,7 @@ prompt_git() {
    else
    prompt_segment green black
    fi
    echo -n "${ref/refs\/heads\// }$dirty"
    echo -n "${ref/refs\/heads\//\ue0a0 }$dirty"
    fi
    }

  2. @yorkxin yorkxin created this gist Jun 13, 2013.
    72 changes: 72 additions & 0 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,72 @@
    # Path to your oh-my-zsh configuration.
    ZSH=$HOME/.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="yaci"
    ZSH_THEME="yaci-agnoster"


    # Set to this to use case-sensitive completion
    # CASE_SENSITIVE="true"

    # Comment this out to disable weekly auto-update checks
    # DISABLE_AUTO_UPDATE="true"

    # Uncomment following line if you want to disable colors in ls
    # DISABLE_LS_COLORS="true"

    # Uncomment following line if you want to disable autosetting terminal title.
    # DISABLE_AUTO_TITLE="true"

    # Uncomment following line if you want red dots to be displayed while waiting for completion
    # COMPLETION_WAITING_DOTS="true"

    # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
    # Example format: plugins=(rails git textmate ruby lighthouse)
    plugins=(bundler git osx rvm gem rake sublime urltools history-substring-search zsh-syntax-highlighting safe-paste)

    source $ZSH/oh-my-zsh.sh

    # Customize to your needs...

    export LANG=en_US.UTF-8
    export BUNDLER_EDITOR=subl

    function git_find_out_of_date_tracking_branches {
    git remote show origin | grep "local out of date"
    }

    function start_coding {
    cd ~/projects/$1
    git fetch -p
    git --no-pager log --graph --pretty=oneline --decorate --abbrev-commit master..origin/master
    git --no-pager log --graph --pretty=oneline --decorate --abbrev-commit master\^..master
    git_find_out_of_date_tracking_branches
    git status --short --branch master
    }

    export PATH="/usr/local/sbin:/usr/local/bin:/usr/local/share/python:$PATH"
    export PATH="$PATH:(brew --prefix coreutils)/libexec/gnubin:$HOME/bin"
    export NODE_PATH="/usr/local/lib/node"

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

    alias ll='ls -l'
    alias ls='ls -FG'
    alias js-beautify="js-beautify --indent-size=2"
    alias sudo='rvmsudo'
    alias gg='git grep'
    alias gll='git pull'

    alias reveal='open -R'

    # Stealed from Paul Irish: https://github.com/paulirish/dotfiles/blob/5f34dcbbabfae690769dc81a07e9fb38147ea956/.aliases#L51
    alias c='pygmentize -g'

    # sniffing HTTP requests. Stealed from Paul Irish: https://twitter.com/paul_irish/status/263753893979250688
    alias sniff="ngrep -W byline -d 'en0' -t '^(GET|POST) ' 'tcp and port 80'"

    export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
    115 changes: 115 additions & 0 deletions yaci-agnoster.zsh-theme
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,115 @@
    # vim:ft=zsh ts=2 sw=2 sts=2
    #
    # agnoster's Theme - https://gist.github.com/3712874
    # A Powerline-inspired theme for ZSH
    #
    # # README
    #
    # In order for this theme to render correctly, you will need a
    # [Powerline-patched font](https://gist.github.com/1595572).
    #
    # In addition, I recommend the
    # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
    # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
    # it has significantly better color fidelity.
    #
    # # Goals
    #
    # The aim of this theme is to only show you *relevant* information. Like most
    # prompts, it will only show git information when in a git working directory.
    # However, it goes a step further: everything from the current user and
    # hostname to whether the last call exited with an error to whether background
    # jobs are running in this shell will all be displayed automatically when
    # appropriate.

    ### Segment drawing
    # A few utility functions to make it easy and re-usable to draw segmented prompts

    CURRENT_BG='NONE'
    SEGMENT_SEPARATOR=''

    # Begin a segment
    # Takes two arguments, background and foreground. Both can be omitted,
    # rendering default background/foreground.
    prompt_segment() {
    local bg fg
    [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
    [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
    if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
    echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
    else
    echo -n "%{$bg%}%{$fg%} "
    fi
    CURRENT_BG=$1
    [[ -n $3 ]] && echo -n $3
    }

    # End the prompt, closing any open segments
    prompt_end() {
    if [[ -n $CURRENT_BG ]]; then
    echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
    else
    echo -n "%{%k%}"
    fi
    echo -n "%{%f%}"
    CURRENT_BG=''
    }

    ### Prompt components
    # Each component will draw itself, and hide itself if no information needs to be shown

    # Context: user@hostname (who am I and where am I)
    prompt_context() {
    local user=`whoami`

    if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
    fi
    }

    # Git: branch/detached head, dirty status
    prompt_git() {
    local ref dirty
    if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
    ZSH_THEME_GIT_PROMPT_DIRTY='±'
    dirty=$(parse_git_dirty)
    ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
    if [[ -n $dirty ]]; then
    prompt_segment yellow black
    else
    prompt_segment green black
    fi
    echo -n "${ref/refs\/heads\//⭠ }$dirty"
    fi
    }

    # Dir: current working directory
    prompt_dir() {
    prompt_segment blue black '%~'
    }

    # Status:
    # - was there an error
    # - am I root
    # - are there background jobs?
    prompt_status() {
    local symbols
    symbols=()
    [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
    [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
    [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"

    [[ -n "$symbols" ]] && prompt_segment black default "$symbols"
    }

    ## Main prompt
    build_prompt() {
    RETVAL=$?
    prompt_status
    # prompt_context
    prompt_dir
    prompt_git
    prompt_end
    }

    PROMPT='%{%f%b%k%}$(build_prompt) '