Configuring your shell environment

Hey everyone!

I'd like to start a thread learning about your favourite RHEL bash tweaks. I'm particularly interested in:

  • Aliases
  • Shell environment variables
  • Functions

I'll get started:




alias apsc="ansible-playbook --syntax-check"



Shell environment variables:



export LESS="-X"



This will cause a pager to not clear on exit. For example, when you're reading a man page, the screen will be cleared on exit so if you have a man page which has examples that you'd like to immediately use in your current terminal, exiting the man page will keep your example onscreen.




mkdir -pv $1
cd $1



using mcd foo will create a directory and then change into it.

I have many examples that I can share but I want to hear from you and I will share my full environment configuration that I use. My objective is to take the very best contributions and add them to my git repo for everyone to use. 

Labels (5)
11 Replies
Starfighter Starfighter

Okay, here's my contribution to the original post.  In
keeping with my rant on "Shell" vs "Environment"

When I'm covering variables in the shell environment,
i'm using the env, printenv, export, and set commands
to demonstrate things involving these variables.  

We know that the env, priintenv, and export commands
do not display/list shell variables - ONLY environment
variables.  The set command to the rescue!  Well, the
set command displays everything but the kitchen sink -
shell,variables, environment variables, and functions.

So first, I have them to simply execute the set command
without any options, so that they can see the additional
information that the env and printenv commands do not
display/list.  Of course, the focus is on the Shell variables.

Because the information displayed by the set command
can be a little overwhelming with the inclusion of functions
in the output, I show the students this little concoction, so
that the only information output will be Shell and Environment

$   set  -o  posix

I don't get into the details of what POSIX is all about.  I only
go as far as to explain that the command eliminates the display
of the functions when the set command is executed as shown. 
So now, each time they execute the set command, the only info
that is output is the names and values of Shell and Environment

Of course, there will be that one forward thinking person who
wants to know how to go about reverting back to a state whereby
the function names in the environment can once again be
displayed. I'll then serve up the following command:

$   set  +o  posix

Once that command has been executed, they can see
once again that executing the set command without any
options will display Shell variables, Environments variables,
and functions.  However, I don't stop there.  I take the 
opportunity to expose them to subshells, by letting them
see how that posix feature can be activated temporarily,
to prevent the display of functions when executing the
set command, by showing them this little concoction:

$  (set  -o  posix;  set)

After executing that command, they will see that the 
function names are not displayed, and if the set
command is executed as it was previously, the function
names do indeed appear.  Executing that little construct

                 (set -o posix; set)

did not impact the current shell environment, while
suppresing the display of functions in the output.

What's the BASH tweak in all of this?  As it
relates to Shell and Environment variables:

1)   set -o posix


2)   (set -o posix; set)

I don't impose the details of why the tweak does what it
does, because that would take away from what the intent
of the tweak is to allow them to focus on/  What's being
featured is:  Shell vs Environment variables.  Also, I think
it might be a little bit much for students undertaking an
inaugural Linux course.

Trevor "Red Hat Evangelist" Chandler
0 Kudos
Mission Specialist
Mission Specialist

I think the best enhancement in bash functionality is to install the bash-completion package to get tab autocompletion for many commands.

0 Kudos
Join the discussion
You must log in to join this conversation.