Documentation

Shell Scripts Manager

Saved Shell Scripts

Quick Start

Access and manage your saved scripts:

  1. Open Script Library from the sidebar
  2. Browse your scripts organized by connection, database, and folder
  3. Double-click a script to load it into MongoDB Shell
  4. Use drag and drop to organize scripts into folders
Script Library showing organized scripts in a tree structure with connections, databases, and folders

Interface Overview

Header Section

The top of the interface shows the total number of scripts and provides quick access to key actions:

  • Script Count - Displays total number of saved scripts matching current filters
  • Sort Toggle - Switch between sorting by name (alphabetical) or date (most recent first)
  • Export Button - Export all scripts to JSON file for backup or sharing
  • Import Button - Import scripts from JSON file
  • Refresh Button - Reload the script list from the server

Filter scripts by typing in the search box. Search looks across:

  • Script name
  • Script description
  • Connection name
  • Database name

Script Tree

Scripts are organized in a hierarchical tree structure:

  • Connections - Top level shows each MongoDB connection (green plug icon)
  • Databases - Each connection contains databases (blue database icon)
  • Folders - Within databases, organize scripts in custom folders (yellow folder icon)
  • Scripts - Individual scripts appear as purple file icons with their name and last modified time

Browsing Scripts

Click on any folder, database, or connection to expand or collapse it:

  • Expand - Click to reveal contents beneath
  • Collapse - Click again to hide contents
  • Chevron Icon - Points right when collapsed, rotates down when expanded
  • Item Count - Shows total number of scripts and subfolders in each container

Sorting Options

Use the sort toggle in the header to control script order:

Sort Mode Description
Name Scripts sorted alphabetically by name
Date Scripts sorted by last modified date, most recent first

Script Information

Each script displays:

  • Script Name - The name you gave when saving
  • Description - Optional description appears next to the name
  • Last Modified - Shows relative time (e.g., "5m ago", "2h ago", "3d ago")
Script tree showing expanded connection with databases and scripts, displaying names, descriptions, and modified times

Running Scripts

Loading into Shell

There are multiple ways to load a script into MongoDB Shell:

  • Double-click - Opens the script in a new MongoDB Shell activity tab
  • Run Button - Hover over a script and click the green play button
  • Context Menu - Right-click and select "Run"

What Happens When Loading

When you run a script:

  • A new MongoDB Shell activity tab opens
  • The script content loads into the code editor
  • Connection and database are automatically set to match the saved script
  • The script is linked to the saved version for easy updates
  • You can execute the script immediately or make changes first
Script being loaded into MongoDB Shell with the script name in the tab title

Organizing with Folders

Creating Folders

Keep your scripts organized by creating custom folders:

  • Hover Over Database or Folder - A folder-plus icon appears on the right
  • Click Folder-Plus Icon - Opens the create folder dialog
  • Right-click Menu - Select "Create Subfolder" from the context menu
  • Enter Folder Name - Type a name and click Create

Folder Rules

  • Folders must be created inside a database or another folder
  • Folders can be nested multiple levels deep
  • Empty folders are preserved even when they contain no scripts
  • Folder names are always sorted alphabetically

Moving Scripts Between Folders

Use drag and drop to reorganize your scripts:

  • Click and Drag - Click on a script and drag it to a database or folder
  • Drop Zone Highlight - Valid drop locations highlight as you drag
  • Multiple Selection - Select multiple scripts and drag them together
  • Same Connection Only - Scripts can only move within the same connection and database

Deleting Folders

Remove folders you no longer need:

  • Right-click on a folder and select "Delete Folder"
  • Confirm the deletion in the dialog
  • All scripts inside the folder are permanently deleted
  • Empty folders are deleted immediately without confirmation
Create folder dialog showing folder name input and parent location

Managing Scripts

Script Actions

Hover over any script to reveal action buttons:

  • Run - Load the script into MongoDB Shell and open it in a new tab. The connection and database are automatically set.
  • Clone - Create a duplicate copy of the script with " (copy)" appended to the name. The clone appears in the same folder.
  • Delete - Permanently remove the script. You'll be asked to confirm before deletion. This action cannot be undone.

Multi-Select Operations

Select multiple scripts for batch operations:

  • Click + Ctrl - Hold Ctrl (or Cmd on Mac) and click scripts to select multiple
  • Shift Click - Click one script, hold Shift, and click another to select all scripts in between
  • Visual Feedback - Selected scripts are highlighted with a blue background
  • Batch Delete - Right-click on any selected script and choose Delete to remove all selected
  • Batch Move - Drag any selected script to move all selected scripts together

Context Menus

Right-click on different elements to access context-specific actions:

Script Context Menu

  • Run - Load the script into MongoDB Shell
  • Clone - Create a duplicate copy
  • Delete - Remove the script (shows count if multiple selected)

Folder Context Menu

  • Create Subfolder - Add a new folder inside this one
  • Expand/Collapse - Toggle visibility of contents
  • Delete Folder - Remove folder and all scripts inside

Database Context Menu

  • Create Subfolder - Add a new folder at the database level
  • Expand/Collapse - Toggle visibility of contents

Import and Export

Exporting Scripts

Create a backup or share your script library:

  • Click the Export button (download icon) in the header
  • All scripts are saved to a JSON file
  • File includes script content, names, descriptions, connections, and databases
  • Filename includes timestamp (e.g., saved_scripts_1704123456789.json)

Importing Scripts

Load scripts from a previously exported file:

  • Click the Import button (upload icon) in the header
  • Select a JSON file from your computer
  • Scripts are imported as new entries (not merged with existing)
  • Success message shows how many scripts were imported
  • If import fails, you'll see an error message with details

Import File Format

The import feature accepts two JSON formats:

  • Full Export Format - Files created by the Export button with version and timestamp metadata
  • Script Array Format - Plain array of script objects for custom integrations
Header toolbar showing Export and Import buttons along with sort and refresh controls

Keyboard Navigation

Navigate the script library efficiently using keyboard shortcuts:

Shortcut Action
Arrow Down Move to next script or folder
Arrow Up Move to previous script or folder
Arrow Right Expand folder or database
Arrow Left Collapse folder or database, or jump to parent
Enter Run selected script or toggle folder expand/collapse
Page Down Jump down 10 items
Page Up Jump up 10 items

Note: Keyboard shortcuts only work when the search box and folder name input are not focused

Pro Tips

  • Organize by purpose - Create folders like "Migrations", "Reports", and "Admin" to organize scripts by purpose rather than just by database.
  • Use descriptive names - Use descriptive names and add descriptions to your scripts so you can quickly identify what each one does months later.
  • Regular backups - Export your script library regularly as a backup. Store exports in version control to track changes over time.
  • Clone before modifying - Clone scripts before making significant changes to preserve working versions while you experiment.
  • Use search - Use the search bar to quickly find scripts across all connections and databases instead of manually expanding folders.
  • Multi-select for moves - Select multiple scripts with Ctrl+Click and drag them all at once when reorganizing your library.
  • Persistent folder state - The tree remembers which folders you had expanded, so you can close and reopen Script Library without losing your place.
  • Smart sorting - Sort by date to quickly find scripts you recently modified, or sort by name to browse alphabetically.
  • MongoDB Shell - Execute saved scripts and save new scripts to the library
  • Query History - View all previously executed commands, then save them to the script library
  • Collection Activity - Build queries visually and save them as shell scripts

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial