I am trying to setup an alias to automatically search for an anime on 'ani-cli'
Example of using ani-cli normally with no alias/automation
ae@phony:~$ ani-cli
Search Anime: Neon Genesis Evangelion
[1] neon-genesis-evangelion-
[2] neon-genesis-evangelion-dub
[3] evangelion-death-and-rebirth
[4] neon-genesis-evangelion-death-rebirth-dub
[5] neon-genesis-evangelion-the-end-of-evangelion-dub
Enter Number:
I've tried using:
alias ani-nge="echo 'Neon Genesis Evangelion' | ani-cli"
The alias does sucessfully look for the anime, but when prompted to choose which series, it returns an Error saying an invalid number was picked, even when I didn't type anything.
[1] neon-genesis-evangelion-
[2] neon-genesis-evangelion-dub
[3] evangelion-death-and-rebirth
[4] neon-genesis-evangelion-death-rebirth-dub
[5] neon-genesis-evangelion-the-end-of-evangelion-dub
Enter number: Invalid number entered
I'm newer to bash and the terminal, so I'm not the greatest at this. Thank you in advance!
CodePudding user response:
The problem is that you're passing input to ani-cli
via pipe, and when echo
is done, the pipe closes, which closes ani-cli
's standard input stream (stdin for short), which ani-cli
detects as an error. Then there's no way to provide additional input.
Instead, pass the query as an argument (which the docs say you can do):
ani-cli 'Neon Genesis Evangelion'
In the context of the alias:
alias ani-nge="ani-cli 'Neon Genesis Evangelion'"