Skip to content

How can I add aliases? #214

Answered by zimbatm
tars0x9752 asked this question in Q&A
Aug 20, 2022 · 4 comments · 2 replies
Discussion options

You must be logged in to vote

Because direnv targets many different types of shells and handles reverting the changes when switching projects, it can only handle environment variables. This unfortunately means that things like bash aliases and function definitions are being lost.

Most of the time aliases are being used as a shorthand to a longer program name. In that case, you can use the commands to generate a wrapper script:

pkgs.devshell.mkShell {
  commands = [
    { name = "tf"; category = "ops"; help = "terraform alias"; command = ''${tf}/bin/terraform "$@"''; }
  ];
}

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@martinbaillie
Comment options

@tomdavidson
Comment options

Answer selected by tars0x9752
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants