4

Is there a proper plugin or a class to change font size, font type and decoration within a common output console?

You can change terminal's font by going into preferences but that is not what I'm looking for here. I want to be able to change font dynamically from within code.

Is there anything in Ruby or some terminal commands to do so (I use Mac OS X).

Bhushan Lodha
  • 6,824
  • 7
  • 62
  • 100

4 Answers4

3

The font/font size used in ANSI terminals are implementation specific, and ANSI color/style codes are the only way to provide decoration. Simplest way I've found to add color and style to console output is use the colorize gem.

gem install colorize

Examples:

puts "This is blue".colorize( :blue )
puts "This is light blue".colorize( :light_blue )
puts "This is also blue".colorize( :color => :blue )
puts "This is red on blue and underline".colorize( :red ).on_blue.underline
puts "This is blue text on red".blue.on_red.blink

Here is the colorize README.

Or if you'd like to get fancier and do some UI elements, you can use the rbcurse gem:

gem install rbcurse

Here are some rbcurse screenshots.

azurewraith
  • 378
  • 1
  • 3
  • 13
1

There is no way to dynamically change the font face or font size in standard terminals. They mostly only recognise the standard ANSI/VT escape codes, which only support colors and (some) style.

Michael Slade
  • 13,802
  • 2
  • 39
  • 44
0

I suggest you can use fancy_irb modules, which can decorate your irb console. :)

gem install fancy_irb

TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
0

If you are looking for a solution for the rails default webconsole (displayed inside a browser) I suggest to get a browserextension where you can add additional styling to a page and then just override the following classes:

.console-prompt-label,
.console-prompt-display, 
.console-message {
  font-size: 16px;
  line-height: 16px;
}

If you're using chrome you can use StyleBot. Then you would need to:

  1. Install Stylebot
  2. run rails server and open localhost inside your browser
  3. click on the stylebot extension logo (CSS) and click Open Stylebot...
  4. a sidenav should open, at the bottom left press the button Edit CSS
  5. add the CSS from above and save

that's it, no more small console ouput ever.

enter image description here

dcts
  • 1,479
  • 15
  • 34