Can I set a default hostname for curl?

0

I would like to reduce the keystrokes when I use curl to test web services on my workstation.

Is there a way to set a default hostname of 'localhost:3000' into ~/.curlrc so the following will work?

curl /foo.json

Mike Bailey

Posted 2011-06-08T05:43:55.810

Reputation: 131

Answers

1

On Unix – shell functions:

cu() { curl "http://localhost:3000/$1"; }

cu foo.json would be translated to curl http://localhost:3000/foo.json.

Downside: needs far more code to support options (curl -I and stuff), but that can be achieved too.

user1686

Posted 2011-06-08T05:43:55.810

Reputation: 283 655