Bash shell scripts – what can be changed

In most, if not all, shells, you have a script that launches your shell. Learn how to change it and you will have your own terminal environment. The most obvious use for these settings is to change the appearance and the tooltip displayed when the shell starts. From a more functional point of view, you can set aliases, environment variables and daemons that change your prompt depending on which directory you are in. If you use the command line infrequently and with only a few strange commands, this may not interest you. However, you will lose the power of the command line. With a little scripting skills, you can improve your experience and make many tasks much easier. First of all, you can get faster with some administrative tasks. Graphical choices are common in a very special case: once you know the scripts, you can do exactly what you want.

What are they for?

The startup script is for changing behavior, adding color, customizing the tooltip, and more. One of the big considerations is environment variables. Many applications and, to a large extent, libraries use them to control their behavior. When you install development packages, they install the environment so they can find the correct libraries, compilers, and binaries. A smart shell script can make your prompt dynamic for the directory you are in. Great example of a great git prompt created by Olivier Verdier. when it is active you will see the status of your git repository at the prompt.

Some common aliases to make things easier:

alias PreL='emacs –with-profile prelude &' alias egrep='egrep –color=auto'
alias l="ls -CF" alias la="ls -A" alias ll="ls -alF" alias ls="ls –color=auto"
alias pbcopy='xclip -selection clipboard' alias pbpaste="xclip -selection clipboard -o"

In the list above, you can see that the user likes Emacs. The top alias sets the Prelude to run with the short PreL command. Great if you want to try multiple Emacs distributions. Next, you will make sure egrep will always use color. Ls aliases make it easier to work with files. You can easily create your own by simply writing it on the command line and then trying it out. When you’re happy, just add it to your favorite shell init file.

The system uses environment variables to ensure that applications are using the correct directories and values. Main environment variables:

  • PATH

path is where your shell looks for executables. Inside you will find / bin, / usr / bin and so on, depending on your needs and distribution. When you start developing software, the installation scripts will change this so that you are using the correct binaries and libraries.


This variable indicates which wrapper you are using. This is used by scripts to make sure you have shell script functionality. The most common shell is bash, but if you use bash functions in another shell, the script will fail. If you check this variable, you can stop the script or use POSIX-compliant methods.

  • USER

This is your username.

  • TERM

This is set by the terminal you are using, so the script knows if the color can be used.


It sets the colors for the ls command.

  • LC *

This is important because they determine which language you use. The keyboard you use is set by them. Make a mistake and you may have trouble finding ‘/’ and ”. They move depending on your keyboard settings.

Shell variables control the parameters of the shell itself. They are more direct to the shell rather than the entire system or applications.


Here you can check the options used when starting the shell. This is the second way to make sure your scripts are running smoothly.


Bash version.


The width of your shell in columns.

You can install many of these while using the shell, but nothing is left until you add them to your init scripts.

Where are they?

Each shell has its own files to help you customize the user experience. It all depends on whether you are programming, administering, or just using the command line for day-to-day tasks.

Different shells have different places for their files, but usually at least one file is in / etc and another is in your home directory. When configuring something, be sure to use the user directory settings if you are not sure what your installation requires. The most common default shell on Linux is bash. Many scripts should work in any shell, there is a POSIX standard for this. The standard declares what code you can paste, bash has many other features, the POSIX-compliant shell is sh. This should be available on all distributions.

How do you change and test your changes?

The best way to test your changes is to install them using a script that you manually run and then test. When you’ve done enough iterations, you put the values ​​into your config files.


You can change a lot with the shell to make it look nicer and help you run programs from the command line. To make things better, start with aliases and then move on to more complex scripts. There are many scripts available that can help you with your specific needs. Find them, and if they are missing something, read the scripts and make your changes. Remember to ask for help, compete, and collaborate on scripting.

Related Posts