LoginSignup
3
1

More than 5 years have passed since last update.

ボクのbashはダサい

Last updated at Posted at 2019-03-02

と最近煽られたのでほげぇええええええええと言われないようにbashを少し改造しました。(最低限)
お前らのターミナルはダサい

設定移行で事故りたくないのでzsh移行は今度やる(しばらくやらない)

ディレクトリのフルパスとbranch名を表示

ディレクトリのフルパスとgithubのbranch名を表示するようにします。
.bashrcに追記

function parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

PS1="\[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

スクリーンショット 2019-03-02 18.38.44.png

lsに色をつける

.bash_profileに追記

CLICOLOR=1
LSCOLORS=FxGxcxdxCxegedabagacad

CLICOLORはLSCOLORSを有効にする環境変数(man ls参考)、1で有効
ls時の色を変更します。(ディレクトリとファイルを区別)
LSCOLORS Generatorsでプレビュー見ながら色を作れます。

スクリーンショット 2019-03-02 18.40.45.png

bashコマンドの補完

brewでbash_completionをインストール

$ brew install bash_completion

.bash_sourceに追記

[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion

途中までコマンドを入れた場合にタブで補完されるようになる

よく使うgitコマンド

git_completion入れるよりも
ぶっちゃけaliasで設定したほうが楽
.bashrcに追記

# git
function gc() {
  command git clone $1 --depth 1
}
alias gf='git fetch'
alias gch='git checkout'
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -D'
alias gpl='git pull'
alias grh='git reset --hard'
alias gps='git push -u origin'
alias gpsf='git push -f origin'
alias gco='git commit -am'
alias gcoe='git commit --allow-empty -m'
alias gcl='git clean -dfx'
alias gl='git log'
alias gr='git rebase'
alias gri='git rebase -i'
alias grv='git revert'
alias gm='git merge'
alias gd='git diff'
alias ga='git add *'
alias gs='git stash'
alias gsp='git stash pop'
alias gcp='git cherry-pick'
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1