GBashLib (GBL) is a bunch of scripts that helps you to write less and do more in the terminals with BASH shell but keeping it super human friendly.
It provides several nice features:
j
- for jumping to saved pathsd
- running bash functions as commands. Basically replacesmake
targets with simple BASH functions.r
- is the same asd
but globally available from any directory and uses $HOME/d.bl.sh file.s
- run ssh to saved destinations.c
- manage multiple serial console connections and configurations.v
- used to save kye=value pairs in yaml file, which then can be used in any other script (bash, ) or application.g
- alias for git command with all auto completestpl
- simple templating on key=values, used for simple scripting / generation of configuration filesuidgen
- a simple CLI tool to generate hashed UIDS of files or text, in order to detect changes.
GBL provides several tools to manage what features should be included in configuration files from Home directory, like:
mng_bashrc
- will manage features/files included in ~/.bashrc- console - provides
c
shortcut to mange serial console commands - find - provides shortcuts to find files and directories:
ff
andfd
shortcuts. - git - provides
g
shortcut (alias with git) with autocomplete - git_prompt - setups the PS1 to include the branch name and the repo status
- jump - provides the
j
shortcut for jump - python - provides shortcuts for python:
bp
(bpython),pytest
,pyclean
- qt_screen_factor - implements the workarround for QT apps to scale on various monitors.
- ssh - provides
s
shortcut - systemd
- terminal
- console - provides
mng_inputrc
- will manage features/files included in ~/.inputrc- up_down_search - setups that reverse and forward search should happen when user presses up/down keys
- useful - setups some useful inputrc settings, like how to show autocomplete suggestions.
mng_gitconfig
- will manage features/files included in ~/.gitconfig- alias - adds some short aliases for commands like
co
for checkout,d
for diff,l
for log, etc. - http_credentials - enables store credentials for http.
- push_pull - configures push to simple and pull to rebase strategy.
- alias - adds some short aliases for commands like
- go to the directory where you want to keep the code
- clone the code
git clone https://github.com/SmartSoftDev/GBashLib.git
- run
$./GBashLib/src/scripts/install.sh
Alternatively you could run which will install GBashLib and all recommended mng _bashrc,_inputrc and _gitconfig
wget -O - https://raw.githubusercontent.com/SmartSoftDev/GBashLib/master/src/scripts/install_all_goodies.sh | bash
Before you can jump to your preferred paths you have to save them with j set
command like this:
$ j set alias1 .
to add alias1 as jump to current directory orj set alias2 /home/myUser/git/
.
then you can jump to any of this locations:
$ j alias1
j
has intelligent autocomplete and selection feature. For ex: you can write an unique string which is part of your alias
and j
will autocomplete but also will select it atomatically.
$ j 1
is equal with$ j alias1
because "1" is unique for our example of 2 aliases ("alias1" and "alias2").
Before you can ssh to your preferred host you have to add it to s
like this:
-
$ s set ALIAS1 user@ip:port
- only IP is mandatory for this command. -
s
command adds an entry in $HOME/.ssh/config file and uses$G_BASH_LIB/tpls/ssh_host.tpl
template for that. -
When you set a new alias the
s
command will copy your keys (using ssh-copy-id command) to that host, that you are not prompted for password anymore. This can be skipped with$ s set --skip-keys ALIAS...
. -
But when the
--template path/to/template.tpl
argument is given then it will be used. This is useful if you have to configure ssh differently for different types of hosts. -
s
supports proxyJump option likes set --ProxyJump proxyHostAlias my_alias root@192.168.1.1
-
s
supports waiting for the Alias to come online when trying to connect to SSH:s --wait my_alias
This is calling different serial console setups. It is very usefull when you have multiple USB to Serial adapters. The best practice is to give them a specifi name based on serial number using udev like this:
$ cat /etc/udev/rules.d/90-serial.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="ttyUSB_rpi"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="ttyUSB_opi"
Then you can configure them as follows:
$ c set ALIAS1 DEV_PATH@BAUDRATE
- when BAUDRATE is missing it defaults to 115200. Thec
command usesscreen
serial console. And you can start the console usingc ALIAS1
.
d
command always looks ford.bl.sh
file inside current directory.- any bash function that starts with
gbl_
will be taken as a command.
- Stores simple key=value pairs in yaml file, in HOME directory, or in current directory.
- Can print the values so that BASH takes them as variables.
- Stores in yaml file so it is easy to read from any program language (there is a python library that supports all v features).
- Key=values pairs can be grouped ("type" specifier in CLI).
- Supports GPG encryption using multiple GPG keys (for keeping secrets, passwords, etc).
- It can generate entire files, or it can generate/replace/delete only a portion of files
- Can generate/replace multiple variables at once.
- Can generate/replace multipe instances of the same template in same file (based on instance ID).
- transaction type generation (multiple CLI calls can be executed to add/del hashes)