You are not logged in.
Pages: 1
Is it possible to use one alias command and use parameters to perform multiple tasks?
For example:
If I do cddoc then it should cd in ~/Documents.
But if I do cddoc -s (or any parameter) then it should cd in another folder inside ~/Documents such as ~/Documents/anyfolder.
I can't figure out how to create and make the parameters work.
Offline
Why do you wanna use " -" by any means? Simply use "cddocs".
Last edited by dogknowsnx (2022-01-30 08:35:25)
Why do you wanna use " -" by any means? Simply use "cddocs".
Ok I did: cddoc s
But it gave me error: cd: string not in pwd: (folder location)
Location is correct and there is folder located in the location.
Last edited by SudeepSharma100 (2022-01-30 08:42:46)
Offline
Free your mind from "must have empty space in my command"...
Is it possible to use one alias command and use parameters to perform multiple tasks?
For example:If I do cddoc then it should cd in ~/Documents.
But if I do cddoc -s (or any parameter) then it should cd in another folder inside ~/Documents such as ~/Documents/anyfolder.I can't figure out how to create and make the parameters work.
in .zshrc, you can put:
aaa=/root/Documents
.....
then once zsh is reloaded, a simple
cd $aaa is less than a two-paramater alias.
[ best to be sure aaa is not any comand yet...]
better yet, one can then do such tricks as:
cp -iv file.txt $aaa
saving a whole bunch of keystrokes.
Last edited by arch_jsb (2022-01-30 09:04:43)
Offline
Why bloat your .zshrc to make it look like you're using parameters? I don't get it...
EDIT: You can install and source "zsh-autosuggestions" Simply use zsh's built-in completion in order to save keystrokes for any location, not just predefined ones.
Last edited by dogknowsnx (2022-01-30 09:25:46)
Use a function instead of an alias.
Offline
Use a function instead of an alias.
+1
In this very case you could use an ugly hack to cheat zsh:
alias cddoc='HOME=/home/<username>/Documents cd; HOME=/home/<username>/Documents cd'Offline
Pages: 1