wada811 / blog

wada811's blog
https://github.com/wada811/blog/issues
Apache License 2.0
6 stars 0 forks source link

git git 問題を解決するエイリアス #40

Open wada811 opened 5 years ago

wada811 commented 5 years ago

Why

コマンドラインで git を使っていると git git と打ち込んでいてエラーになる。 エラーにならずに実行したい。

What

  1. 位置パラメータをチェックして git が続いていれば shift する。
  2. バックスラッシュで本来の git コマンドに全引数 $@ を渡して実行する。

How

function drop_git(){
  if (( $# > 0 )); then
    while [[ "$1" == "git" ]]
    do
      shift 1
    done

    \git "$@"
  else
    \git
  fi
}

alias git="drop_git"

Ref