Skip to content

Instantly share code, notes, and snippets.

@yonchu
Created October 23, 2012 01:14
Show Gist options
  • Select an option

  • Save yonchu/3936073 to your computer and use it in GitHub Desktop.

Select an option

Save yonchu/3936073 to your computer and use it in GitHub Desktop.

Revisions

  1. yonchu revised this gist Nov 29, 2012. 2 changed files with 143 additions and 57 deletions.
    146 changes: 115 additions & 31 deletions gits.sh
    Original file line number Diff line number Diff line change
    @@ -13,46 +13,130 @@ if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
    exit 1
    fi

    cmd_remote_update_info(){
    local remote_name=${1:-origin}
    echo "git remote show $remote_name \
    | tail -1 | sed 's/.*\((.*)\)/\1/' | tr '\n' ' ' \
    && git remote -v | grep '^origin.*(push)$' | tr '\t' ' ' | cut -d' ' -f 2"
    }

    echo -e "===== \033[0;32mStatus (git status -sb)\033[0;39m ====="
    git status -sb
    ## Common
    get_branch () {
    # HEAD branch
    local head_branch=$(git symbolic-ref -q --short HEAD)
    if [ -z "$head_branch" ]; then
    local prehash=$(git rev-parse --short HEAD)
    echo "Not on any branch : prehash=$prehash"
    return 1
    fi
    echo "$head_branch"
    }

    echo -e "===== \033[0;32mRemote Update Info\033[0;39m ====="
    # HEAD branch
    head_branch=$(git symbolic-ref -q --short HEAD)
    if [ -z "$head_branch" ]; then
    prehash=$(git rev-parse --short HEAD)
    echo 'Not on any branch : prehash=$prehash'
    else
    get_remote_name () {
    local head_branch=$1
    # The remote name of HEAD branch (e.g. origin)
    remote_name=$(git config branch."${head_branch}".remote)
    local remote_name=$(git config branch."${head_branch}".remote)
    if [ -z "$remote_name" ]; then
    echo 'No remote repository'
    else
    echo -e "## \033[0;32m$remote_name\033[0;39m"
    eval $(cmd_remote_update_info "$remote_name")
    return 1
    fi
    fi
    echo "$remote_name"
    }

    # Submodule
    (
    cd "$(git rev-parse --show-toplevel)" >/dev/null 2>&1;
    echo -e "===== \033[0;33mSubmodule Status (git submodule status)\033[0;39m ====="
    sub_status=$(git submodule status)
    if [ -n "$sub_status" ]; then
    echo "$sub_status"
    cd_git_toplevel() {
    cd "$1"
    if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
    return 1
    fi
    cd "$(git rev-parse --show-toplevel)" >/dev/null 2>&1
    }

    ## Submodule
    print_submodule_update_info() {
    (
    cd_git_toplevel "$1" || return 1
    local -a submodule_dirs
    IFS=$'\n' submodule_dirs=($(git submodule | cut -d ' ' -f 3 | sed 's/(.*)$//'))
    if [ -z "$submodule_dirs" ]; then
    return 0
    fi
    for sub_dir in "${submodule_dirs[@]}"; do
    echo " - $(print_remote_update_info "$sub_dir")"
    done
    )
    }

    ## Remote
    print_remote_update_info () {
    (
    local dir=$1
    cd_git_toplevel "$dir" || return 1

    echo -e "===== \033[0;33mSubmodule Remote Update Info\033[0;39m ====="
    origin_status=$(git submodule foreach "$(cmd_remote_update_info)")
    echo "$origin_status" | sed '/^Entering/d'
    local status
    local url

    local branch
    local merge_branch
    local remote_branch
    branch=$(get_branch)
    if [ $? -eq 0 ]; then
    remote_name=$(get_remote_name "$branch")
    if [ $? -eq 0 ]; then
    merge_branch=$(git config branch."$branch".merge | sed -E s/^.\{11\}//g)
    if [ -z "$merge_branch" ]; then
    status='No merge branch'
    else
    local remote_show=$(git remote show "$remote_name")
    status=$(echo "$remote_show" \
    | grep "^ *$merge_branch pushes" | sed 's/.*(\(.*\)).*/\1/')
    url=$(echo "$remote_show" | grep '^ *Push' | sed 's/^.*URL: \(.*\)$/\1/')
    remote_branch=$(echo "$remote_show" \
    | grep "^ *$merge_branch pushes" | sed 's/.*pushes to \(.*\) (.*)/\1/')
    fi
    else
    status=$remote_name
    fi
    else
    status=$branch
    branch=''
    fi
    if [ "$status" != "up to date" ]; then
    status="\033[0;31m$status\033[0;39m"
    fi
    local branch_info=''
    if [ -n "$branch" ]; then
    branch_info=$branch
    if [ -n "$merge_branch" ]; then
    branch_info="$branch_info:$merge_branch -> $remote_branch"
    fi
    branch_info="($branch_info)"
    fi

    local update_info="($status) [${dir%/}]$branch_info${url:+ URL: $url}"
    echo -e "$update_info"
    )
    }

    print_update_info() {
    local dir=$1
    if [ ! -e "$dir" ]; then
    echo -e "\033[0;31mDirectory not found!! : $dir\033[0;39m"
    return 1
    elif [ ! -d "$dir" ]; then
    return 0
    fi
    )
    print_remote_update_info "$dir" \
    && print_submodule_update_info "$dir"
    }

    ## Main
    cd_git_toplevel

    echo -e "===== \033[0;32mStatus (git status -sb)\033[0;39m ====="
    git status -sb

    sub_status=$(git submodule status)
    if [ -n "$sub_status" ]; then
    echo -e "===== \033[0;33mSubmodule Status (git submodule status)\033[0;39m ====="
    echo "$sub_status"
    fi

    echo -e "===== \033[0;32mRemote Update Info\033[0;39m ====="
    print_update_info '.'

    echo -e "===== \033[0;34mRemote List (git remote -v)\033[0;39m ====="
    git remote -v
    54 changes: 28 additions & 26 deletions readme.txt
    Original file line number Diff line number Diff line change
    @@ -2,38 +2,40 @@

    $ gits
    ===== Status (git status -sb) =====
    ## master...origin/master [ahead 1]
    ## master...origin/master [ahead 15]
    M bin/gits
    ===== Remote Update Info =====
    ## origin
    (fast-forwardable) git@github.com:yonchu/dotfiles.git
    ===== Submodule Status (git submodule status) =====
    9150244afd8cb992b90390ea9789054ed376c468 .tmux/tmux-powerline (heads/master)
    1579b53125011063b6b37c3ffde8cc05023e29ad .tmux/tmux-powerline-wrapper (heads/master)
    3b2a24914b9ff3a51673a1f2223c57a21dbda390 .vim/neobundle.vim (ver.2.0-190-g3b2a249)
    4ac57be0cdcae5aa0f482916ae68e48187856df0 .zsh/dircolors-solarized (heads/master)
    f7c0f031cab5eca993e517200df68e43184ffcbf .zsh/functions/Completion/zsh-completions (0.3.0-89-gf7c0f03)
    184ce5516f2dc9bb440ca4bdcbd71a1176c9edb7 .tmux/tmux-powerline (heads/master)
    d02fff8809db1ba9ee8634c0bcfed3cbb577fa51 .tmux/tmux-powerline-wrapper (heads/master)
    9a584520b5cf4be0601a1b4016e14e40c409381f .vim/neobundle.vim (ver.2.0-203-g9a58452)
    9c263266bc312685a9bcc554bc1c00f0c8e84b16 .zsh/cdd (heads/master)
    0fe095d60c7d12115d3dc7ee53d0e3d49acba04c .zsh/dircolors-solarized (heads/master)
    144967fe6900f1e40e13ac307de3c66f6287aa44 .zsh/functions/Completion/zsh-completions (0.3.0-95-g144967f)
    7e7a3901daad41b6eead0865d7363c922f6ca8ad .zsh/git-edit (heads/master)
    dfd4308ae84da481f774b3f5e732ee277d9d8769 .zsh/z (v1.4-2-gdfd4308)
    45194671af8e1d6b37b16e214a58674762ab8e49 .zsh/zsh-syntax-highlighting (0.1.2-2-g4519467)
    2b4704d67920e89e2e809ff8eae058bae7d57c59 .zsh/zsh-vcs-prompt (heads/master)
    ===== Submodule Remote Update Info =====
    (local out of date) https://github.com/erikw/tmux-powerline.git
    (local out of date) https://github.com/yonchu/tmux-powerline-wrapper.git
    (local out of date) git://github.com/Shougo/neobundle.vim.git
    (up to date) git://github.com/seebi/dircolors-solarized.git
    (up to date) https://github.com/zsh-users/zsh-completions.git
    (up to date) git://github.com/rupa/z.git
    (up to date) https://github.com/yonchu/zsh-syntax-highlighting.git
    (up to date) https://github.com/yonchu/zsh-vcs-prompt.git
    a706839a881a630939b72062b5ece0bf569d53d3 .zsh/zsh-vcs-prompt (heads/master)
    ===== Remote Update Info =====
    (fast-forwardable) [.](master:master -> master) URL: /Users/yonchu/Dropbox/Repos/git/dotfiles.git
    - (local out of date) [.tmux/tmux-powerline](master:master -> master) URL: https://github.com/erikw/tmux-powerline.git
    - (local out of date) [.tmux/tmux-powerline-wrapper](master:master -> master) URL: https://github.com/yonchu/tmux-powerline-wrapper.git
    - (up to date) [.vim/neobundle.vim](master:master -> master) URL: git://github.com/Shougo/neobundle.vim.git
    - (up to date) [.zsh/cdd](master:master -> master) URL: git://github.com/m4i/cdd.git
    - (up to date) [.zsh/dircolors-solarized](master:master -> master) URL: git://github.com/seebi/dircolors-solarized.git
    - (up to date) [.zsh/functions/Completion/zsh-completions](master:master -> master) URL: https://github.com/zsh-users/zsh-completions.git
    - (up to date) [.zsh/git-edit](master:master -> master) URL: https://github.com/yonchu/git-edit.git
    - (up to date) [.zsh/z](master:master -> master) URL: git://github.com/rupa/z.git
    - (up to date) [.zsh/zsh-syntax-highlighting](master:master -> master) URL: https://github.com/yonchu/zsh-syntax-highlighting.git
    - (up to date) [.zsh/zsh-vcs-prompt](master:master -> master) URL: https://github.com/yonchu/zsh-vcs-prompt.git
    ===== Remote List (git remote -v) =====
    github git@github.com:yonchu/dotfiles.git (fetch)
    github git@github.com:yonchu/dotfiles.git (push)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (fetch)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (push)
    github git@github.com:yonchu/dotfiles.git (fetch)
    github git@github.com:yonchu/dotfiles.git (push)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (fetch)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (push)
    ===== Branch List (git branch -av) =====
    * master a49010a [ahead 1] Update .gitconfig, Add .gittemplate
    remotes/github/master 33c9001 Add a screenshot for iTerm on Mac
    * master 65d8813 [ahead 15] Update setup.sh
    remotes/github/master 696affd Fix bugs about `git-check-remote-update` and `git-check-status`
    remotes/origin/HEAD -> origin/master
    remotes/origin/master 33c9001 Add a screenshot for iTerm on Mac
    remotes/origin/master 696affd Fix bugs about `git-check-remote-update` and `git-check-status`
    ===== Stash List (git stash list) =====
    stash@{0}: WIP on master: a49010a Update .gitconfig, Add .gittemplate
  2. yonchu revised this gist Nov 26, 2012. 1 changed file with 6 additions and 8 deletions.
    14 changes: 6 additions & 8 deletions gits.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    #

    if ! type git > /dev/null 2>&1; then
    echo 'Error: Git is not installed.' 2>%1
    echo 'Error: Git is not installed' 2>&1
    exit 1
    fi

    @@ -17,23 +17,21 @@ cmd_remote_update_info(){
    local remote_name=${1:-origin}
    echo "git remote show $remote_name \
    | tail -1 | sed 's/.*\((.*)\)/\1/' | tr '\n' ' ' \
    && git remote -v | head -1 | tr '\t' ' ' | cut -d' ' -f 2"
    && git remote -v | grep '^origin.*(push)$' | tr '\t' ' ' | cut -d' ' -f 2"
    }

    echo -e "===== \033[0;32mStatus (git status -sb)\033[0;39m ====="
    git status -sb

    echo -e "===== \033[0;32mRemote Update Info\033[0;39m ====="
    # HEAD branch (e.g. refs/heads/<branch-name>)
    head_branch=$(git symbolic-ref HEAD)
    # HEAD branch
    head_branch=$(git symbolic-ref -q --short HEAD)
    if [ -z "$head_branch" ]; then
    prehash=$(git rev-parse --short HEAD)
    echo 'Not on any branch : prehash=$prehash'
    else
    # Retrieve brach name (like master) from HEAD branch
    branch=$(echo "$head_branch" | sed -E s/^.\{11\}//g)
    # The remote name of HEAD branch (e.g. origin)
    remote_name=$(git config branch."${branch}".remote)
    remote_name=$(git config branch."${head_branch}".remote)
    if [ -z "$remote_name" ]; then
    echo 'No remote repository'
    else
    @@ -63,4 +61,4 @@ echo -e "===== \033[0;35mBranch List (git branch -av)\033[0;39m ====="
    git branch -av

    echo -e "===== \033[0;36mStash List (git stash list)\033[0;39m ====="
    git stash list
    git stash list
  3. yonchu revised this gist Nov 14, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gits.sh
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,7 @@ else
    echo 'No remote repository'
    else
    echo -e "## \033[0;32m$remote_name\033[0;39m"
    eval $(cmd_remote_update_info)
    eval $(cmd_remote_update_info "$remote_name")
    fi
    fi

  4. yonchu revised this gist Nov 6, 2012. 2 changed files with 39 additions and 10 deletions.
    44 changes: 35 additions & 9 deletions gits.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash
    #
    # gitリポジトリの詳細情報を表示
    # Print detail infomation about current git repository.
    #

    if ! type git > /dev/null 2>&1; then
    @@ -13,20 +13,46 @@ if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
    exit 1
    fi

    cmd_remote_update_info(){
    local remote_name=${1:-origin}
    echo "git remote show $remote_name \
    | tail -1 | sed 's/.*\((.*)\)/\1/' | tr '\n' ' ' \
    && git remote -v | head -1 | tr '\t' ' ' | cut -d' ' -f 2"
    }

    echo -e "===== \033[0;32mStatus (git status -sb)\033[0;39m ====="
    git status -sb

    echo -e "===== \033[0;32mRemote Update Info\033[0;39m ====="
    # HEAD branch (e.g. refs/heads/<branch-name>)
    head_branch=$(git symbolic-ref HEAD)
    if [ -z "$head_branch" ]; then
    prehash=$(git rev-parse --short HEAD)
    echo 'Not on any branch : prehash=$prehash'
    else
    # Retrieve brach name (like master) from HEAD branch
    branch=$(echo "$head_branch" | sed -E s/^.\{11\}//g)
    # The remote name of HEAD branch (e.g. origin)
    remote_name=$(git config branch."${branch}".remote)
    if [ -z "$remote_name" ]; then
    echo 'No remote repository'
    else
    echo -e "## \033[0;32m$remote_name\033[0;39m"
    eval $(cmd_remote_update_info)
    fi
    fi

    # Submodule
    (
    cd "$(git rev-parse --show-toplevel)" >/dev/null 2>&1;
    echo -e "===== \033[0;33mSubmodule Status (git submodule status)\033[0;39m ====="
    sub_state=$(git submodule status)
    if [ -n "$sub_state" ]; then
    echo "$sub_state"

    echo -e "===== \033[0;33mSubmodule Update Info\033[0;39m ====="
    cmd="git remote show origin| tail -1 | sed 's/.*\((.*)\)/\1/' | tr '\n' ' ' && git remote -v | head -1 | tr '\t' ' ' | cut -d' ' -f 2"
    status=$(git submodule foreach "$cmd")
    echo "$status" | sed '/^Entering/d'
    sub_status=$(git submodule status)
    if [ -n "$sub_status" ]; then
    echo "$sub_status"

    echo -e "===== \033[0;33mSubmodule Remote Update Info\033[0;39m ====="
    origin_status=$(git submodule foreach "$(cmd_remote_update_info)")
    echo "$origin_status" | sed '/^Entering/d'
    fi
    )

    5 changes: 4 additions & 1 deletion readme.txt
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,9 @@ $ gits
    ===== Status (git status -sb) =====
    ## master...origin/master [ahead 1]
    M bin/gits
    ===== Remote Update Info =====
    ## origin
    (fast-forwardable) git@github.com:yonchu/dotfiles.git
    ===== Submodule Status (git submodule status) =====
    9150244afd8cb992b90390ea9789054ed376c468 .tmux/tmux-powerline (heads/master)
    1579b53125011063b6b37c3ffde8cc05023e29ad .tmux/tmux-powerline-wrapper (heads/master)
    @@ -13,7 +16,7 @@ $ gits
    dfd4308ae84da481f774b3f5e732ee277d9d8769 .zsh/z (v1.4-2-gdfd4308)
    45194671af8e1d6b37b16e214a58674762ab8e49 .zsh/zsh-syntax-highlighting (0.1.2-2-g4519467)
    2b4704d67920e89e2e809ff8eae058bae7d57c59 .zsh/zsh-vcs-prompt (heads/master)
    ===== Submodule Update Info =====
    ===== Submodule Remote Update Info =====
    (local out of date) https://github.com/erikw/tmux-powerline.git
    (local out of date) https://github.com/yonchu/tmux-powerline-wrapper.git
    (local out of date) git://github.com/Shougo/neobundle.vim.git
  5. yonchu revised this gist Nov 4, 2012. 2 changed files with 38 additions and 28 deletions.
    21 changes: 13 additions & 8 deletions gits.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    #!/bin/bash
    #
    # gitリポジトリの詳細情報を表示
    #

    if ! type git > /dev/null 2>&1; then
    echo 'Error: Git is not installed.' 2>%1
    @@ -10,26 +13,28 @@ if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
    exit 1
    fi

    echo "===== git status -sb ====="
    echo -e "===== \033[0;32mStatus (git status -sb)\033[0;39m ====="
    git status -sb

    (
    cd "$(git rev-parse --show-toplevel)" >/dev/null 2>&1;
    echo "===== git submodule status ====="
    echo -e "===== \033[0;33mSubmodule Status (git submodule status)\033[0;39m ====="
    sub_state=$(git submodule status)
    if [ -n "$sub_state" ]; then
    echo -e '## \033[0;34msubmodule\033[0;39m'
    echo "$sub_state"
    echo "===== git remote show orign (simple) ====="

    echo -e "===== \033[0;33mSubmodule Update Info\033[0;39m ====="
    cmd="git remote show origin| tail -1 | sed 's/.*\((.*)\)/\1/' | tr '\n' ' ' && git remote -v | head -1 | tr '\t' ' ' | cut -d' ' -f 2"
    status=$(git submodule foreach "$cmd")

    echo "$status" | sed '/^Entering/d'
    fi
    )
    echo "===== git remote -v ====="

    echo -e "===== \033[0;34mRemote List (git remote -v)\033[0;39m ====="
    git remote -v
    echo "===== git branch -av ====="

    echo -e "===== \033[0;35mBranch List (git branch -av)\033[0;39m ====="
    git branch -av
    echo "===== git stash list ====="

    echo -e "===== \033[0;36mStash List (git stash list)\033[0;39m ====="
    git stash list
    45 changes: 25 additions & 20 deletions readme.txt
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,36 @@
    # 実行イメージ

    $ gits
    ===== git status -sb =====
    ## master
    ===== git submodule status =====
    ## submodule
    a60663b02cd3b75793a82dd2050d96cd86c22ede .tmux/tmux-powerline (heads/master)
    d6cccfe6eb1c2f1e541955935f95f9e6152f2097 .tmux/tmux-powerline-wrapper (heads/master)
    ===== Status (git status -sb) =====
    ## master...origin/master [ahead 1]
    M bin/gits
    ===== Submodule Status (git submodule status) =====
    9150244afd8cb992b90390ea9789054ed376c468 .tmux/tmux-powerline (heads/master)
    1579b53125011063b6b37c3ffde8cc05023e29ad .tmux/tmux-powerline-wrapper (heads/master)
    3b2a24914b9ff3a51673a1f2223c57a21dbda390 .vim/neobundle.vim (ver.2.0-190-g3b2a249)
    4ac57be0cdcae5aa0f482916ae68e48187856df0 .zsh/dircolors-solarized (heads/master)
    f7c0f031cab5eca993e517200df68e43184ffcbf .zsh/functions/Completion/zsh-completions (0.3.0-89-gf7c0f03)
    dfd4308ae84da481f774b3f5e732ee277d9d8769 .zsh/z (v1.4-2-gdfd4308)
    45194671af8e1d6b37b16e214a58674762ab8e49 .zsh/zsh-syntax-highlighting (0.1.2-2-g4519467)
    1582b6a89008d5298a95f99d8de8f09b75994a1e .zsh/zsh-vcs-prompt (heads/master)
    ===== git remote show orign (simple) =====
    2b4704d67920e89e2e809ff8eae058bae7d57c59 .zsh/zsh-vcs-prompt (heads/master)
    ===== Submodule Update Info =====
    (local out of date) https://github.com/erikw/tmux-powerline.git
    (up to date) https://github.com/yonchu/tmux-powerline-wrapper.git
    (local out of date) https://github.com/yonchu/tmux-powerline-wrapper.git
    (local out of date) git://github.com/Shougo/neobundle.vim.git
    (up to date) git://github.com/seebi/dircolors-solarized.git
    (up to date) https://github.com/zsh-users/zsh-completions.git
    (up to date) git://github.com/rupa/z.git
    (up to date) https://github.com/yonchu/zsh-syntax-highlighting.git
    (local out of date) https://github.com/yonchu/zsh-vcs-prompt.git
    ===== git remote -v =====
    github git@github.com:yonchu/dotfiles.git (fetch)
    github git@github.com:yonchu/dotfiles.git (push)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (fetch)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (push)
    ===== git branch -av =====
    * master 9efa208 Add submodule zsh-vcs-prompt. Delete zsh-git-prompt.
    remotes/github/master 9efa208 Add submodule zsh-vcs-prompt. Delete zsh-git-prompt.
    (up to date) https://github.com/yonchu/zsh-vcs-prompt.git
    ===== Remote List (git remote -v) =====
    github git@github.com:yonchu/dotfiles.git (fetch)
    github git@github.com:yonchu/dotfiles.git (push)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (fetch)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (push)
    ===== Branch List (git branch -av) =====
    * master a49010a [ahead 1] Update .gitconfig, Add .gittemplate
    remotes/github/master 33c9001 Add a screenshot for iTerm on Mac
    remotes/origin/HEAD -> origin/master
    remotes/origin/master 9efa208 Add submodule zsh-vcs-prompt. Delete zsh-git-prompt.
    ===== git stash list =====
    remotes/origin/master 33c9001 Add a screenshot for iTerm on Mac
    ===== Stash List (git stash list) =====
    stash@{0}: WIP on master: a49010a Update .gitconfig, Add .gittemplate
  6. yonchu revised this gist Oct 28, 2012. 2 changed files with 42 additions and 3 deletions.
    14 changes: 11 additions & 3 deletions gits.sh
    Original file line number Diff line number Diff line change
    @@ -15,10 +15,18 @@ git status -sb
    (
    cd "$(git rev-parse --show-toplevel)" >/dev/null 2>&1;
    echo "===== git submodule status ====="
    echo -e '## \033[0;34msubmodule\033[0;39m'
    git submodule status
    sub_state=$(git submodule status)
    if [ -n "$sub_state" ]; then
    echo -e '## \033[0;34msubmodule\033[0;39m'
    echo "$sub_state"
    echo "===== git remote show orign (simple) ====="

    cmd="git remote show origin| tail -1 | sed 's/.*\((.*)\)/\1/' | tr '\n' ' ' && git remote -v | head -1 | tr '\t' ' ' | cut -d' ' -f 2"
    status=$(git submodule foreach "$cmd")

    echo "$status" | sed '/^Entering/d'
    fi
    )
    echo
    echo "===== git remote -v ====="
    git remote -v
    echo "===== git branch -av ====="
    31 changes: 31 additions & 0 deletions readme.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # 実行イメージ

    $ gits
    ===== git status -sb =====
    ## master
    ===== git submodule status =====
    ## submodule
    a60663b02cd3b75793a82dd2050d96cd86c22ede .tmux/tmux-powerline (heads/master)
    d6cccfe6eb1c2f1e541955935f95f9e6152f2097 .tmux/tmux-powerline-wrapper (heads/master)
    f7c0f031cab5eca993e517200df68e43184ffcbf .zsh/functions/Completion/zsh-completions (0.3.0-89-gf7c0f03)
    dfd4308ae84da481f774b3f5e732ee277d9d8769 .zsh/z (v1.4-2-gdfd4308)
    45194671af8e1d6b37b16e214a58674762ab8e49 .zsh/zsh-syntax-highlighting (0.1.2-2-g4519467)
    1582b6a89008d5298a95f99d8de8f09b75994a1e .zsh/zsh-vcs-prompt (heads/master)
    ===== git remote show orign (simple) =====
    (local out of date) https://github.com/erikw/tmux-powerline.git
    (up to date) https://github.com/yonchu/tmux-powerline-wrapper.git
    (up to date) https://github.com/zsh-users/zsh-completions.git
    (up to date) git://github.com/rupa/z.git
    (up to date) https://github.com/yonchu/zsh-syntax-highlighting.git
    (local out of date) https://github.com/yonchu/zsh-vcs-prompt.git
    ===== git remote -v =====
    github git@github.com:yonchu/dotfiles.git (fetch)
    github git@github.com:yonchu/dotfiles.git (push)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (fetch)
    origin /Users/yonchu/Dropbox/Repos/git/dotfiles.git (push)
    ===== git branch -av =====
    * master 9efa208 Add submodule zsh-vcs-prompt. Delete zsh-git-prompt.
    remotes/github/master 9efa208 Add submodule zsh-vcs-prompt. Delete zsh-git-prompt.
    remotes/origin/HEAD -> origin/master
    remotes/origin/master 9efa208 Add submodule zsh-vcs-prompt. Delete zsh-git-prompt.
    ===== git stash list =====
  7. yonchu revised this gist Oct 23, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gits.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/bin/sh
    #!/bin/bash

    if ! type git > /dev/null 2>&1; then
    echo 'Error: Git is not installed.' 2>%1
  8. yonchu revised this gist Oct 23, 2012. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion gits.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,15 @@
    #!/bin/sh

    if ! type git > /dev/null 2>&1; then
    echo 'Error: Git is not installed.' 2>%1
    exit 1
    fi

    if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
    echo 'Error: Not a git repository' 2>&1
    return 1
    exit 1
    fi

    echo "===== git status -sb ====="
    git status -sb
    (
  9. yonchu created this gist Oct 23, 2012.
    19 changes: 19 additions & 0 deletions gits.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
    echo 'Error: Not a git repository' 2>&1
    return 1
    fi
    echo "===== git status -sb ====="
    git status -sb
    (
    cd "$(git rev-parse --show-toplevel)" >/dev/null 2>&1;
    echo "===== git submodule status ====="
    echo -e '## \033[0;34msubmodule\033[0;39m'
    git submodule status
    )
    echo
    echo "===== git remote -v ====="
    git remote -v
    echo "===== git branch -av ====="
    git branch -av
    echo "===== git stash list ====="
    git stash list