Snippets

Snippets are saved commands that you can run with a single click or tap, while in the terminal, saving you considerable time. On mobile, you can also run snippets on several hosts at once. Before a snippet can be used, it must be added on the Snippets screen.

Snippets are a Premium feature.

Add a Snippet

Desktop
Mobile
  1. Navigate to the Snippets screen.

  2. Click + New at the top.

  3. In the Label field, specify an optional name for the snippet.

  4. In the Script field, add a command(s) that will be executed.

  5. Click Save. The snippet will appear on the Snippets screen.

  1. Navigate to the Snippets screen.

  2. Tap + at the top and choose New Shell Snippet.

  3. In the Name field, specify an optional name for the snippet.

  4. In the Script field, add a command(s) that will be executed.

  5. Tap Save. The snippet will appear on the Snippets screen.

Do not use \n in a snippet as it will not have an effect. It will be treated as two separate characters and not an escape sequence. For specifying several commands in a snippet, add each one of them on a new line.

If it’s Bash that runs on a remote host, you can use && or ; to specify more than one command on a new line.

Run a Snippet

Desktop
Mobile
  1. In the terminal, press Cmd + S (on Mac OS) or Ctrl + S (on Windows / Linux) to open the snippet picker panel.

  2. Choose one of the following:

    1. To run a snippet, click Run next to it.

    2. To insert a snippet, but not run, click Paste next to it.

You can resize the snippets panel by dragging its edge to the left.

  1. In the terminal, tap {} above the keyboard.

  2. If you don’t want run the snippet, but rather insert its contents into the terminal, uncheck Run snippet immediately.

  3. Tap a snippet you would like to execute.

Run on Multiple Hosts

Mobile
  1. Navigate to the Snippets screen.

  2. Tap a snippet.

  3. Choose one of the following:

    1. To run the snippet on hosts that are not currently running:

      1. Select the hosts.

      2. If you’d like to disconnect from the host once the snippet is executed, uncheck Close sessions after running.

      3. Tap Run <snippet name>.

    2. To run the snippet on hosts that are currently running:

      1. Switch to the Terminals tab.

      2. Select the hosts (terminals).

      3. Tap Run <snippet name>.

You can set default options for the Select Targets screen when adding or editing a snippet.

Example Snippets

Snippets are incredibly powerful. There are many commands that you may run on a day-to-day basis that are either cumbersome to type (especially on a mobile device) or require command line switches you may not remember. Instead of constantly searching or referencing a sheet for these things, snippets allow you store this knowledge and save time in your daily server tasks.

To help get you started, we've created a few for you to use:

Find All Files Created or Modified Within 30 Days

find -type f -mtime -30

Find All Files Created or Modified Within 30 Days and Run a Command

find -type f -mtime -30 -exec

The -exec at the end allows you to specify a command. This snippet is intended to be run without pressing enter so that you can type the command to run on those matching files.

Obtain Disk Usage and Free Space Statistics

du -ch

List Listening Ports and Owning Processes

netstat -tolpn

Display Kernel Log

sudo dmesg

List All Running Processes

ps auxw

Search for a Running Process

ps aux | grep

This snippet is meant to be run without pressing enter. After using the snippet, type the name of the program you are searching for (i.e. "apache2"), and the process list will be searched for this name.