the function
Tired of losing stray thoughts? Tired of task-switching to record an idea? Well jot
is your one-liner lifeline for adding timestamped entries to a running Markdown log with a quick terminal command.
# jot – Append a timestamped message to a Markdown file in your Obsidian vault
jot() {
local vault note timestamp message input
# Detect platform and set vault path
if [[ "$(uname)" == "Darwin" ]]; then
# macOS: standard Documents folder
vault="$HOME/Documents/obsidian_vault"
elif grep -qi microsoft /proc/version 2>/dev/null; then
# WSL: write to the Windows user's Documents or Obsidian vault path
vault="/mnt/c/Users/<YourWindowsUsername>/Documents/Obsidian Vault"
else
# Regular Linux
vault="$HOME/obsidian_vault"
fi
note="$vault/jot.md"
timestamp="$(date '+%Y-%m-%d %H:%M:%S')"
# Edit mode
if [[ "$1" == "--edit" || "$1" == "-e" ]]; then
${EDITOR:-vim} "$note"
return
fi
# Read stdin if piped
if [ ! -t 0 ]; then
input="$(cat -)"
message="$input"
elif [[ -z "$1" ]]; then
echo -n "📝 Enter jot message: "
read -r message
if [[ -z "$message" ]]; then
echo "⚠️ No message entered. Aborting."
return 1
fi
else
message="$*"
fi
# Append to jot.md
{
echo "- [$timestamp]"
echo "$message"
echo ""
} >> "$note"
echo "📝 Jotted to: $note"
}
Usage
jot "Added notes to my zine."
echo "Multiline from a script" | jot
jot --edit
📝 Enter jot message:
If you run jot with no arguments it will prompt the user to type their message. The --edit
option will open in your default editor for longer or more complex notes, like code blocks or multi-line entries. It will also handle piped output from other programs.
You will need to modify the vault path(s) in the script to point to your Obsidian vault.
In my setup, I jump between different linux machines, my windows machine running Ubuntu under Windows Subsystem for Linux and multiple Mint Linux boxes. The code is currently designed to support that by defining three paths based on detecting the environment and using the right path to my vault automatically. All you should need to do is to modify the path in the vault=path portion of the script.
Some path examples for the vault= line:
- On macOS:
~/Documents/obsidian_vault
- On Linux:
~/obsidian_vault
- On WSL:
/mnt/c/Users/<YourWindowsUsername>/Documents/Obsidian Vault
Why is this cool?
Being able to jot a note from the CLI is absolutely useful. Some existing projects allow you to use Obsidian from the CLI, but they often try to provide a whole interface. Jot is simple. If you think of a great idea while coding, you are just a single command away from capturing it:
-
jot "I had a great idea today. Holographic chess"
-
jot "#listening_to Cashing In by Minor Threat"
-
jot "Never name a server 'skynet'"
I try to review the Jot note in Obsidian from time to time and develop ideas and create proper notes for really solid ideas. It lowers the cost of writing something down in your second brain while you are already focused.
Conclusion
I hope you will find it as useful as I have.
Please let me know if you have any feedback or ideas to improve it. Happy jotting!