5

I have created an alias:

alias shh='sqlplus hfdora/hfdora@hfd1" 

After creating this alias I was able to enter my database only by typing shh.

But after closing my shell, I wasn't able to find the alias next time. Even after typing only alias, shh was not showing in the list.

Is there any file to make an alias permanent so that it will not be erased?

4 Answers 4

7

For ksh:

printf "%s\n" "alias shh='sqlplus hfdora/hfdora@hfd1" >> ~/.kshrc source ~/.kshrc 

For bash:

printf "%s\n" "alias shh='sqlplus hfdora/hfdora@hfd1" >> ~/.bashrc source ~/.bashrc 

For zsh:

printf "%s\n" "alias shh='sqlplus hfdora/hfdora@hfd1" >> ~/.zshrc source ~/.zshrc 

Use source for the instant effect


And as @glennjackman said:

A note to readers: ~/.kshrc is for ksh93. For ksh88, either put your aliases in ~/.profile, or use ~/.kshrc but add this to your ~/.profile:

export ENV=$HOME/.kshrc 
5
  • I am using .kshrc.... so it will be in ~/.kshrc? Commented Jul 14, 2015 at 15:30
  • @Nainita Yes, do that =) Commented Jul 14, 2015 at 15:31
  • What are those printf statements supposed to do? They're not updating the *rc file Commented Jul 14, 2015 at 15:38
  • @glennjackman sorry, I forgot >> =\ Commented Jul 14, 2015 at 15:39
  • A note to readers: ~/.kshrc is for ksh93. For ksh88, either put your aliases in ~/.profile, or use ~/.kshrc but add this to your ~/.profile: export ENV=$HOME/.kshrc Commented Jul 14, 2015 at 15:42
2

put your alias inside your ~/.bash_aliases file.

If it's not present create one and call it from ~/.bashrc

OR you can directly put it inside your ~/.bashrc

1
  • I am using .kshrc Commented Jul 14, 2015 at 15:30
0

Put it in your .bashrc file. Then it will be an alias in every instance of Bash shell you open.

0

To Add a Temporary Alias:

  1. Goto Terminal (I'm using git bash for windows).
  2. Type $ alias gpuom='git push origin master'
  3. To See a List of All the aliases type $ alias hit Enter.

To Add a Permanent Alias:

  1. Goto Terminal (I'm using git bash for windows).
  2. Type $ vim ~/.bashrc and hit Enter (I'm guessing you are familiar with vim).
  3. Add your new aliases (For reference look at the snippet below).
    #My custom aliases alias gpuom='git push origin master' alias gplom='git pull origin master' 
  4. Save and Exit (Press Esc then type :wq).
  5. To See a List of All the aliases type alias hit Enter.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.