dsh overview
The dsh command provides DanteTerm's core command line interface, allowing users to interact with both terminal and graphical elements from the command line. This guide covers the basics of using dsh and its key features.
See the dsh reference for a list of all dsh commands and their arguments.
Overview
At its core, dsh enables seamless interaction between your terminal commands and DanteTerm's graphical blocks. It allows you to:
- Control graphical widgets directly from the command line
- Share data between terminal sessions and GUI components
- Manage your workspace programmatically
- Connect remote and local environments
- Run terminal commands in separate, isolated blocks
Key Concepts
Interacting with Blocks
dsh provides direct interaction with DanteTerm's graphical blocks through the command line. For example:
# Open a file in the editor
dsh edit config.json
# Get the current file path from a preview block
dsh getmeta -b 2 file
Persistent State
dsh can maintain state across terminal sessions through its variable system:
# Store a variable that persists across sessions
dsh setvar API_KEY=abc123
# Store globally
dsh setvar DEPLOY_ENV=prod
# Or store in the current workspace
dsh setvar -b workspace DEPLOY_ENV=staging
# Use stored variables in commands
curl -H "Authorization: $(dsh getvar API_KEY)" https://api.example.com
Accessing Local Files from Remote
When working on remote machines, you can access files on your local computer using the dsh://local/~/ path prefix with dsh file commands. The shorthand /~/ can also be used as an alias for dsh://local/~/:
# Read a local file from a remote machine
dsh file cat dsh://local/~/config/app.json
# Run a local script on the remote machine using shell process substitution
bash <(dsh file cat dsh://local/~/scripts/deploy.sh)
python <(dsh file cat dsh://local/~/scripts/deploy.py)
# Append remote output to a local log file
echo "Remote machine log entry" | dsh file append dsh://local/~/app.log
# Copy a local file to the remote machine
dsh file cp dsh://local/~/data.csv ./remote-data.csv
# Copy remote file back to local machine
dsh file cp ./results.txt dsh://local/~/results.txt
# You can also use the shorthand /~/ instead of dsh://local/~/
dsh file cat /~/config/app.json
Block Management
Every visual element in DanteTerm is a block, and dsh gives you complete control over them (hold Ctrl+Shift to see block numbers):
# Create a new block showing a webpage
dsh web open github.com
# Do a web search in a new block
dsh web open "danteterm terminal"
# Run a command in a new block and auto-close when done
dsh run -x -- npm test
# Get information about the current block
dsh getmeta
Tabs, block placement, and terminal input can be scripted together:
# Make a dedicated tab -- it comes up with one terminal -- and park it first in the tab bar
dsh tab create logs
dsh tab move logs 1
# Split it, giving the new terminal 40% of the pair
dsh createblock term --tab logs --target 1 --position right --size 40
# Start the dev server in the left terminal
dsh sendkeys --tab logs -b 1 --enter "npm run dev"
# Later, grab the last command's output for use elsewhere
dsh termscrollback --tab logs -b 1 --lastcommand
Common Workflows
Here are some common ways to use dsh:
Development Workflow
# Open directory or markdown files
dsh view .
dsh view README.md
# add a -m to open the block in "magnified" mode
dsh view -m README.md
# Start development server in a new block (-m will magnify the block on startup)
dsh run -m -- npm run dev
# Open documentation in a web block
dsh web open http://localhost:3000
Remote Development
# Connect to remote server with optional key
dsh ssh -i ~/.ssh/mykey.pem dev@server
# Edit remote files
dsh edit /etc/nginx/nginx.conf
# Monitor remote logs
dsh run -- tail -f /var/log/app.log
# Share variables between sessions
dsh setvar -b tab SHARED_ENV=staging
Tips & Features
-
Working with Blocks
- Use block numbers (1-9) to target specific blocks within a tab (hold Ctrl+Shift to see block numbers)
- Can get full block ids by right click a block's header and selecting "Copy Block Id" (useful for scripting)
- Use references like "this", "tab", "workspace", or "global" for different scopes
-
Data Storage
- Use
dsh setvar/getvarfor configuration and secrets - Store file data using
dsh file, which can be easily referenced in all terminals (local and remote) - Use appropriate storage scopes (block, tab, workspace, global)
- Use
-
Command Execution
- Use
dsh runto execute commands in new blocks
- Use
Scripting with dsh
dsh commands can be combined in scripts to automate common tasks. Here's an example that sets up a development environment and uses dsh notify to monitor a long-running build:
#!/bin/bash
# Setup development environment
dsh run -- docker-compose up -d
dsh web open localhost:8080
dsh view ./src
dsh run -- npm run test:watch
# Get notified when long-running tasks complete using dsh notify
npm run build && dsh notify "Build complete" || dsh notify "Build failed"
Getting Help
You can get help on available commands by running dsh with no arguments, or get detailed help for a specific command using dsh [command] -h.
For a complete reference of all dsh functionality, see the DSH Command Reference.