Comments (8)
Those are all great suggestions. Which OS and Shell are you using? I'll have to test it across a few different platforms to make sure I can roll it into everything.
from gitignore.io.
I use Bash and Linux mostly.
from gitignore.io.
btw any reason you use curl
instead of wget
?
from gitignore.io.
wget
is not installed on OSX by default. That would mean that users would have to brew install wget
to run the command as listed.
In your first comment what does IFS=,
do?
from gitignore.io.
wget is not installed on OSX by default. That would mean that users would have to brew install wget to run the command as listed.
the same goes for curl
in Linux, maybe we could add a check to see which one is installed? something like:
if hash curl; then
curl "${curl_args[@]}" http://gitignore.io/api/"${gi_args[*]}"
elif hash wget; then
wget -O- "${curl_args[@]}" http://gitignore.io/api/"${gi_args[*]}"
else
echo "please install curl or wget to run this command" >&2
exit 1
fi
In your first comment what does IFS=, do?
IFS is a variable bash uses in several situations, in this case I use it so when the "${gi_args[*]}"
array gets expanded bash doesn't separate each term with a space but use a comma instead.
notice that in order to do this I used [*]
and not [@]
also notice the entire function is enclosed in parenthesis and not braces, this creates a subshell when it's run and that prevents the modification of IFS to leak to the user's environment.
there's other ways to prevent that but this works fine.
from gitignore.io.
Thanks for the explanation. I feel like I need an advanced section to the site to explain some of these options. My goal was to keep the installation script as simple as possible, but you're showing that there are definitely a lot of use cases that I did not take into account. When I get a few hours, I'll have to try these out and see what would be simplest to implement
Thanks a lot of your input, it's been very helpful.
from gitignore.io.
If you want a one line version for bash.
function gi { curl http://www.gitignore.io/api/$(IFS=, ; echo "$*"); }
from gitignore.io.
that's a good one, equivalent to the first form proposed (the one without additional arguments for curl/wget)
the command substitution should be quoted tho, otherwise it might break if there's a whitespace literal on any argument, which is unlikely but should be covered I guess
function gi { curl http://www.gitignore.io/api/"$(IFS=, ; echo "$*")"; }
from gitignore.io.
Related Issues (20)
- The process cannot access the file 'D:\Code\Multi-Scene Defense System For Fake News Counter Sample\classfication_attaction\test\.gitignore' because it is being used by another process. HOT 2
- Weird character at the end of the generated ignore with CLI HOT 5
- Website does not function when Ad Block is enabled HOT 19
- Not works on Firefox browser HOT 18
- .gitignore
- Problem HOT 3
- BUG HOT 5
- Critical: Visual basic template makes git ignore all subdirectories. HOT 1
- Cache the api response into a file, to accelerate the completion.
- Add `.gitignore` as suffix to URL (feature request) HOT 3
- fabrikaautocare HOT 1
- Same rules : WebStorm+iml & RubyMine+iml HOT 1
- Never ignore *.meta files for Unity projects HOT 1
- zsh installation instructions wrong HOT 8
- Feature Request: CLI tool that talks with GitHub directly HOT 2
- .NET-related templates should now include .artifacts HOT 3
- Proposal: Sort '!' to the bottom of the gitignore file, so inclusions are more important than exclusions
- CLI, cannot access .gitignore file because it is being used by another process.
- IntelliJ-rule "out/" cause all folders out to be excluded
- echo "function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> \ ~/.bashrc && source ~/.bashrc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gitignore.io.