Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash Aliases and Dotfiles

I recently came across this # -*- sh -*- at the top of a file with aliases in them. It was part of someone's dotfiles inside their bash directory and, until now, I've never seen it before. So, what is this and how is it different than using a shebang? I tried googling alternatives to a shebang, but came up with nothing that gives me a hint as to what the above is. Shebang

like image 595
kyle Avatar asked Sep 05 '25 04:09

kyle


1 Answers

Files with alias definitions do not need shebang lines, because executing them stand-alone would not add the definitions to the current shell, which is the point of alias definitions.

Instead, files with alias definitions must be sourced (run in the context of the current shell, with source or .).

Thus, what you're seeing is just an ordinary comment that indicates what specific shell (sh) the file is designed to be sourced from.

like image 63
mklement0 Avatar answered Sep 07 '25 21:09

mklement0