Skip to content
/ pybcli Public

cli like bash function manager, bash auto completion, local and remote bash function execution

Notifications You must be signed in to change notification settings

saeedtx/pybcli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pybcli

Pybcli is a command-line tool for managing and executing Bash functions, it supports neat autocompletion and seamless execution of functions over SSH without the need to manually copy the script to the remote server.

Long gone the days of forgetting where you put that one bash function that you need to run on a remote server.

Key Features

  • cli like with autocompletion
  • Import a bash file (with functions) or directory into a namespace
  • Execute a function from a file within a namespace
  • Execute a function from a file within a namespace over SSH
  • Auto-completion for bash functions and namespaces
  • File management (display, purge, remove)

Installation

To install Pybcli, clone the repository and install the dependencies:

git clone https://github.com/saeedtx/pybcli.git
cd pybcli
# user
pip install .
bcli install-bash-completion
# system
sudo pip install .
sudo bcli install-bash-completion
# Restart your shell
exec bash

Usage

Import a file or directory into a namespace

# Import a single file into the default namespace
bcli import /path/to/your/script.sh

# Import a single file into a custom namespace
bcli import /path/to/your/script.sh custom_namespace

# Import a directory into the default namespace
bcli import /path/to/your/scripts

# Import a directory into a custom namespace
bcli import /path/to/your/scripts custom_namespace

Execute a function from a file in a namespace

# Execute a function locally
bcli exec namespace script_name function_name arg1 arg2

# **Execute a function over SSH**
bcli exec --ssh user@remote_host namespace script_name function_name arg1 arg2

Display configuration information

# Display configuration information with default verbosity
bcli info

# Display configuration information with increased verbosity
bcli info -v
bcli info -vv
bcli info -vvv

Purge non-existing files from metadata

bcli purge

Remove a namespace or a specific file within a namespace

# Remove an entire namespace
bcli remove custom_namespace

# Remove a specific file within a namespace
bcli remove custom_namespace script_name

Install bash completion script

# Install system-wide (requires root)
sudo bcli install-bash-completion

# Install for the current user
bcli install-bash-completion

Examples

Importing and Executing Scripts

  1. Import a script into the default namespace:

    bcli import /home/user/scripts/my_script.sh
  2. Execute a function from the imported script:

    bcli exec default my_script my_function arg1 arg2
  3. Import a directory of scripts into a custom namespace:

    bcli import /home/user/scripts custom_namespace
  4. Execute a function from a script in the custom namespace:

    bcli exec custom_namespace my_script my_function arg1 arg2

Managing Metadata

  1. Display configuration information:

    bcli info
  2. Purge non-existing files from metadata:

    bcli purge
  3. Remove a namespace:

    bcli remove custom_namespace
  4. Remove a specific file within a namespace:

    bcli remove custom_namespace my_script

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

About

cli like bash function manager, bash auto completion, local and remote bash function execution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published