User Tools

Site Tools


aix:aix_prompt

Bash prompt

While it's not recommended to change shell for the root user ,except ksh can be changed to ksh93(used for system scripts, commands, crontab…), you can set into root login profile an alternative shell, like bash. First install the bash rpm package.

Then you can create a customized profile into the ~root/.profile from user:

# cat .profile
[ -x /usr/bin/bash ] && exec /usr/bin/bash

also create a .bashrc with a customized promt

# cat .bashrc
# #####################################################################
#
#       Defintion of the colors
#
# #####################################################################

normal="\033[0m"
black="\033[30m"
red="\033[31m"
lred="\033[1;31m"
green="\033[32m"
lgreen="\033[1;32m"
yellow="\033[33m"
blue="\033[34m"
lblue="\033[1;34m"
purple="\033[35m"
cyan="\033[36m"
lcyan="\033[1;36m"
white="\033[37m"

USERCOLOR="$green"
PASSCOLOR="$yellow"
STOPCOLOR="$normal"

# #####################################################################
#
#       Use different PS1 color for managment servers
#
# #####################################################################

case $HOSTNAME in
        nim|nimsrv)
                ROOTCOLOR="$cyan"
        ;;
        *)
                ROOTCOLOR="$red"
        ;;
esac

# #####################################################################
#
#       Use different PS1 color for users than for root
#
# #####################################################################

if [ $UID -eq 0 ]
then
        STARTCOLOR=$ROOTCOLOR
        #BASHPATH="[\t] - [\w]"
        BASHPATH="\w"
else
        STARTCOLOR=$USERCOLOR
        BASHPATH="\w"
fi
unset USERCOLOR ROOTCOLOR

# #####################################################################
#
#       Define PS1
#
# #####################################################################

PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ; }"'history -a; echo -ne "\033]0;${LOGNAME}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
#PS1="\n\[$PASSCOLOR\]$BASHPATH\n\[$STARTCOLOR\][\u@\h] \\$\[$STOPCOLOR\] "
PS1="[$STARTCOLOR\][\u@\h]\[$PASSCOLOR\]$BASHPATH\\$\[$STOPCOLOR\] "

unset PASSCOLOR REMOTECOLOR STARTCOLOR STOPCOLOR

alias ll='ls -lsa'
stty erase ^?

aix/aix_prompt.txt · Last modified: 2021/01/01 21:21 (external edit)