How to configure local terminal .bashrc in MobaXterm?

.bashrc is a shell file placed in the user home directory and sourced while you start an interactive shell in Linux terminals, such as local MobaXterm or in Cygwin. This file can be edited or created to customize bash behavior, for example, define ENV settings, aliases, functions, call scripts, etc.

How to configure local terminal bashrc in MobaXterm?

Let us have a look at how to configure the .bashrc file in your local mobaxterm.

Step #1: Open your local bash terminal

  • Open your MobaXterm
  • From Terminal Menu, “Open New TAB
  • Click Start Local Terminal
  • Your terminal window will open

You would get a window something like below with a banner message,

[20XX-XX-XX 10:24.13]  ~
[admin.codetryout] >

Step #2: Open or create the file .bashrc

Edit .bashrc file, using the command vim .bashrc
You can customize your settings there.

Step #3: Example customization

Let us enter a simple alias,

[admin.codetryout] > vim .bashrc
alias hello="hello codetryout world"

Step #4: Reloading the bashrc changes to the shell

It is required that you have to reload the .bashrc file in order to make the changes available in your current shell. (Note, the changes will be available all the time when you open a new terminal/shell).
To reload .bashrc, use any one of the following methods,

. .bashrc

or

source .bashrc

Step #5: Testing your new bashrc

[admin.codetryout] > hello
hello codetryout world

Another full steps example, adding an alias to MobaXterm local bashrc:

# Adding a new entry to MobaXterm .bashrc
# Alias name: cu1

/home/mobaxterm> echo 'alias cu1="curl https://code.codetryout.com/ --output code.html"' >> .bashrc



# Reloading the bashrc
/home/mobaxterm> . .bashrc


 
# Testing the new alias from mobaxterm bashrc 
/home/mobaxterm> cu1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   311    0   311    0     0   2549      0 --:--:-- --:--:-- --:--:--  2549



# Verifying the output
/home/mobaxterm> cat code.html
<html>
  <head>
    <title>Code.CodeTryout.com</title>
  <body>
    <h1>code.codetryout.com</h1><br />
    This is a demo website for testing sample code experiments and demos at CodeTryout.com.<br />
    Please visit <a href="https://codetryout.com/">CodeTryout.com</a> for more information.
  </body>
</html>
/home/mobaxterm>

Similar way, you may add anything that works on a shell, to your bashrc, such as auto-login to a server using SSH, file copy using SCP, etc. Hope this helps