Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameters in ZSH Aliases

Tags:

zsh

I'm looking to speed up my workflow a bit by creating a zsh alias for dtach that would function like this:

dtach -A /tmp/{directoryName} -r winch dvtm

I've tried doing this, which does not work.

dtach -A /tmp/$ -r winch dvtm

ZSH newb here, any help would be much appreciated.

Thanks!

like image 783
Jacques Tardie Avatar asked Oct 20 '25 09:10

Jacques Tardie


1 Answers

Aliases are simply replaced by their text. Unless you can reorder the parameters of the command you are aliasing so that all parameters are at the end, aliases are not the way to go.

If you want to use parameters, functions are better suited:

function mydtach () {
    dtach -A "/tmp/$1" -r winch dvtm
}

Call with:

mydtach directoryName
like image 109
Adaephon Avatar answered Oct 22 '25 05:10

Adaephon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!