Hear about some of my mad ramblings.


For many developers and system administrators, the zsh (Z Shell) has become a powerful alternative to more traditional Unix shells, like Bash. It offers a wide range of customizations, plugins, and enhancements that make it an attractive choice for many power users. Two features that can significantly improve your command line experience are the ability to share your shell history across several devices and to have smart autosuggestions based on that history.

In this post, we'll explore how to set up these features using zsh-histdb and zsh-autosuggestions plugins.

Step 1: Installing

The first step is to install the zsh-histdb plugin, which replaces the default Zsh command history file with a SQLite database. This database not only makes it possible to retrieve and search your history across devices, but also offers performance improvements when dealing with large history files. To install zsh-histdb, follow the instructions below:

  • Clone the zsh-histdb repository:

  • Add the following line to your ~/.zshrc file:

  • Restart your Zsh shell by typing exec zsh or closing and reopening your terminal.

  • Step 2: Setting up a remote SQLite database

    The next step is to create a remote SQLite database on a server you have access to, which will store your Zsh history. This can be any remote server that you have SSH access to and supports SQLite.

  • SSH into your server and create the SQLite database:

  • Make sure your local machine has access to your SQLite database file. One way to achieve this is by mounting the remote directory containing the database via sshfs. First, install sshfs on your local machine, if not already installed:

  • Create a local mount point and mount the remote directory:

  • Modify your ~/.zshrc file to point the zsh-histdb plugin to your remote SQLite database:

  • Restart your Zsh shell or open a new terminal, and your Zsh history should now be stored on the remote server, available across all devices that share the same database.

  • Step 3: Installing zsh-autosuggestions

    The zsh-autosuggestions plugin will offer smart auto-completion based on your command history. To install it, follow these steps:

  • Clone the zsh-autosuggestions repository:

  • Add the following line to your ~/.zshrc file:

  • Restart your Zsh shell or open a new terminal. You should now see autosuggestions based on your command history as you type.

  • Conclusion

    By combining the power of zsh-histdb and zsh-autosuggestions, you can manage a more robust and efficient shell history that syncs across devices, along with context-aware autosuggestions - significantly improving your command line experience.