Package: pbash
Welcome to pbashBash Script Managerpbashhelps managing a set of bash scripts. It keeps the logic of one file per script, but creates aliases and handle parameter prompt and pipe.Main featuresbash script runparameter promptparameter pass through pipeautomatic cli command and option from the scriptgit supportpossibility to handle several distinct storescommands and params autocompletionRoadmapenhanced filtertest on other platformscode cleaningWelcome to pbashInstallationRequirementsInstall from pypiInstall from deb packageUsageInitialiseCreate a new scriptScript templateRun a scriptRun a script (example)List scriptsEdit a scriptFilterAdd a new storeUse a storeInitialise new git repositoryInitialise from existing git repositoryPublish to gitShortcuts and AliasesBuildDependenciesAuthorIssuesLicenseInstallationRequirementsThe application is developped and used on ubuntu 21.10, with python 3.9.7. Any feedback on other platforms is welcomed.python3 >=3.6.2,<4.0git:sudo apt install gitnano:sudo apt install nanoInstall from pypipipinstallpbashFor an isolated environment withpipx:pipxinstallpbashInstall from deb packageA deb package is available, built usingdh-virtualenv. Installing this package will create a new Python virtual environment inopt/venvs. It will then create the symlinkusr/bin/pbashpointing toopt/venvs/pbash/bin/pbash.Note thatdh-virtualenvbuilt packages are dependent of python version. Use this only if you have default python version installed:ubuntu bionic 18.04: Python 3.6ubuntu focal 20.04: Python 3.8ubuntu hirsute 21.04: Python 3.9ubuntu impish 21.10: Python 3.9Download latest.debfile from therelease page.sudodpkg-ipbash_0.1.0_{{os}}_amd64.debUsageInitialiseInitialisation is required before using the application, to create the working diretory.pbashinitA configuration file.pbashrcis created in the user home directory.By default, scripts will be stored in${HOME}/.pbash/folder.The--editoption will open configuration file in edit mode.Create a new scriptYou can create a new script file.pbashnew--name"${NAME}"--desc"${DESCRIPTION}"--param"${PARAM1}"--param"${PARAM2}"If options are not given, they will be prompted at run.For param details, see below.Script templateTo add a description to the script, add a comment line beginning with#DESC.#DESC ...To add a param to the script, add a comment line beginning with#PARAM.#PARAM <name>, <question>, <default>, <always_prompt>Only<name>is required. This value must be strict alphanumeric. The application will automatically create an option--<name>for the cliruncommand.<question>is used for cli prompt and option help message. Default is empty string.<default>is the default value. Default is empty string.<always_prompt>is used to display prompt even when a default value is given. Set totrueif desired. Default isfalse.Run a scriptThe genericruncommand calls the corresponding script.pbashrun<name>Options are automatically created based on script informations.Run a script (example)Let's take the below scriptexample.sh#!/bin/bash#PARAM user, User#PARAM message, Which messageread-p"User: "userread-p"Which message: "messageecho"$usersays$message"The script can be run directly through terminal.It can also be run throughpbash: the params will be promptedpbashrunexampleIt can be run with options :pbashrunexample--user"Sebastien"--message"Hello World!"Or with piped arguments(echo"Sebastien";echo"Hello World!")|pbashrunexample# orcat<(echo"Sebastien")<(echo"Hello World!")|pbashrunexampleNote : for piped arguments, all params must be given so that it worksList scriptspbashlist<filter>Edit a scriptScript edition will open the file in default cli editor.pbashedit<filter>FilterCurrently command filter is only done on the script file name.A future enhancement will provide a better filter functionnality.pbash <command> <anything>will filter displayed scripts based onanythingvalue (name containing this value).Add a new storeYou can create several stores (config sections). Default store path is${HOME}/.pbash-${NAME}/pbash-c"${STORE}"init--new-sectionYou can also select path via the option--path. The folder will be created if it does not exist.pbash-c"${STORE}"init--new-section--path"${PATH}"Use a storeAll functions can be used for a specific store by using the-coption frompbashapplication.pbash-c"${STORE}"new...
pbash-c"${STORE}"list...
pbash-c"${STORE}"run...# etc.Initialise new git repositoryYou can initialise a new git repository in store path. It will set automatic git push for every script creation or modification. The git repository needs to be created on your platform before.A default branchmainis created.pbash-c"${STORE}"init-gitYou can also pass parameter through cli command:pbash-c"${STORE}"init-git--repo"${REPO}"--user"${USER}"--mail"${EMAIL}"--branch"${BRANCH}"Initialise from existing git repositoryIf the git repository already exists, you can restore it in the current store folder by adding the--pulloption toinit-gitcommand.It will download the latest commit frommainbranch. If the branch name is different, you can update it in the config file throughpbash init --editor through--branchoption.Publish to gitWhen a git repository is enabled, all changes to scripts will be pushed to remote. However, there will never be automatic pull to retrieve potential scripts changes from remote (from other application, computer, user, aso.).It can be done manually throughpbash-c"${STORE}git pull"# orpbash-c"${STORE}git sync"# pull then pushIn case a remote change is done but not pulled, the automatic push on script modification will fail. A manualgit syncwill be required to merge local and remote.Shortcuts and AliasesApplication must give a fast access to scripts to be useful.I personnaly defined shortcuts in my home.bashrcfile:aliaspb='pbash -c PRO'aliaspbr='pbash -c PRO run'aliaspbp='pbash -c PERSO'aliaspbpr='pbash -c PERSO run'BuildRequirementsdebhelper:sudo apt install debhelperdh-virtualenvbuildvirtualenvCommandspoetryinstall# build debdpkg-buildpackage-us-uc
dpkg-buildpackage-Tclean# build python packagepython3-mbuildDependenciesPython LibrariesclickrichPython Development LibrariespoetryAuthorSébastien Guerri -github pageIssuesContributions, issues and feature requests are welcome!Feel free to checkissues page. You can also contact me.LicenseCopyright (C) 2022 Sebastien Guerripbash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.pbash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with pbash. If not, seehttps://www.gnu.org/licenses/.