Quantcast
Channel: Bash alias that calls a script versus defining the script as a function - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2

Bash alias that calls a script versus defining the script as a function

$
0
0

I have 150+ shortcuts defined in my .bash_aliases file. Some of them are simple commands, for example:

# Opens file with default program
o () { xdg-open "$@" & disown; }

# Folder shortcuts
alias ..='cd .. && ls'

Others are calling a script that I have somewhere else on the machine, such as:

alias i3exit='~/.config/i3/i3exit.sh'

And others are larger scripts defined like the o command above, only with 30-80 lines.

What is the difference between a script defined directly as a bash function, and an alias that calls a script from a different file? Is one preferable over the other, and if so, why?

Intuition tells me that having separate script files would be better but I don't have any arguments for that.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images