git branch parsing in console added

This commit is contained in:
winterhalderp 2021-04-19 16:37:01 +02:00
parent b4870213dc
commit 313b3ea8df

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
# Add these lines to .bashrc, do this: # In order to add these lines to .bashrc do this:
# Add the the following in between "#----" to the end of your .bashrc script # Add the following lines in between "#----" to the end of your .bashrc file
# To do this open .bashrc: # To do this open .bashrc:
# sudo nano ~/.bashrc # sudo nano ~/.bashrc
# Move to end of .bashrc (arrow down) # Move to end of .bashrc (arrow down)
# Highlight the lines below and copy (Ctrl+C) # Highlight the lines below and copy (Ctrl+C)
# Paste into console at the end of .bashrc (Right click, paste or CTRL+LShift+V) # Paste into console at the end of .bashrc (Right click: paste or CTRL+LShift+V)
@ -26,7 +26,7 @@ cmd="$HOME/colcon_ws/install/local_setup.bash"
source $cmd source $cmd
echo "ROS Overlay: "$cmd echo "ROS Overlay: "$cmd
# You can add other workspaces # You can add other workspaces as overlays
#cmd="$HOME/colcon_libs/install/local_setup.bash" #cmd="$HOME/colcon_libs/install/local_setup.bash"
#source $cmd #source $cmd
#echo "ROS Overlay: "$cmd #echo "ROS Overlay: "$cmd
@ -72,3 +72,13 @@ echo "If your package is not listed (ros2 pkg list):"
echo " * make sure you are sourcing the correct workspace: .bashrc" echo " * make sure you are sourcing the correct workspace: .bashrc"
echo " * delete build/, install/ and rebuild w/o errors" echo " * delete build/, install/ and rebuild w/o errors"
#---------------------------------------------------------------------------------- #----------------------------------------------------------------------------------
# In order to view the git branch you are currently in, add the following lines to the end of your .bashrc file:
#----------------------------------------------------------------------
# Parsing of git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "
#----------------------------------------------------------------------