ossobv / sonic-buildimage

Scripts which perform an installable binary image build for SONiC
Other
0 stars 0 forks source link

config: (minor) Fix bashrc with color prompts and TIME in bash_history #36

Open wdoekes opened 1 week ago

wdoekes commented 1 week ago

Description

Which build are we running (if any)

Upstream issues/PRs

Possible fix

diff --git a/build_debian.sh b/build_debian.sh
index 188396baa..51eb5b83f 100755
--- a/build_debian.sh
+++ b/build_debian.sh
@@ -325,6 +325,11 @@ sudo LANG=C chroot $FILESYSTEM_ROOT useradd -G sudo,docker $USERNAME -c "$DEFAUL
 ## Create password for the default user
 echo "$USERNAME:$PASSWORD" | sudo LANG=C chroot $FILESYSTEM_ROOT chpasswd

+# XXXWJD/FIXME: add frr user at 300?
+# XXXWJD: drop bashrc so we take the default
+sudo rm $FILESYSTEM_ROOT/home/$USERNAME/.bashrc
+sudo rm $FILESYSTEM_ROOT/root/.bashrc
+
 ## Create redis group
 sudo LANG=C chroot $FILESYSTEM_ROOT groupadd -f redis
 sudo LANG=C chroot $FILESYSTEM_ROOT usermod -aG redis $USERNAME
diff --git a/files/image_config/bash/bash.bashrc b/files/image_config/bash/bash.bashrc
index 96f54776f..b3d90a27d 100644
--- a/files/image_config/bash/bash.bashrc
+++ b/files/image_config/bash/bash.bashrc
@@ -6,6 +6,18 @@
 # If not running interactively, don't do anything
 [ -z "$PS1" ] && return

+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+HISTTIMEFORMAT='%F %T '
+
 # check the window size after each command and, if necessary,
 # update the values of LINES and COLUMNS.
 shopt -s checkwinsize
@@ -17,6 +29,8 @@ fi

 # set a fancy prompt (non-color, overwrite the one in /etc/profile)
 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+# XXXWJD: we like some color so separate the outut between the commands
+PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:$?:\[\033[01;34m\]\w\[\033[00m\]\$ '

 # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
 # If this is an xterm set the title to user@host:dir