{"id":32026658,"url":"https://github.com/albertalef/rubyshell","last_synced_at":"2026-01-23T05:38:42.375Z","repository":{"id":317455635,"uuid":"1067533733","full_name":"albertalef/rubyshell","owner":"albertalef","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-20T16:04:57.000Z","size":1171,"stargazers_count":56,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-21T00:18:41.076Z","etag":null,"topics":["automation","hacktoberfest","ruby","script","shell","shell-script"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/rubyshell","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/albertalef.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-01T02:00:39.000Z","updated_at":"2026-01-20T16:04:57.000Z","dependencies_parsed_at":"2025-10-01T02:13:08.352Z","dependency_job_id":null,"html_url":"https://github.com/albertalef/rubyshell","commit_stats":null,"previous_names":["albertalef/rubyshell"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/albertalef/rubyshell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertalef%2Frubyshell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertalef%2Frubyshell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertalef%2Frubyshell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertalef%2Frubyshell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albertalef","download_url":"https://codeload.github.com/albertalef/rubyshell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertalef%2Frubyshell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28681041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T04:33:33.518Z","status":"ssl_error","status_checked_at":"2026-01-23T04:33:30.433Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","hacktoberfest","ruby","script","shell","shell-script"],"created_at":"2025-10-16T14:33:09.586Z","updated_at":"2026-01-23T05:38:42.367Z","avatar_url":"https://github.com/albertalef.png","language":"Ruby","readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg alt=\"RubyShell\" src=\"./docs/images/rubyshelllogo.png\" width=\"60%\"\u003e\n\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003e✨ Rubist way to create shell scripts ✨\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://rubygems.org/gems/rubyshell\"\u003e\n    \u003cimg src=\"https://img.shields.io/gem/v/rubyshell?color=red\u0026logo=ruby\" alt=\"Gem Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://rubygems.org/gems/rubyshell\"\u003e\n    \u003cimg src=\"https://img.shields.io/gem/dt/rubyshell.svg?label=Downloads\u0026colorA=004d99\u0026colorB=0073e6\" alt=\"Gem Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/albertalef/rubyshell/actions/workflows/main.yml\"\u003e\n    \u003cimg src=\"https://github.com/albertalef/rubyshell/actions/workflows/main.yml/badge.svg\" alt=\"Build Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-green.svg\" alt=\"License\"\u003e\n  \u003c/a\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\n    ·\n    \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\n    ·\n    \u003ca href=\"#complete-example\"\u003eExamples\u003c/a\u003e\n    ·\n    \u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\n    ·\n    \u003ca href=\"#sponsors\"\u003eSponsors\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n```ruby\n  cd \"/log\" do\n    ls.each_line do |line|\n      puts cat(line)\n    end\n  end\n```\n\nYes, that’s valid Ruby!\n`ls` and `cat` are just shell commands, but **RubyShell** makes them behave like Ruby methods.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add rubyshell\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install rubyshell\n\n## Usage\n\n### Calling a shell command\nWith RubyShell, every shell command can be used inside the ruby, you just need to call\n\n```ruby\nsh do\n  puts pwd # =\u003e /Users/albertalef/projects/rubyshell\nend\n```\n\n### Using without the block\nIf you want to start an irb or pry session, and run commands as first-class citizens then do the following.\n\n```ruby\nextend RubyShell::Executor\n\npwd # =\u003e /Users/albertalef/projects/rubyshell\n```\n\n### Passing arguments\nHere we have different ways to pass arguments to a command.\nYou can separate strings, use only one, use hashes, anyway will work\n\n```ruby\nsh do\n  docker(\"ps\", all: true) # Using hash syntax = docker ps --all\n\n  docker(\"ps\", a: true) # Using hash syntax = docker ps -a\n\n  docker(\"ps\", '-a') # Passing multiple strings = docker ps -a\n\n  docker(\"ps -a\") # Passing one string = docker ps -a\nend\n```\n\n### Changing folder\nHas two possible ways, changing the folder of the code, or running code only inside a folder \n\n##### Chaging code folder\n```ruby\nsh do\n  puts pwd # =\u003e /Users/albertalef/projects/rubyshell\n\n  cd 'examples'\n\n  puts pwd  # =\u003e /Users/albertalef/projects/rubyshell/examples\nend\n```\n\n##### Executing code inside another folder\n\n```ruby\nsh do\n  cd 'examples' do\n    puts pwd  # =\u003e /Users/albertalef/projects/rubyshell/examples\n  end\n\n  puts pwd  # =\u003e /Users/albertalef/projects/rubyshell\nend\n```\n\n### Chaining commands\nThe `chain` method make possible we use shell operators inside the ruby, like `\u0026 \u0026\u0026 | \u003e \u003e\u003e \u003c \u003c\u003c`\n\n```ruby\nsh do\n  chain { echo \"Dummy text\" \u003e\u003e \"dummy.txt\" }\n  \n  puts cat(\"dummy.txt\") # =\u003e \"Dummy text\"\nend\n\nsh do\n  number_of_files = chain { ls | wc('-l') }.chomp\n\n  puts number_of_files # =\u003e 5\nend\n```\n\n### Executing without a block\nThe `sh` method can receive any method call, and execute shell commands\n\n```ruby\nsh.puts pwd # =\u003e /Users/albertalef/projects/rubyshell\n\nsh.cd 'examples'\n\nputs sh.pwd  # =\u003e /Users/albertalef/projects/rubyshell/examples\n```\n\n## Complete example\n\n```ruby\n#!/usr/bin/env ruby\n\nrequire \"rubyshell\"\nrequire \"securerandom\"\n\nsh do\n  mkdir \"files\"\n\n  cd \"files\" do\n    5.times do |i|\n      chain do\n        echo(SecureRandom.alphanumeric(16)) \u003e\u003e \"#{i}.txt\"\n      end\n    end\n\n    puts \"Number of Files: #{ls.lines.count}\"\n\n    ls.each_line do |filename|\n      puts cat(filename)\n    end\n  end\nensure\n  rm \"-rf files\"\nend\n\n# Running:\n#\n# ❯ ./examples/example1.rb\n#\n# Number of Files: 5\n# o6Kw8KHvWJnLGSeQ\n# qkRKcZHqu2Moq1se\n# nUPluln9GM1ydtoz\n# rkdYsc1RBhkeN1dq\n# ZPXZMqzYfyFfjPHF\n```\n\n## Coming\n\n- Support to Streams\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/albertalef/rubyshell. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/albertalef/rubyshell/blob/master/CODE_OF_CONDUCT.md).\n\n## Sponsors\n\n\u003ca href=\"https://avantsoft.com.br\"\u003e\n  \u003cimg alt=\"Avantsoft\" src=\"./docs/images/LogoAvantsoft.png\" width=\"40%\"\u003e\n\u003c/a\u003e\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Rubysh project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/albertalef/rubyshell/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertalef%2Frubyshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertalef%2Frubyshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertalef%2Frubyshell/lists"}