Search code examples
bashdotfilesaliases

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


Solution

  • 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.