execute icon indicating copy to clipboard operation
execute copied to clipboard

Alias is not being executed

Open VuiMuich opened this issue 2 years ago • 3 comments

Hi, thanks for this crate, I was trying to use it for the atuin shell history, but it seems aliases from the shell config are not respected. Or am I missing some point in the docs?

VuiMuich avatar Apr 30 '23 17:04 VuiMuich

It seems that alias does not work in a non-interactive shell. According to https://stackoverflow.com/questions/1615877/why-aliases-in-a-non-interactive-bash-shell-do-not-work, you can run shopt -s expand_aliases to enable it.

  1. Create a bash file (assuming your shell is bash)
    #!/bin/bash
    shopt -s expand_aliases
    
    # you can add your alias here
    
  2. Set the BASH_ENV environment variable to the path of the bash file.
  3. Now you can use alias commands in a non-interactive shell.

magiclen avatar May 01 '23 03:05 magiclen

Thanks for the quick answer and good find on that stackexchange article.

Bummer side of this: atuin has support for bash, zsh, fish and nushell at the moment.

Do you think adding alias expansion as a feature (returning some error like "Alias expansion not supported for <SHELL>") would be realistic to who's for? Tbh I haven't had any looks at your code base so far at all, so I have no idea if you already are doing stuff for specific shells.

VuiMuich avatar May 01 '23 05:05 VuiMuich

Assuming you are using bash, you can use bash -i -c "<Your Command> to execute a command in an interactive shell. I'm not planing to provide API for interactive/login shell because Windows has no such thing.

magiclen avatar May 01 '23 06:05 magiclen