3

My colleague gave me a file containing lots of configs such as

alias  ll="ls -l"
alias  lr="ls -lrt"
alias  gv="vim -g"

How can I use(execute) this profile?

Yves
  • 8,474
  • 7
  • 59
  • 114
  • Does this answer your question? [How do I reload .bashrc without logging out and back in?](https://stackoverflow.com/questions/2518127/how-do-i-reload-bashrc-without-logging-out-and-back-in) – Abhishek Kumar Jan 21 '20 at 07:42

5 Answers5

7

You can load the profile using source command:

source <profile-filename>

eg:

source ~/.bash_profile
Nishu Tayal
  • 18,079
  • 8
  • 44
  • 90
1

For your custom aliases, the best place should be at ~/.bash_aliases. You must just be sure the ~/.bashrc file already contains the following lines:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

or in a more concise manner:

[ -f ~/.bash_aliases ] && . ~/.bash_aliases

To load them immediately, source it. Otherwise, aliases will be loaded at every terminal opening. To check, use the alias command without argument.

xapn
  • 11
  • 2
0

You can put it in your local .bashrc (or appropriate shell rc file) file if you want it permanently.

cat fileNameProfile >> ~/.bashrc

And for current session:

source ~/.bashrc

If you want it just now, then:

source fileNameProfile
khrm
  • 4,423
  • 1
  • 17
  • 25
0

For one time use, copy paste commands to your terminal:-

alias  ll="ls -l"
alias  lr="ls -lrt"
alias  gv="vim -g"

For everytime use, add it in .bashrc.

echo 'alias  ll="ls -l"' >>  ~/.bashrc
echo 'alias  lr="ls -lrt"' >> ~/.bashrc
echo 'alias  gv="vim -g"' >> ~/.bashrc

and then source ~/.bashrc

sumitya
  • 2,405
  • 1
  • 15
  • 28
0

To autoload these alias commands, create a .sample_profile file and add the alias on the file. after that add this text in .bashrc file

.bashrc

if [ -f ~/.sample_profile ]; then
    . ~/.sample_profile
fi
Abhishek Kumar
  • 149
  • 2
  • 13