This extension that allows you to run custom initial commands in a Bash terminal and dynamic working directory based on file types.
Features
Opens a Bash terminal with a dynamically resolved or user-configured working directory.
Allows users to configure the terminal name.
Customizes the terminal prompt using the PS1 variable.
Provides error messages if no folder is open in VS Code or if the configured path does not exist.
Requirements
This extension requires:
Linux as the operating system.
Visual Studio Code version 1.70.0 or higher.
A Bash shell (/bin/bash) installed and available on the system.
Node.js environment to support the extension development API.
Known Issues
The terminal may fail to open if no folder is opened in the workspace.
The terminal will fail to open if the cwd is configured to a path that does not exist.
The extension does not verify the validity of custom PS1 prompt strings, which might lead to incorrect behavior if improperly formatted.
Release Notes
0.0.1
Initial release of bash-ce with the following features:
Dynamic Working Directory:
Dynamically resolved working directory based on the opened workspace.
Customizable Terminal Name and Prompt:
Allows you to configure a custom terminal name and prompt (PS1).
Error Handling:
Displays warnings for missing or invalid working directories.
0.0.2
v0.0.2 release of bash-ce with the following features:
Improved Fallback for Working Directory:
If the configured cwd (e.g., ${baseCWD}/build) does not exist, the extension now automatically falls back to the workspace folder (${baseCWD}).
Enhanced Feedback:
Added a warning message when the specified folder is missing and an informational message explaining the fallback behavior.
0.0.3
v0.0.3 release of bash-ce with the following features:
Dynamic Working Directory:
Automatically sets the working directory based on the file type of the currently active editor.
Customizable Bash Code:
Write certain for the Bash Terminal run when its opened (default: Code Executor>).
File-Specific Configuration:
Define specific cwd (current working directory) configurations for different file types (e.g., .c, .java, .py).
Custom Initialization Commands:
Specify the initial commands to be executed when the terminal opens.
Configuration
The extension provides several settings that can be customized in your VSCode settings (settings.json or through the GUI).
Available Settings
Setting
Default Value
Description
bashCodeExecutor.cwd
${baseCWD}
Default working directory for the terminal. Use ${baseCWD} for the root of the workspace.
bashCodeExecutor.terminalName
"Code Executor"
Name of the terminal created by this extension.
bashCodeExecutor.bashCode
"PS1='Code Executor>'; clear"
Initial commands executed when the terminal opens.
bashCodeExecutor.fileConfigurations
{ ".c": { "cwd": "${baseCWD}/build" } }
File-specific configurations for setting cwd dynamically.
How to Use
Commands
Command
Description
bash-ce.test
Displays a test message: "Hello World from Bash Code Executor!"
bash-ce.ce
Opens a new terminal with the configured settings.
Steps to Execute
Open a folder/workspace in VSCode.
Open a file in the editor (e.g., a .c file).
Run the command:
Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
Search for Bash Code Executor: Open Terminal and select it.
A Bash terminal will open with:
A custom prompt (PS1).
The working directory set based on the file's extension (if configured).
Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
Split the editor (Cmd+\ on macOS or Ctrl+\ on Windows and Linux)
Toggle preview (Shift+Cmd+V on macOS or Shift+Ctrl+V on Windows and Linux)
Press Ctrl+Space (Windows, Linux, macOS) to see a list of Markdown snippets