Is possible to define a bash script to run interactively by default?
Sourcing your .bashrc
is not a good idea. You could create a .bash_alias
file with your alias and then source that file in your script and use shopt
something like:
shopt -s expand_aliases
source ~/.bash_alias
Bash man page states:
Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt (see the descrip‐ tion of shopt under SHELL BUILTIN COMMANDS below).
If you add the -i
option to your hashbang(s) it will specify that the script runs in interactive mode.
#!/bin/bash -i
Alternatively you could call the scripts with that option:
bash -i /path/to/script.sh