cancel
Showing results for 
Search instead for 
Did you mean: 
ricardodacosta
Moderator
Moderator
  • 6,820 Views

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:

Aliases:

 

 

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.

Functions:

 

 

mcd(){
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)
15 Replies
Tracy_Baker
Starfighter Starfighter
Starfighter
  • 5,162 Views

The -v (verbose) option should, IMHO, be used wherever it exists. Your mkdir command is one example. Others:

mv, cp, rm, chmod, chown, tar, rsync, restorecon, etc...

I like having a little extra "room." I add this to all my .bashrc files - it double spaces my prompts:

PS1='\n[\u@\h \W]\$ '

Program Lead at Arizona's first Red Hat Academy, est. 2005
Estrella Mountain Community College
ricardodacosta
Moderator
Moderator
  • 5,098 Views

I use mkdir -pv without even thinking about it but I like the use of increased verbosity and we should teach this in RH124. Thanks for that tip!

 

Armann
Flight Engineer
Flight Engineer
  • 5,138 Views

I haven't gotten into the habit yet of using aliases but this is what I have so far.
 
#Default Prompt Value
PS1="\[\e[38;5;10m\]\u\[\e[38;5;10m\]@\[\e[38;5;10m\]\h:\[\e[38;5;33m\]\w \[\033[0m\]$ "
 
#History with date, minute, year and timestamp.
export HISTTIMEFORMAT="%d/%m/%y %T "
ricardodacosta
Moderator
Moderator
  • 5,101 Views

I like the prompt colour!

On my Mac I use a slightly different PS1 which I won't dare paste here as it requires a plugin and the value of $PS1 is just ugly as a result.

Screenshot 2022-11-17 at 17.13.49.png

 

Trevor
Starfighter Starfighter
Starfighter
  • 5,071 Views

Hello Ricardo,

At the risk of redirecting your post a little bit, along with potentially
coming across as a purist, I'd like to comment on your item 2:
"shell environment variables".  It could be considered splitting
hairs a tad bit.

I know, you know, that "Shell" variables, and "Environment" 
variables, are two different animals.  I know, at least I think I
know, what you're intending to refer to, but I'm not so sure
that there may not be someone out here in the community
who's beginning their Linux journey, who knows the distinction.

I know part of my purist demeanor is guided by the fact that
I deliver 4 levels of Linux courses, and that very first one is
where I may go overboard a little bit in setting the foundation
for the remaining three (sys admin level) courses.  One of the
subjects that I provide a little extra coverage with is when I begin 
the conversation about the shell - especially when it comes to
variable types and functionalities.

Okay, I might be rambling a little bit here, and I don't mean to.
I know part of my prose is really just trying to justify my putting
the reference to "shell environment varibles" under the
microscope.  

Now that I've gone this far, I'll close with the following:

 - Shell variables are only present in the shell in which
     they are defined.

 - Environment variables are inherited by child shells but
    shell variables are not

 -  Shell variables can be made an environment variable
      by using export command

Okay, that's as far as I'll go with that because I've strayed away
enough from the original post.  It's the purist in me   Again, this
is not intended for the seasoned pros - they know, or should know,
the distinction.  

Alright, now that I've consumed this much bandwidth, I know
I'm indebted to provide a reply based on the original post: 
"favorite RHEL bash tweak".  Coming to a theatre near you
soon!!!

 

Trevor "Red Hat Evangelist" Chandler
ricardodacosta
Moderator
Moderator
  • 5,070 Views

Fair point, I should have used “Shell, and environment variables”.

Thank you

But I’m going to poke you for a contribution
Trevor
Starfighter Starfighter
Starfighter
  • 5,069 Views

Whew!  I'm so relieved that you didn't drop the hammer
on me.  I was sweating that my verbage would possibly
be taken as being critical.   

One contribution coming up!!!

Trevor "Red Hat Evangelist" Chandler
ricardodacosta
Moderator
Moderator
  • 5,057 Views

Nah that’s not the Red Hat way!

I’m replying off my phone, but I added emojis to my first reply to you to avoid my response being misconstrued but it doesn’t seem to have inserted into the post.

Long live emoticons!
Trevor
Starfighter Starfighter
Starfighter
  • 5,055 Views

Long live emoticons!!!

Trevor "Red Hat Evangelist" Chandler
Join the discussion
You must log in to join this conversation.