How to make custom alias in ~.bash_profile work on F10 86_64

Paul W. Frields stickster at gmail.com
Mon Dec 1 14:44:17 UTC 2008


On Mon, Dec 01, 2008 at 08:40:43AM -0430, Patrick O'Callaghan wrote:
> On Mon, 2008-12-01 at 11:27 +0000, Steve wrote:
> > > Unfortunately, exporting aliases is not supported by bash (neither
> > in 
> > > /etc/profile nor ~/.bash_profile) :-(
> > 
> > No ! that's not right ! Of course it is supported. Aliases can be
> > defined anywhere /etc/bashrc, /etc/profile, /etc/profile.d/*,
> > ~/.bashrc, ~/.bash-profile  ie: in any of the rc files.
> 
> These files are 'eval'ed, so their contents are executed in the context
> of the current shell.
> 
> A simple test shows that aliases are not exported:
> 
> [poc at bree:~] alias foo='ls -ld'
> [poc at bree:~] foo
> drwxr-xr-x 236 poc poc 20480 2008-12-01 01:07 .
> [poc at bree:~] bash
> [poc at bree:~] foo
> bash: foo: command not found

If I recall correctly, /etc/profile, /etc/profile.d/*, and
~/.bash_profile are only eval'd in an interactive (login) shell.  You
probably want to place your alias in ~/.bashrc so it will be used in
all shells.

Working manually, could also define foo as a function instead of an
alias, and then export it:

[pfrields at localhost ~]$ foo() { ls -ld; }
[pfrields at localhost ~]$ foo
drwxr-xr-x 193 pfrields pfrields 12288 2008-12-01 09:00 .
[pfrields at localhost ~]$ export -f foo
[pfrields at localhost ~]$ bash
[pfrields at localhost ~]$ foo
drwxr-xr-x 193 pfrields pfrields 12288 2008-12-01 09:00 .
[pfrields at localhost ~]$ exit

-- 
Paul W. Frields                                http://paul.frields.org/
  gpg fingerprint: 3DA6 A0AC 6D58 FEC4 0233  5906 ACDB C937 BD11 3717
  http://redhat.com/   -  -  -  -   http://pfrields.fedorapeople.org/
  irc.freenode.net: stickster @ #fedora-docs, #fedora-devel, #fredlug
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20081201/d512bc83/attachment-0001.sig>


More information about the fedora-list mailing list