[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion for .bashrc

From: Greg Wooledge
Subject: Re: Suggestion for .bashrc
Date: Fri, 31 Dec 2021 10:31:46 -0500

On Thu, Dec 30, 2021 at 08:46:16PM -0800, Kevin O'Gorman wrote:
> So I propose extending  the stanza near the end of .bashrc:
> if [ -f ~/.bash_aliases ]; then
>     . ~/.bash_aliases
> fi

That code was written by your operating system vendor, or by your
system administrator, or by you.  It's not something that comes from
upstream bash.

> by following it with
> for __bash_alias in ~/.bash_aliases.d/* ; do
>     if [ -f $__bash_alias ]; then
>         source $__bash_alias
>     fi
> done

You can edit the file yourself and make it work however you like.  You
have the right idea, but I'd write it like this:

if [[ -d ~/.bash_aliases.d ]]; then
    for f in ~/.bash_aliases.d/*; do
        [[ -f $f ]] && source "$f"

Variable expansions need to be quoted inside [ but not inside [[.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]