Package: pybashrc
pybashrc: Automatically register python functions as bash commandsThis is a very simple utility that will create a~/.pybashrc.pyfile, and the functions it contains will be made accessible as bash (or zsh) commands.By default,pybashrcaliases all functions that do not start with an underscore and were created in~/.pybashrc.py(i.e. they must not be imported). For example, this is the default template file:# Pybashrc file. Create your command-line accessible python functions here.def_hidden_print_function(*args):"""This function will be ignored by pybashrc, and will not be available from thecommand line.However, other functions can still use it."""print(*args)deftest_pybashrc(first_argument:str,second_argument:str="second_argument"):"""Default test function that simply prints its input arguments. This only serves asan example of how to define pybashrc functions.Arguments:- first_argument (str): The first argument.- second_argument (str): The second argument, which has a default value."""_hidden_print_function("This is the pybash default test function.")_hidden_print_function(f"Provided arguments:{first_argument},{second_argument}")When runningpybash, you'll see the available functions:$ pybash
Available functions:
- test_pybashrc(first_argument: str, second_argument: str = 'second_argument')
	Default test function that simply prints its input arguments. This only serves as an example of how to define pybashrc functions.

	Arguments:
		- first_argument (str): The first argument.
		- second_argument (str): The second argument, which has a default value.And you can now executetest_pybashrcdirectly from the command line:$ test_pybashrc arg1 arg2
This is the pybash default test function.
Provided arguments: arg1, arg2InstallationSimply runpip install pybashrc, and then runpybash-configureonce to set up the bash/zsh alias files etc. After that, you're ready to go! Any time you update your.pybashrc.py, your shell functions will also be updated (note that you'll need to restart the shell for a new alias to become available). If you forget which functions are available or what their usage is, simply runpybashto get an overview.Click functionspybashrcalso supportsclick functions:importclick@click.command(help="A click command rather than a default python function."+" It has one argument with several options and a flag that can be toggled.")@click.argument("first_arg",type=click.Choice(["option1","option2","option3"],case_sensitive=False),)@click.option("-f","--flag",is_flag=True,default=False,show_default=True,help="A command-line flag",)defclick_function(first_arg,flag):print(f"Click function first arg:{first_arg}, flag:{flag}")$ pybash
Available functions:
- click_function(first_arg, flag)
    Usage:  [OPTIONS] [option1|option2|option3]

      A click command rather than a default python function. It has one argument
      with several options and a flag that can be toggled.

    Options:
      -f, --flag  A command-line flag  [default: False]
      --help      Show this message and exit.Exporting external functionsYou may want to make a CLI function available that is not part of your.pybashrc.pyfile. For example, let's say you want to makere.subcommand-line accessible. This can be done very easily by simply importing it, and then specifying it in__all__:fromreimportsub__all__=["sub"]Whenever an__all__is specified,pybashrcwill alias those functions regardless of whether they were defined in your.pybashrc.pyor imported from elsewhere. If you now runpybashto see the available commands:$ pybash
Available functions:
- sub(pattern, repl, string, count=0, flags=0)
    Return the string obtained by replacing the leftmost
    non-overlapping occurrences of the pattern in string by the
    replacement repl.  repl can be either a string or a callable;
    if a string, backslash escapes in it are processed.  If it is
    a callable, it's passed the Match object and must return
    a replacement string to be used.So you can now callsub <pattern> <replacement> <string>directly from the command line!$ sub "\s" "_" "some test string"
some_test_stringRunning from a different virtual environmentTo run your pybash scripts from a different virtual environment, simply make sure that that environment haspybashrcinstalled andpybash-configurehas been run from there once. Once that is done,pybashrcwill simply execute your scripts with the currently active virtual environment!