Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ansi-select

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi-select

  • 0.3.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Installation

$ gem install ansi-select

Usage

There are two options:

  • A standalone executable. Lines passed to STDIN will form your options. The result will be printed to STDOUT.
echo some words to choose from | tr ' ' '\n' | ansi-select

cd $(ls -d */ | ansi-select) # Go to a visually selected subdirectory.
git checkout $(git branch | ansi-select) # The same, but with git branches.

rm -r $(ls | ansi-select --multi) # Delete all the selected files.
  • A Ruby library.
require "ansi/selector"

beverage = Ansi::Selector.select(["coffee", "tee"])

puts "Would you like some additions?"
additions = Ansi::Selector.multi_select(["sugar", "cream", "milk"])

print "Here's your #{beverage}. "
print "We've also added #{additions.join(', ')}." if additions.present?

The Ruby interface has an additional benefit of accepting and returning any objects instead of strings. Also, if you'd like a custom formatter for them, you can pass it as a second option (the default one calls #to_s):

Ansi::Selector.select(objects, ->(object) { "❤❤❤#{object}❤❤❤" })

Keyboard

  • Up and down arrows, j/k, or Ctrl+N/P to navigate.
  • Space to toggle in multi select mode.
  • Return to choose.
  • Ctrl+C or q to quit.

FAQs

Package last updated on 25 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc