DEV Community

Cover image for Create a New Note for Your Obsidian Vault from the Terminal
gokayburuc.dev
gokayburuc.dev

Posted on

Create a New Note for Your Obsidian Vault from the Terminal

Open up your .zshrc file (if you are a bash user use .bashrc instead) for your configurations then paste the function given below:

nn() {
# Go to programming directory

# WARN: use your own <vaultpath> here
cd "$HOME/Documents/vaults/programming/00-inbox/" || return

# Get current date
current_date=$(date +"%Y-%m-%d")

# Create filename
filename="${current_date}_$1.md"

# Create the file
touch "$filename"

# FIXME:  add markdown properties from bash such as tags, date, id, classes etc.

# Open the created file with nvim
nvim "$filename"
}

Enter fullscreen mode Exit fullscreen mode

This function will automatically add the current date as a prefix to your filename. Using the touch command, it will create a new Markdown note in your inbox folder, and Neovim will open as the text editor for this file.

Usage

Open your terminal and write nn and filename for your new note. For example :

nn how-to-create-new-note-from-your-terminal
Enter fullscreen mode Exit fullscreen mode

Top comments (0)