My preferred dev terminal nowadays is WSL2 of Ubuntu. After installing Obsidian CLI on windows, I could not figure out how to run the new cli tool on WSL.
The following instruction does not work in WSL
obsidian help
However, the same works perfectly fine on Powershell or command prompt as the executable path is already added to environment variables path.
Usually windows path is imported into WSL.
echo $PATH
If not enable it in
nano ~/.wslconfig
Add
[interop]
appendWindowsPath=true
then restart wsl.
wsl --shutdown
Once your app is in the Windows PATH, you can run it by:
obsidian.exe
If you try running on WSL (in my case Ubuntu)
obsidian.exe help
the output appears all garbled now.
Reason
Windows executables output \r\n (CRLF) line endings, while Linux terminals expect \n (LF). The extra carriage return (\r) causes the cursor to jump back to the start of the line, producing messy output.
Quick Fix
Pipe the output through tr -d '\r' to strip carriage returns:
obsidian.exe 2>&1 | tr -d '\r'
Permanent Fix: Create a Wrapper Script
Instead of typing the pipe every time, create a wrapper script:
mkdir -p ~/bin
Create ~/bin/obsidian with the following content:
#!/bin/bash
obsidian.exe "$@" 2>&1 | tr -d '\r'
Make it executable and add ~/bin to your PATH:
chmod +x ~/bin/obsidian
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Now just run obsidian instead of obsidian.exe — clean output, every time.


Top comments (0)