Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to read in silent mode in Fish

📅 2016-May-16 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ fish, read, silent ⬩ 📚 Archive

Silent mode is an useful feature in shells to read sensitive information like passwords. The text typed by the user is not displayed on the displayed nor stored anywhere on file.

Sadly, the Fish shell does not have a true silent mode in its read command. Also, when used with default options, the password (or input) entered to the read command is stored in ~/.config/fish/fish_read_history.

The best we can do is to make the read command not store its history. This can be achieved by passing /dev/null as the history file for read:

read -m /dev/null var_to_store_password

Tried with: Fish 2.2.0 and Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧