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
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.
Basic Usage Examples
Using xx
is pretty simple. You build up a database of useful commands, and search and execute them whenever you like.
Adding Commands
Commands are added to the database with:
xx -a [label] <command>
Add a very simple command top
. Not very useful as the command is already short and easy to remember.
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 Size] du --max-depth=1 -h .
Adding our favourite ssh command:
xx -a [SSH Best Host] ssh -i ~/.ssh/mykey.pem me@myhost.com
Browse and Search Commands Interactively
Run xx
with no options to enter the interactive view.
xx
Fast search and execute
xx
can search for matching commands and if only one match is found it will be immediately executed. To run the command we just added we could search for "du":
xx du
Or to run it by searching for a partial match of the label we added:
xx size
We could immediately ssh connect with:
xx best
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
- Any other key press is added to the interactive search to filter the command list.
Further Usage
usage: xx [-h] [-a ...] [-i URL] [-c] [-f FILE] [-l] [-m] [-n] [-p PADDING]
[-s] [-t] [-b] [-v]
[cmd]
A helper for remembering useful shell commands. Type to interactively search,
use UP and DOWN arrows to select, RETURN to launch the selected command. Use
DELETE to remove the currently selected row. F1 or CTRL+E to edit the label of
the selected item.
positional arguments:
cmd 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>
-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.
-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.
-b, --no-border Don't display a window border.
-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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file xxcmd-0.8.0.tar.gz
.
File metadata
- Download URL: xxcmd-0.8.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b53fd4d5dd14b48698b8764c6fea7d18d0f807cc7ef6a29777112c08c8aa125b |
|
MD5 | 3a324e22ae33d6c9cedddbff43141c26 |
|
BLAKE2b-256 | fd73333ccc20482af3058d9bb052a7c871e6292860adf8b2ae75ccdc4432e5af |
File details
Details for the file xxcmd-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: xxcmd-0.8.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 487ebfeb1daff0dc4bfc5f5d3210d9a0f3d4307a1255c06c2e6b83e42210408c |
|
MD5 | 53b11ea9d7b2212ea9cadc112989d092 |
|
BLAKE2b-256 | 421687544e08ff59ef2cad6f0b31cc898a9eaad9abe0c46b2dc0f011163fed87 |