Reputation: 303
Hi I am having a problem with setting alias in mac after I start the screen
command, I have alias for working with git, like
commit=git commit
they work as I expect when I start my terminal (iTerm2), but then sometimes I use screen
to have simultaneous instances in remotes servers and virtual machines I work with. After this the alias disappear(command not found
).
Does anyone know why or how solve it?
Upvotes: 3
Views: 2015
Reputation: 42715
You need to make sure your aliases are defined in ~/.bashrc
to ensure they get included in all logins. You can test this out: edit your ~/.bashrc
to include this line:
echo "bashrc"
And then edit your ~/.bash_profile
to include this line:
echo "bash_profile"
You'll see when you start screen
that only "bashrc" is displayed.
See this question for much more detail on the subject.
Upvotes: 1
Reputation: 1170
To make the alias work, you must use the alias
command. For example, to create an alias in Bash you do:
$ alias commit="git commit"
This works temporarily ie.: in your current shell. In order to make it "stick", you must put it in your ~/.bashrc
. That will make it be sourced to all instances of Bash you'll invoke during your terminal session.
When you start screen, it starts a separate Bash too, so you'll be covered.
You write something about VMs. If you need this alias to work there, you must make ~/.bashrc
on these VMs to have the same aliases. But that's the other story. You should already know how to achieve what you want.
Upvotes: 4