Trimming standard output with tr command
Suppose that you want to display the number of commits your local branch is behind the remote branch. Like this:
git le head --not origin/$(git_current_branch) | wc -l
9
The problem is that the number is preceded with some white space. In order to fix that trim it with wc -d ' '
:
git le head --not origin/$(git_current_branch) | wc -l | tr -d ' '
9
You can even turn the command into alias ghb (git head behind for short).
alias ghb="git le head --not origin/$(git_current_branch) | wc -l | tr -d ' '"
Written by Wojtek Ryrych
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Zsh
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#