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
link|improve this question
feedback

2 Answers

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.

link|improve this answer
feedback
export h=http://example.com
curl $h/foo.json

Put the export statement in your ~.profile

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.