Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 645609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:31:19+00:00 2026-05-13T21:31:19+00:00

I have these lines in my ~/.inputrc : set editing-mode vi set keymap vi

  • 0

I have these lines in my ~/.inputrc:

set editing-mode vi 
set keymap vi

This allows me to use vi keybindings in every program that uses GNU readlines for text input. Examples: python, irb, sftp, bash, sqlite3, and so on. It makes working with a command line a breeze. Matlab doesn’t use readlines, but vi keybindings would be amazing to have when debugging or working interactively. Is there an existing solution?

I tend to use matlab -nosplash -nodesktop from the command line and that got me thinking: would it be possible to write a wrapper that does use readlines and pass the input to matlab? (If I have to implement this, I’d probably prefer to do so in Ruby.)

Update:

Thanks for the help. This almost works:

# See also: http://bogojoker.com/readline/
require 'readline'

puts 'Starting Matlab...'
io = IO.popen('matlab -nosplash -nodesktop 2>&1', 'w+')

while input_line = Readline.readline('>> ', true)
  io.puts input_line
  puts io.gets
end

But it only reads a single line from Matlab at a time (because I’m using gets). Any ideas on how to get everything until the next time it’s waiting for input? Here’s what’s happening (I’m entering stuff at the >> prompt):

Starting Matlab...
>> 1

>> 2
                            < M A T L A B (R) >
>> 3
                  Copyright 1984-2009 The MathWorks, Inc.
>> 4
                 Version 7.8.0.347 (R2009a) 32-bit (glnx86)
>> 5
                             February 12, 2009
>> 6

>> 7

>> 8
  To get started, type one of these: helpwin, helpdesk, or demo.
>> 9
  For product information, visit www.mathworks.com.
>> 0

>> 1
>> 
>> 2
ans =
>> 3

>> 4
     1
>> 5

>> 6
>> 
>> 7
ans =
>> 8

>> 9
     2
>> 0

>> 1
>> 
>> 2
ans =
>> 3

>> 4
     3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:31:19+00:00Added an answer on May 13, 2026 at 9:31 pm

    Yes, that should be easy enough. It’s just a special case of the general “open a process and bind to its stdin and stdout” problem, and that’s not difficult.

    A bit of Google searching finds that IO.popen() is the right piece of Ruby for that, and there’s a little more detail in the replies here: http://groups.google.com/group/ruby-talk-google/browse_thread/thread/0bbf0a3f1668184c. Hopefully, that’s enough to get you started!

    Update: Looks like you’re almost there with your wrapper. What you need to get finished is recognize when Matlab is asking for input, and only ask the user for input then. I’d suggest trying this pseudocode:

    while input_line = Readline.readline('>> ', true)
      io.puts input_line
      while ((output_line = io.gets) != '>> ')  // Loop until we get a prompt.
        puts io.gets
      end
    end
    

    That’s not quite right, as you need to do the inner loop once before you ask for the first input line, but it should give you the idea. You might need to adjust the prompt text that it’s looking for, too.

    Update 2: Okay, so we also need to account for the fact that there’s no EOL after a prompt and so io.gets will hang. Here’s a revised version that uses the fact that you can give a blank line to a Matlab prompt and it will just give you another prompt without doing anything. I’ve rearranged the loop to make things a little clearer, though this means you now have to add logic to figure out when you’re done.

    while [not done]   // figure this out somehow
      io.puts blank_line                        // This will answer the first
                                                // prompt we get.
      while ((output_line = io.gets) != '>> ')  // Loop until we get a prompt.
        puts io.gets                            // This won't hang, since the
      end                                       // prompt will get the blank
                                                // line we just sent.
    
      input_line = Readline.readline('>> ', true)  // Get something, feed it
      io.puts input_line                           // to the next prompt.
    
      output_line = io.gets   // This will eat the prompt that corresponds to
                              // the line we just fed in.
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running wsgi application on apache mod_wsgi in daemon mode. I have these lines
I have these three lines in bash that work really nicely. I want to
I have these lines in a script which I'd like to show as an
I have this structure: An interface IProjectService and this is implemented by ProjectServiceImpl. Now
I have a text file with these contents balamurugan,rajendran,chendurpandian christopher updateba and i have
I have a problem with Hibernate (3.6.0.-Final) in my Java EE application using MySQL
I am trying to change the status bar color to Black translucent. I have
I'm new to programming in general and references in particular. I want to manipulate
I am new to winforms and facing one problem in my application. I am
eval(_parent.volumetone + target1)._yscale = Math.round(number)/1.5+50; eval(_parent.volumetone + target2)._yscale = Math.round(number)/1.5+50; eval(_parent.volumetone + target3)._yscale =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.