3

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?

5

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
| improve this answer | |
  • I am using .kshrc.... so it will be in ~/.kshrc? – pmaipmui Jul 14 '15 at 15:30
  • @Nainita Yes, do that =) – A.B. Jul 14 '15 at 15:31
  • What are those printf statements supposed to do? They're not updating the *rc file – glenn jackman Jul 14 '15 at 15:38
  • @glennjackman sorry, I forgot >> =\ – A.B. Jul 14 '15 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 – glenn jackman Jul 14 '15 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

| improve this answer | |
  • I am using .kshrc – pmaipmui Jul 14 '15 at 15:30
0

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

| improve this answer | |
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.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.