* Make a function name an alias for another function
@ 2021-09-04 16:21 Eric Smith
2021-09-04 16:24 ` Roman Perepelitsa
0 siblings, 1 reply; 4+ messages in thread
From: Eric Smith @ 2021-09-04 16:21 UTC (permalink / raw)
To: zsh-users
Hey zsh-ers,
I would like to have a function defined in one place.
POST() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
GET() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
DELETE() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
Not three like this.
How can I make like
POST() = GET()
Then I can call GET() and it will run the same function but return of cause an alternate $0
Thanks for any tips.
Best wishes
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Make a function name an alias for another function
2021-09-04 16:21 Make a function name an alias for another function Eric Smith
@ 2021-09-04 16:24 ` Roman Perepelitsa
2021-09-05 5:00 ` Make a function name an alias for another function [SOLVED] Eric Smith
0 siblings, 1 reply; 4+ messages in thread
From: Roman Perepelitsa @ 2021-09-04 16:24 UTC (permalink / raw)
To: Eric Smith; +Cc: Zsh Users
On Sat, Sep 4, 2021 at 6:22 PM Eric Smith <es@fruitcom.com> wrote:
>
> How can I make like
> POST() = GET()
> Then I can call GET() and it will run the same function but return of cause an alternate $0
Like this:
POST GET DELETE() { cur --silent -X "$0" ... }
Roman.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Make a function name an alias for another function [SOLVED]
2021-09-04 16:24 ` Roman Perepelitsa
@ 2021-09-05 5:00 ` Eric Smith
2021-09-05 19:01 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Eric Smith @ 2021-09-05 5:00 UTC (permalink / raw)
To: zsh-users
Masterful!
$ vim .zshrc;source .zshrc
$ POST user/using/9
{
"message": "Active organization changed"
}
$ GET org
{
"id": 9,
"name": "oxxxxxxxxxxxxxxonmail.com",
}
Roman Perepelitsa previously_wrote on Sat-04-Sep 21 6:24PM
> On Sat, Sep 4, 2021 at 6:22 PM Eric Smith <es@fruitcom.com> wrote:
> >
> > How can I make like
> > POST() = GET()
> > Then I can call GET() and it will run the same function but return of cause an alternate $0
>
> Like this:
>
> POST GET DELETE() { cur --silent -X "$0" ... }
>
> Roman.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Make a function name an alias for another function [SOLVED]
2021-09-05 5:00 ` Make a function name an alias for another function [SOLVED] Eric Smith
@ 2021-09-05 19:01 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2021-09-05 19:01 UTC (permalink / raw)
To: Eric Smith; +Cc: Zsh Users
On Sat, Sep 4, 2021 at 10:00 PM Eric Smith <es@trustfood.org> wrote:
>
> Masterful!
>
> $ POST user/using/9
Just a word of caution ... if you have perl LWP::UserAgent installed,
it will also add perl scripts named HEAD GET POST etc. to your path.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-05 19:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-04 16:21 Make a function name an alias for another function Eric Smith
2021-09-04 16:24 ` Roman Perepelitsa
2021-09-05 5:00 ` Make a function name an alias for another function [SOLVED] Eric Smith
2021-09-05 19:01 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).