From 313b3ea8df4addcb8ff9f480dd61fcd2bd5c5791 Mon Sep 17 00:00:00 2001 From: winterhalderp Date: Mon, 19 Apr 2021 16:37:01 +0200 Subject: [PATCH] git branch parsing in console added --- non-ros-files/bashrc_overlay.bash | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/non-ros-files/bashrc_overlay.bash b/non-ros-files/bashrc_overlay.bash index d38cca3..b304172 100644 --- a/non-ros-files/bashrc_overlay.bash +++ b/non-ros-files/bashrc_overlay.bash @@ -1,13 +1,13 @@ #!/bin/bash -# Add these lines to .bashrc, do this: -# Add the the following in between "#----" to the end of your .bashrc script +# In order to add these lines to .bashrc do this: +# Add the following lines in between "#----" to the end of your .bashrc file # To do this open .bashrc: # sudo nano ~/.bashrc # Move to end of .bashrc (arrow down) # 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 echo "ROS Overlay: "$cmd -# You can add other workspaces +# You can add other workspaces as overlays #cmd="$HOME/colcon_libs/install/local_setup.bash" #source $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 " * 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\]$ " +#---------------------------------------------------------------------- \ No newline at end of file