1

During FreeBSD 11 Release installation I setup for my new user the standard shell "/bin/sh" as default. Is there a way to make history for this shell permanent that I can use history after reboot. Or do I have to switch to another shell like bash?

Additionally does sh support ctrl+R to search through history?

  • FreeBSD sh is not the Bourne shell, it is based on the Almquist shell, has been (mostly) POSIXified and has a few extensions. – Stéphane Chazelas Jul 4 '17 at 13:44
  • use vipw to change user shell – user996142 Jul 4 '17 at 13:47
  • @StéphaneChazelas, thx for clarifying, so this topic is not related to my question anyhow? – Hölderlin Jul 4 '17 at 13:47
  • @user996142 you mentioned I should use bash or something else? – Hölderlin Jul 4 '17 at 13:49
  • 2
    sh there uses the editline library. See man editrc for configuration. – Stéphane Chazelas Jul 4 '17 at 13:50
3

It is not whether sh supports searching through history and persistent history. It is whether the editing library that it uses does. The editing library is libedit. Indeed it does support searching through history. It does not support persistent history.

There is no key mapped to the next/previous search history actions by default. But you can map one.

bind ^R ed-search-prev-history

This mapping usually goes in $HOME/.editrc. You can make it general or specific to sh.

Tip: You type the pattern to search for before pressing the ed-search-prev-history key in libedit. Not after.

Further reading

  • Luke Mewburn (2014). editrc. §5. FreeBSD Manual.
  • Luke Mewburn (2014). editline. §3. FreeBSD Manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.