├── .gitignore ├── bin ├── explain └── explain.sh ├── explain_shell.gemspec └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | -------------------------------------------------------------------------------- /bin/explain: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | explain_script = File.expand_path('../explain.sh', __FILE__) 4 | exec "#{explain_script} #{ARGV.join(' ')}" 5 | -------------------------------------------------------------------------------- /bin/explain.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # base url with first command already injected 4 | # $ explain tar 5 | # => http://explainshel.com/explain/tar?args= 6 | url="http://explainshell.com/explain/$1?args=" 7 | 8 | # removes $1 (tar) from arguments ($@) 9 | shift; 10 | 11 | # iterates over remaining args and adds builds the rest of the url 12 | for i in "$@"; do 13 | url=$url"$i""+" 14 | done 15 | 16 | # opens url in browser 17 | open $url -------------------------------------------------------------------------------- /explain_shell.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | 3 | Gem::Specification.new do |gem| 4 | gem.name = "explain_shell" 5 | gem.version = "1.0.2" 6 | gem.authors = ["Richard Schneeman"] 7 | gem.email = ["richard.schneeman+rubygems@gmail.com"] 8 | gem.description = %q{ Bash interface to http://explainshell.com/ } 9 | gem.summary = %q{ explain your bash commands with ease } 10 | gem.homepage = "https://github.com/schneems/explain_shell" 11 | gem.license = "MIT" 12 | 13 | gem.files = `git ls-files`.split($/) 14 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 15 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 16 | # gem.require_paths = ["lib"] 17 | end 18 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Explain Shell 2 | 3 | An awesometastic way to open http://explainshell.com/ from your command line 4 | 5 | ## Install 6 | 7 | ```sh 8 | $ gem install explain_shell 9 | ``` 10 | 11 | ## Use 12 | 13 | The explain_shell gem gives you an `explain` function in bash. 14 | 15 | ```sh 16 | $ explain tar xzvf archive.tar.gz 17 | ``` 18 | 19 | Will open up http://explainshell.com/explain/tar?args=xzvf+archive.tar.gz in your browser! 20 | 21 | Use it with any unix command! 22 | 23 | ```sh 24 | $ explain find . -type f -print0 25 | $ explain ssh -i keyfile -f -N -L 1234:www.google.com:80 host 26 | $ explain lsof -c python -u user 27 | $ explain mysql -u root -p -h 192.168.1.2 28 | $ explain iptables -A INPUT -i eth0 -s ip-to-block -j DROP 29 | $ explain git log --graph --abbrev-commit --pretty=oneline origin..mybranch 30 | ``` 31 | 32 | It's super annoying that it's a slightly different name ah-la bundle/bundler, but the [explain](http://rubygems.org/gems/explain) gem name was already taken. 33 | 34 | ## Without Rubygems 35 | 36 | If you don't have Rubygems on your system (`$ which gem` returns nothing). You can add a simple script to your startup enviornment instead: 37 | 38 | ```sh 39 | function explain { 40 | # base url with first command already injected 41 | # $ explain tar 42 | # => http://explainshel.com/explain/tar?args= 43 | url="http://explainshell.com/explain/$1?args=" 44 | 45 | # removes $1 (tar) from arguments ($@) 46 | shift; 47 | 48 | # iterates over remaining args and adds builds the rest of the url 49 | for i in "$@"; do 50 | url=$url"$i""+" 51 | done 52 | 53 | # opens url in browser 54 | open $url 55 | } 56 | ``` 57 | 58 | ## License 59 | 60 | MIT 61 | 62 | --------------------------------------------------------------------------------