I want to setup an alias that would show useful git commands to make it easier to find what I’m looking for, and echoing each to a new line
alias git_help='echo "Delete local branch: git branch -d <branch_name>" \n; echo "Delete remote branch: git push origin --delete <branch_name>" \n'
but each time I run it, while the output does break into a newline, the ‘n’ character is still there:
Delete local branch: git branch -d <branch_name> n
Delete remote branch: git push origin --delete <branch_name> n
Is there a way to do this without printing the ‘n’ character at the end of each line?
>Solution :
echo already adds a newline, so just remove the \n entirely.
[user@host]$ alias git_help='echo "Delete local branch: git branch -d <branch_name>" ; echo "Delete remote branch: git push origin --delete <branch_name>"'
[user@host]$ git_help
Delete local branch: git branch -d <branch_name>
Delete remote branch: git push origin --delete <branch_name>
[user@host]$
Using a function over an alias may make this easier to understand.
git_help() {
echo "Delete local branch: git branch -d <branch_name>"
echo "Delete remote branch: git push origin --delete <branch_name>"
}