Skip to main content

A helper for remembering useful shell commands.

Project description

xxcmd

xx is a Linux shell command. xx remembers other shell commands, so you don't have to.

Installation

pip

Requires Python 3. Installation is simple using pip.

pip install xxcmd

Or pip3 on Ubuntu or Debian based distros.

If typing xx at a command prompt gives you "Command not found", you likely don't have ~/.local/bin on your PATH. Either install globally with sudo pip install xxcmd or add ~/.local/bin to your PATH.

Arch Linux

The xxcmd package in availabe in the AUR.

Basic Usage Examples

Using xx you build up a database of useful commands and search and execute them whenever you like.

Adding Command Examples

Most basic example, adding the top command.

xx -a top

Add the du command to display size of all files and directories in the current directory.

xx -a du --max-depth=1 -h .

Add the same command but with a friendly (searchable) label:

xx -a [File Sizes] du --max-depth=1 -h .

Adding our favourite ssh command:

xx -a [SSH Best Host] ssh -i ~/.ssh/mykey.pem me@myhost.com

Add the last command you executed:

xx -a !!

Add the last command you executed with a descriptive label:

xx -a [My Cool Label] !!

If adding commands containing characters that are interpreted by your shell, such as | or && enclose the command in quotes. You can also use double quotes with bash's last command operator:

xx -a [Command with Pipes] "!!"

Browse and Search Commands Interactively

Run xx with no options to enter the interactive view.

xx

Quick Search and Execute

xx can search for matching commands and if only one match is found it will be immediately executed.

The search looks in labels and commands.

So one way to execute the du command we added above is:

xx sizes

Which finds a match on our label "File Sizes" and runs the associated command.

We could immediately ssh connect with:

xx best

Which would match our label "SSH Best Host".

Interactive View

Invoking xx without options will open the interactive view. This presents a list of all commands with an interactive search.

Keys:

  • Up/Down - navigate the list of commands.
  • Delete - remove the currently selected command
  • Return - execute the currently selected command
  • Escape - exit
  • F1 or CTRL+E - Edit the label of the currently selected item
  • F2 or CTRL+I - Edit the label of the currently selected item
  • F3 or CTRL+G - Add a new command.
  • Any other key press is added to the interactive search to filter the command list.

Further Usage

usage: xx [-h] [-a ...] [-b] [-e] [-i URL] [-c] [-f FILE] [-g] [-l] [-m] [-n]
          [-p PADDING] [-s] [-t] [-v]
          [SEARCH ...]

Remembers other shell commands, so you don't have to.

positional arguments:
  SEARCH                Search for a matching command and run it immediately.

optional arguments:
  -h, --help            show this help message and exit
  -a ..., --add ...     Add the given command to the database. Command may
                        begin with a label enclosed in square brackets [label]
                        <cmd>
  -b, --no-border       Don't display a window border.
  -e, --no-help         Don't display the shortcut key help footer.
  -i URL, --import-url URL
                        Import a command database from the given URL. Merge
                        into existing database.
  -c, --create-config   Create a config file in the users home directory if
                        one doesn't already exist.
  -f FILE, --db-file FILE
                        Use the command database file specified rather than
                        the default.
  -g, --no-global-database
                        Don't load the global system database.
  -l, --list            Print all commands in the database
  -m, --no-commands     Don't show commands in interactive view.
  -n, --no-echo         Don't echo the command to the terminal prior to
                        execution.
  -p PADDING, --label-padding PADDING
                        Add extra padding between labels and commands.
  -s, --search-all      Search both labels and commands. Default is to search
                        only labels first, and only search in commands if
                        searching for labels resulted in no search results.
  -t, --no-labels       Don't display command labels.
  -v, --version         Display program version.

Configuration

In addition to the command line switches a configuration file can be used. The file named .xxcmdrc in the current users home directory is loaded if present.

Some options are only configurable through the config file.

An example file demonstrating all possible options (and the system defaults):

[xxcmd]
echo-commands = yes
show-labels = yes
show-commands = yes
align-commands = yes
draw-window-border = yes
label-padding = 2
bracket-labels = no
bold-labels = yes
whole-line-selection = yes
search-labels-only = no
search-labels-first = yes
shell = default
sort-by-label = yes
sort-by-command = no
sort-case-sensitive = yes
display-help-footer = yes
load-global-database = yes

Command line switches take precedence over configuration file options.

shell can be set to the full path of the shell to be used to execute commands, such as /bin/sh. If set to default the environmental variable SHELL is inspected to use the default OS shell.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xxcmd-0.9.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

xxcmd-0.9.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file xxcmd-0.9.0.tar.gz.

File metadata

  • Download URL: xxcmd-0.9.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for xxcmd-0.9.0.tar.gz
Algorithm Hash digest
SHA256 ece38ed8b09d82228f046919bf03943c41bc41e8f6bdbfdcc021e7c777f585b9
MD5 5ce0d9011f6ba68f6f7099204c00c5fe
BLAKE2b-256 be7efd8ee117d6f85302ec9f3bbf4062fe2f5132fcb7bcbb2efa1258005ade35

See more details on using hashes here.

File details

Details for the file xxcmd-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: xxcmd-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for xxcmd-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f96ac86a805d6c4b6518967ca2eb42e132a1c9a60a6ba07ae56acb69812d12
MD5 8ae0015b14bea5100d209678b7e8ea6e
BLAKE2b-256 65b8887dea984159733c7da1d79248fdd855e38c75e81fef3d658917bdbecf58

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page