enable arrow keys support in nslookup

I use nslookup daily, and I find the fact that I can’t access previous commands or the command history inside nslookup command prompt frustrating to say the least. Looking for a solution, I stumbled across an apple.stackexchange.com question and answer and solved the annoyance.

In Debian, do the following (as root, or with sudo):

apt-get install rlwrap

This will install the rlwrap utility, to enable readline support to apps that don’t support it natively.

Afterwards, run nslookup through rlwrap:

rlwrap nslookup

Now arrow keys, reverse history (Ctrl+r) work nicely, which saves a lot of keystrokes and copy/paste 🙂

apt-cache search ^rlwrap$
rlwrap - readline feature command line wrapper

To avoid wasting keystrokes, you can create an alias in your shell login file. I added the following line to my ~/.bashrc:

alias nslookup='rlwrap nslookup'

Exit the shell and login again or simply do the following to have the change effective in the current shell (applies to bash shell):

source ~/.bashrc

or

. ~/.bashrc

Credit goes to user alan-shutko on apple.stackexchange.com

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.