Reputation:
I was wondering if is there any way to set up an alias on user's ~/.bash_aliases
thru a Makefile.
Let's say I have a bash script called foo.sh
which prints what you've passed to it. E.g.:
Input
sh foo.sh bar
Output
bar
Now, on my Makefile I want to have a something like:
install:
@echo "alias foo=sh foo.sh $@" << ~/.bash_aliases
So everytime user does make install
it will automatically have the foo
alias available. Then, instead of doing the last input, we would have something like:
Input
foo bar
Output
bar
Does anyone know if it's possible to do such thing?
Thanks in advance.
Upvotes: 0
Views: 1430
Reputation: 31274
are you sure you want to add the same line to the user's ~/.bash_aliases
everytime they run your Makefile?
and what about users who don't use bash but another shell, like zsh
?
and what about other users? if the admin types make install
, they usually expect the "installation" to be available to each and every user of the system, not just themselves.
if you only care about making your script foo.sh
available as foo
, then you probably should install a binary called foo
.
install:
$(INSTALL) foo.sh $(bindir)/foo
btw, Debian policy mandates scripts to be installed without .sh extension. i think this is a hint that one generally shouldn't install with script suffixes.
Upvotes: 1
Reputation: 5675
What about:
install:
@echo "alias foo=foo.sh" >> ~/.bash_aliases
Upvotes: 0