Skip to content

abduznik/obsidian-shell-termux

Repository files navigation

Obsidian Termux Bridge

A plugin that connects Obsidian to Termux via a local HTTP bridge, bypassing Android Intent restrictions. It allows you to run shell commands on your Android device directly from Obsidian.

Features

  • Reliable: Uses standard TCP/IP networking (localhost) for robust communication.
  • Silent: Runs in the background without opening Termux windows.
  • Bi-directional: Sends commands and retrieves output immediately.
  • Secure: Uses a generated security token to prevent unauthorized access.
  • Convenient: Includes automated scripts for easy setup and removal.

Roadmap

  • Implement local HTTP bridge
  • Add security token authentication
  • Support for live terminal
  • Add live editor for files (nano, vim)
  • Customizable command templates (e.g., "git commit -m '...'")
  • Visual indicator in status bar for server connection status
  • Run code from snippets (at least .sh ones)

Setup Guide

1. Easy Installation (Recommended)

Open Termux and run the following command to automatically set up the environment, download the server, and generate a security token. You can also copy this command directly from the Obsidian plugin settings.

curl -sL https://raw.githubusercontent.com/abduznik/obsidian-shell-termux/main/scripts/install.sh | bash

What this script does:

  1. Installs Python and OpenSSL if not present.
  2. Downloads the obsidian_server.py bridge script.
  3. Generates a secure authentication token.
  4. Configures ~/.bashrc to auto-start the server when you open Termux.

After the script finishes: It will display a Security Token. Copy this token; you will need to paste it into the Obsidian plugin settings.

2. Configure Obsidian Plugin

  1. Open Obsidian Settings > Termux Bridge.
  2. Server Port: Default is 8085. Ensure this matches the port in the python script if you changed it.
  3. Security Token: Paste the token generated by the install script (you can find it in ~/.obsidian_termux_token if you lost it).
  4. Click Test Connection to verify everything is working.

Usage in Obsidian

Available Commands

  • Run Termux Command: Opens a modal to enter a shell command. The output will be displayed in a notification.
  • Run Termux Command and Paste Output: Opens a modal to enter a command. The output will be inserted into your current note at the cursor position.

Live Terminal

Open the "Termux Terminal" view from the ribbon or command palette.

  • Interactive Shell: Type commands and get results.
  • Restart Server: Click the refresh icon to restart the server process if it behaves unexpectedly.
  • Safety Checks:
    • Interactive commands (nano, vim, top, etc.) are blocked to prevent freezing.
    • pkg install commands require the -y flag (e.g., pkg install git -y).

Examples

  • ls -la: List files in your Termux home directory.
  • git status: Check the status of a git repository (if you are in the correct directory).
  • python --version: Check the installed Python version.

Uninstallation

To remove the server script and stop the background process, run the following command in Termux (also available in plugin settings):

curl -sL https://raw.githubusercontent.com/abduznik/obsidian-shell-termux/main/scripts/uninstall.sh | bash

Troubleshooting

  • Connection Failed: Ensure Termux is running in the background. If you force-stopped Termux, open it again to restart the server.
  • Port Conflict: If port 8085 is in use, you can edit ~/bin/obsidian_server.py to change the port, and update the Obsidian plugin settings to match.

About

Integrates Obsidian with Termux to execute shell commands and automate workflows directly from your notes on Android.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors