Easy bash prompt: http://ezprompt.net/
echo $SHELL
For Global change:
sudo vi /etc/bash.bashrc
For Local change:
~/.bashrc or .bash_profile
echo $SHELLls -al ~/.vi ~/.bashrcvi /etc/bashrcecho -e "\e[31mHello ${USER}!\e[0m"sudo susu ec2-usersource ~/.bashrc
$ vi ~/.bashrc
export PS1="___________________ | \w @ \h (\u) \n| => "
export PS2="| => "
$ source ~/.bash
Example 1:
Example 2:
Example 3: Welcome message
echo 'FROM BASHRC'
Example 2:
export PS1='\u@\h:\w\$ '
export PS1='\u@\h:\[\033[36m\]\W\[\033[0m\] \$ '
Example 3: Welcome message
echo "Welcome ${USER} to Node1!"
Example 1: working!
echo 'Welcome to 𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱𝘀 𝗔𝘂𝘀𝘁𝗿𝗮𝗹𝗮𝘀𝗶𝗮 𝗟𝘁𝗱.' echo ''
export PS1='\[\e[0;2;38;5;44m\]\u\[\e[0;38;5;226m\]@\[\e[0;2;38;5;40m\]\h\[\e[0m\]:\[\e[0;2;38;5;44m\]\w \[\e[0;2;38;5;226m\]$(git branch 2>/dev/null | grep '"'"'^*'"'"' | colrm 1 2)\[\e[0;2;38;5;44m\]$ \[\e[0m\]'
Example 4: for user
Example 5: for Admin
Finally run: source ~/.bashrc
https://www.youtube.com/watch?v=nEUda6E42Lg
To show branch name in "git log" outputs
- git config --global log.decorate auto
To show current branch name in Ubuntu Terminal type below commands to related lines in the ~/.bashrc:
Find “PS1” in .bashrc like:
if [ "$color_prompt" = yes ]; then
PS1= ...
else
PS1= ...
fi
instead of above lines, paste blow lines
# git branch info if present
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
No comments:
Post a Comment