How do I get my arrow keys working in the at> prompt

Whenever I try to use the arrow keys in the at> prompt (after, for example, running at now) it just shows control codes, eg. ^[[D for .

This makes pasting and editing long commands difficult as the only viable option is to edit, copy and paste from a separate document.

So, how do I get arrow keys to work in the at> prompt?

(Googling for anything having to do with the at> prompt or /usr/bin/at is quite difficult…)

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

You could use a program such as rlwrap (readline wrapper) for this:

rlwrap at now

Further reading:

  • hanslub42/rlwrap (github)

    * HOW TO USE IT:
    If 
    
      $ <command> <args>
    
    doesn't let you use arrow keys to edit input, or if you just want
    decent input history and completion, try:
    
      $ rlwrap [-options] <command> <args>
    

Solution 2

Do

at now << EOF
  commands
     ︙
EOF

You’ll be able to do readline-like editing while you’re typing the commands.

Solution 3

Hans Lub’s rlwrap is one such tool for doing this. It employs the GNU Readline library.

It was written in 1999, the same year that Per Bothner wrote rlfe, a similar tool that is now bundled with GNU Readline as an example program. Debian builds the example, tacks on a Debian-only manual page and packages them in the rlfe package.

GNU Readline is not the only line editing library around. But I do not know of any similar wrapper tools that employ editline/libedit.

Of course, if you are using the “here document” idea from another answer, you may well be using another editing library. If your shell is the Z shell you will be editing the “here document” using ZLE, for example.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply