Skip to content

Gambas Shell (gsh) — New User Overview

Gambas Shell GSH edited this page Aug 19, 2025 · 2 revisions

Gambas Shell (gsh) — New User Overview

What is gsh?

Gambas Shell (aka gsh) is a versatile command-line shell that operates similarly to Bash or sh, but it leverages Gambas 3 BASIC syntax along with extensions for pipelines and redirection. It’s designed for both interactive use and scripting, making experimentation and development more seamless and expressive.

Key Features

  • Familiar syntax with added power Use complete Gambas-style code blocks (for-next, if-endif, do…done, etc.) or single-line statements. It integrates shell functionality with structured scripting.

  • Persistent, shared state Maintains an in-memory database of global variables ($var notation) and functions, which can be saved to disk and shared across sessions or processes.

  • Dynamic plugin loading gsh automatically searches and loads plugin modules (subs, classes, structs, scripts) dynamically from designated directories like ~/vars/... and /usr/share/gsh/..., in prioritized order (See file and directory overview).

  • Seamless file and variable redirection You can redirect input/output to both files and global variables or functions, thanks to the persistent in-memory storage.

  • Extensible CLI operations Common shell tasks are simplified with built-in commands:

    • browse: open file manager
    • google: perform a web search in your browser
    • toclipboard (tcb): copy content to clipboard
    • fromclipboard (fcb): retrieve clipboard content or store it to variables or files (lists.gambas-basic.org).

System Requirements & Installation

  • Gambas version Requires Gambas 3.18.4 or newer, including components like gambas3-runtime, gambas3-dev-tools, gambas3-scripter, gambas3-gb.highlight, gambas3-gb-args, among others.

  • Installation methods

    • AppImage (easiest): Download and run gsh.appimage (e.g. version 1.6.2.13 as of June 23, 2024).
    • Package installations: For Debian/Ubuntu and derivatives, add the PPA via curl … KEY.gpg and gsh.list, then install with apt install gsh.
    • The older gshinstall approach is deprecated.

Getting Started Tips

  • Make it your default shell Add /usr/bin/gsh to /etc/shells, then run chsh -s /usr/bin/gsh. Log out and log back in to apply .

  • Profile and startup behavior

    • ~/vars/profile.gsh runs during installation and sets up aliases and environment defaults.
    • ~/.gshrc acts like .bashrc, executed at every startup.
    • ~/vars/subs/onstart and ~/vars/subs/onexit are plugin scripts executing at session start and exit, respectively (e.g. onstart can show a fortune message and set the prompt style) (See Overview of files).
  • Best practices

    • Use clearsubs when upgrading across major versions to avoid residual in-memory functions, and savesubs to back up your subs/scripts.
    • For unexpected behavior, delete ~/vars/gsh.image and /dev/shm/gsh* to reset the shell state.
  • Explore examples Browse example scripts and usage samples via the wiki’s "Getting Started Guide" and "Examples" sections.


Topics Table

Topic Summary
Shell language Gambas 3 BASIC + shell features
State management Persistent variables/functions via in-memory DB
Dynamic modules Auto-load of plugins and scripts
Requirements Gambas 3.18.4+, necessary libs installed
Install options AppImage or PPA; old installer deprecated
Setup Profile templates, aliases, startup plugins
Workflow tips Use clearsubs, savesubs, reset image when needed
Extras Built-ins like browse, google, clipboard commands

Clone this wiki locally