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

Re: [OT] Using aliases or functions in bash script



Quoth William Pursell:
> Another solution is to put the function and alias definitions
> before the check for the interactive shell.  I think that
> a better solution is to define PS1 to fool the test as above,
> but I don't think that is a particularly good solution either.
> Probably better would be to move the function/alias
> definitions into a .bash_functions file, source
> that from .bashrc and from any scripts that want
> the functions and aliases.

I think alias definitions should best live in their own file and be sourced from
.${SHELL}rc. This way you can 

a) share aliases among different (POSIX) shells
b) have a modular way of handling aliases (even within scripts)

I've outsourced everything, my .zshrc just ties it together (there's a file for
functions, one for the environment and one for aliases) and sets some stuff that
wouldn't make sense otherwise (like history and stuff).

Aleks

Attachment: signature.asc
Description: Digital signature


Reply to: