Quick Terminal Command
A VS Code extension for quick terminal command input with smart placeholders, command history, and flexible execution options.
日本語版 README | English README
Features
- Quick Terminal Input: Open an input box to quickly type and execute terminal commands
- Smart Placeholders: Use placeholders like
{filename}
, {dirname}
, etc. with automatic path handling
- Command History: Navigate through previous commands with arrow keys
- Auto Directory Change: Automatically cd to the current file's directory (configurable)
- Flexible Command Templates: Support for pattern matching and auto-execution
Default Keybindings
Ctrl+Alt+I
: Open terminal input box
↑
/ ↓
: Navigate command history (when input box is active)
Commands
Quick Terminal: Input to Terminal
- Open input box for terminal command
Quick Terminal: Paste Command to InputBox
- Paste predefined command to active input box
Quick Terminal: Input to Terminal with Pasted Command
- Open input box with predefined command
Quick Terminal: Previous Command in History
- Navigate to previous command
Quick Terminal: Next Command in History
- Navigate to next command
Placeholders
Quick Terminal supports various placeholders that are automatically replaced with actual values:
Basic Placeholders
{filename}
- Current file name with extension (e.g., "my script.py")
{filestem}
- File name without extension (e.g., "script")
{filepath}
- Full path to current file
{fileext}
- File extension (e.g., ".py")
{dirname}
- Directory containing current file
{relativepath}
- File path relative to workspace
{workspace}
- Workspace root path
{workspacename}
- Workspace folder name
Note: Placeholders are only available when working with files within a workspace. Files outside of workspace (such as standalone files or untitled files) do not support placeholder replacement.
Smart Path Handling
Placeholders automatically handle spaces and special characters in paths:
# Single placeholder usage (automatically quoted)
python {filename} # → python "my script.py"
cd {dirname} # → cd "/path/to/project"
# Path concatenation (automatically combines and quotes)
cat {dirname}/config.txt # → cat "/path/to/project/config.txt"
cp {filename} {workspace}/backup/ # → cp "script.py" "/workspace/backup/"
Configuration
quickTerminal.autoChangeDirectory
(string, default: "workspace")
- Controls directory changing behavior before executing commands
- Options:
"none"
: Do not change directory
"file"
: Change to current file's directory
"workspace"
: Change to workspace root directory (default)
Custom Keybindings Examples
Add these to your VS Code keybindings.json for enhanced functionality:
Note: Use the when
condition "quickTerminal.inputBoxActive"
to ensure keybindings only work when the Quick Terminal input box is active. This prevents conflicts with other VS Code functionality.
Basic Command Templates
{
"command": "quick-terminal.pasteCommand",
"key": "ctrl+l",
"when": "quickTerminal.inputBoxActive",
"args": "ls -la {dirname}"
}
Auto-Execute Commands
{
"command": "quick-terminal.pasteCommand",
"key": "ctrl+alt+l",
"when": "quickTerminal.inputBoxActive",
"args": {
"command": "ls -la {dirname}",
"autoExecute": true
}
}
Pattern-Based Commands
{
"command": "quick-terminal.pasteCommand",
"key": "ctrl+t",
"when": "quickTerminal.inputBoxActive",
"args": [
{
"pattern": "test*.py",
"command": "python -m pytest {filename}"
},
{
"pattern": "*.test.ts",
"command": "npm test"
},
{
"pattern": "*.test.js",
"command": "npm test"
},
{
"pattern": "*",
"command": "echo 'No test command for {filename}'"
}
]
}
{
"command": "quick-terminal.inputWithPastedCommand",
"key": "ctrl+alt+shift+r",
"when": "editorTextFocus",
"args": {
"command": [
{
"pattern": "*.py",
"command": "python {filename}"
},
{
"pattern": "*.js",
"command": "node {filename}"
},
{
"pattern": "*.ts",
"command": "npx ts-node {filename}"
}
],
"autoExecute": false
}
}
Use Cases
Development Workflows
# Run current file
python {filename}
node {filename}
npx ts-node {filename}
# Run tests
python -m pytest {filename}
npm test
jest {filename}
# File operations
cat {filename}
cp {filename} {dirname}/backup/
mv {filename} {dirname}/archive/
# Build and deployment
docker build -t myapp {dirname}
rsync -av {dirname}/ user@server:/path/
Configuration Files
# Edit configuration files
code {dirname}/config.json
vim {workspace}/.env
cat {dirname}/requirements.txt
Log and Debugging
# View logs
tail -f {workspace}/logs/app.log
grep -r "ERROR" {dirname}
find {workspace} -name "*.log"
Smart Terminal Selection
Quick Terminal automatically detects when terminals might be busy and creates new ones when needed. It recognizes common development server patterns:
npm run dev
, yarn dev
docker compose up
uvicorn
, fastapi
, django runserver
jupyter lab
, streamlit run
- And many more...
Tips and Tricks
- Command History: Use
↑
and ↓
arrows to navigate through your command history
- Path Concatenation: Use
{dirname}/subfolder/file
for safe path joining
- Auto-Execute: Set
"autoExecute": true
for commands you run frequently
- Pattern Matching: Create different commands for different file types
- Directory Control: Use
quickTerminal.autoChangeDirectory
to control working directory:
"workspace"
(default): Commands run from workspace root
"file"
: Commands run from current file's directory
"none"
: Commands run from current terminal directory
Requirements
- VS Code 1.105.0 or higher
Known Issues
None currently known. Please report issues on GitHub.
Release Notes
0.0.1
- Initial release
- Basic terminal input functionality
- Smart placeholder system with automatic path handling
- Command history navigation
- Auto directory changing (configurable)
- Intelligent terminal selection
- Support for command templates and pattern matching
- Auto-execution capability
Contributing
Found a bug or have a feature request? Please open an issue on GitHub.
License
This extension is licensed under the MIT License.
Enjoy!