Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Desktop-style, Intuitive, Commandline Editor in Ruby. "Better than nano, simpler than vim."

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
playground
spec
.gitignore
Gemfile
Gemfile.lock
Rakefile
Readme.md
VERSION
ruco.gemspec

Readme.md

Simple, extendable, test-driven commandline editor written in ruby, for Linux/Mac/Windows.

Features:

  • Intuitive interface
  • TextMate Syntax and Theme support
  • selecting via Shift + arrow-keys (only Linux or iTerm) or 'select mode' Ctrl+b + arrow-keys
  • move line up/down (Alt+Ctrl+up/down)
  • Tab -> indent / Shift+Tab -> unindent
  • keeps indentation (+ paste-detection e.g. via Cmd+v)
  • change (*) + writable (!) indicators
  • find / go to line / delete line / search & replace
  • configuration via ~/.ruco.rb
  • cut, copy and paste -> Ctrl+x/c/v
  • undo / redo
  • stays at last position when reopening a file
  • opens file at line with ruco foo/bar.rb:32 syntax
  • keeps whatever newline format you use (\r \n \r\n)
  • surrounds selection with quotes/braces (select abc + " --> "abc")
  • shortens long file names in the middle
  • (optional) remove trailing whitespace on save
  • (optional) blank line before eof on save
  • (optional) line numbers

ruco with railscasts theme
Colors in Ruby 1.8

Install

sudo gem install ruco

Usage

ruco file.rb

Customize

# ~/.ruco.rb
Ruco.configure do
  # set options
  options.window_line_scroll_offset = 5 # default 1
  options.history_entries = 10          # default 100
  options.editor_remove_trailing_whitespace_on_save = true  # default false
  options.editor_blank_line_before_eof_on_save = true       # default false
  options.editor_line_numbers = true                        # default false

  # Use any Textmate theme e.g. from http://wiki.macromates.com/Themes/UserSubmittedThemes
  # use a url that points directly to the theme, e.g. github 'raw' urls
  options.color_theme = "https://raw.github.com/deplorableword/textmate-solarized/master/Solarized%20%28dark%29.tmTheme"
  ...

  # bind a key
  # - you can use Integers and Symbols
  # - use "ruco --debug-keys foo" to see which keys are possible
  # - have a look at lib/ruco/keyboard.rb
  bind(:"Ctrl+e") do
    ask('foo') do |response|
      if response == 'bar'
        editor.insert('baz')
      else
        editor.move(:to, 0,0)
        editor.delete(99999)
        editor.insert('FAIL!')
      end
    end
  end

  # bind an existing action
  puts @actions.keys

  bind :"Ctrl+x", :quit
  bind :"Ctrl+o", :save
  bind :"Ctrl+k", :delete_line
  bind :"Ctrl+e", :move_to_eol
  bind :"Ctrl+a", :move_to_bol

  # create reusable actions
  action(:first_line){ editor.move(:to_column, 0) }
  bind :"Ctrl+u", :first_line
end

TIPS

  • [Mac] arow-keys + Shift/Alt does not work in default terminal (use iTerm)
  • [Tabs] Ruco does not like tabs. Existing tabs are displayed as ' ' and pressing tab inserts 2*space
  • [RVM] alias r="rvm 1.9.2 exec ruco" and you only have to install ruco once
  • [Ruby1.9] Unicode support -> install libncursesw5-dev before installing ruby (does not work for 1.8)
  • [ssh vs clipboard] access your desktops clipboard by installing xauth on the server and then using ssh -X
  • [Alt key] if Alt does not work try your Meta/Win/Cmd key

Colors in Ruby 1.8

# OSX via brew OR port
brew install oniguruma
port install oniguruma5

# Ubuntu
sudo apt-get -y install libonig-dev

gem install oniguruma

TODO

Authors

Contributors

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.