0

I am new to bash aliases and I want to create an bash alias that executes emerge with user input and after it successfully ended to start another one. Is it possible or do I need to write a script for that.

As an idea:

Input:

emerge --ask sys-devel/gcc

Alias:

alias emerge='emerge "insert user input here(--ask sys-devel/gcc)" && notify-send "NOTIFY!"'
choroba
  • 216,930
  • 22
  • 195
  • 267
L. Niesen
  • 11
  • 4

2 Answers2

0

As choroba said in his comment: "It's not possible with an alias, use a function instead"

L. Niesen
  • 11
  • 4
-1

How about something like this

$ alias show_args='f(){ echo You entered "$@" in that order; notify-send $@; unset -f f;}; f'
$ show_args foo bar
You entered foo bar in that order

and the notification appears.

[edit] Source https://www.networkworld.com/article/3573074/enhancing-the-linux-command-line-with-aliases.html

v0idptrs
  • 1
  • 2
  • Then why would you use an alias here at all? Perhaps see also https://stackoverflow.com/questions/57239089/why-would-i-create-an-alias-which-creates-a-function – tripleee Jun 01 '22 at 04:55
  • @tripleee Because that is what the OP asked for? – v0idptrs Jun 03 '22 at 02:31