An extensible collection of bash configuration utilities designed to synchronize your development environment across multiple devices.
Includes built-in support for secure handling of sensitive information.
A simple git pull
on each device will sync your bash env across devices!
Setup below
cd /path/to/repo
git clone https://github.com/tmasthay/basher.git
cd basher
cd src
./setup.sh
That will setup the proper symbolic links to where you are used to seeing bash config files.
You will find in bash_{env, env_vars, functions, aliases}
some good starter kit functions for monotonous tasks.
Some examples are below.
# "color echo", 0 <= X,Y,Z <= 5
cecho --color rgbX_Y_Z [what_you_would_normally_pass_to_echo]
# monitors GPU memory usage on multiple GPUs -- useful when nvtop not available
mgpu color1 color2 num_iterations sleep_time_between_iterations
# color1 defaults to red
# color2 defaults to green
# num_iterations defaults to 1000
# sleep_time_between_iterations defaults to 5 seconds
Here's a very brief description of what each function does.
cecho
: Prints text with specified colors.see_fonts
: Lists available fonts.set_var
: Sets environment variable.prepend_env_var
andrevert_env_var
: Modifies environment variables.start_ssh
andssh_add_all
: Manages SSH agents.matlab
: Opens MATLAB.pfs
: Prints file content with optional regex filtering.grb
: Deletes Git-related temporary files.kkp
: Kills a process based on port number.vit
: Opens Vim with a vertical terminal.gpu_mem
andmgpu
: Monitor GPU memory usage.jail_list, ban_ip, unban_ip, and unban_ip_regex
: Manage IPs with fail2ban.cdmr
: Change to most recently modified directory.ensure_ssh_agent
: Ensures an SSH agent is running.bpushm, bpush, bpull
: Git operations for a specific directory.dwre
: Specific function likely related to your development work.tyc
: Deletes files matching a regex.sfunc, salias, svars, senv, shelp
: Sources various bash configuration files.codeo
: Opens files in Visual Studio Code.gsg, gag, ge, gem, geg
: Git shortcuts.ufw_bak, ufw_bak2, ufw_restore
: Backup and restore UFW rules.
Do not be afraid to bash
things up!
Edit files with impunity just like any other repo and revert if things break!
Your ~/.bashrc
file will be instantly synced since setup.sh
sets up soft symbolic links to the repo.
Finally, your ~/.bashrc
is only appended to, but still back up your bashrc just in case...I cannot afford a lawyer.
Since you might have multiple platforms, edit the platform
directory after a simple
git branch {linux, osx, windows, ...}
git checkout {linux, osx, windows, ...}
Another way to use the platform
is for specific workflows.
For example, say you are working in two different directories and
90% of your edits are in your current directory but 10% of the time you need to edit a small, helper repo.
You might have a workflow like the following.
test() {
PREV=$(pwd)
cd $HELPER_REPO_PATH
pip install --force-reinstall .
cd unit_tests
pytest run_only_this_one_unit_test_for_now.py
cd $PREV
}
This will allow you to essentially dump temporary shorthands without mucking up your global bash environment setup.
The MILD_SECRETS
directory does some simple accounting for you; as long as you know where it expects things to be, it should be able
to integrate sensitive info into your bashrc. It expects three things; if it doesn't find these, then it will attempt to integrate the
information but if it's not there, it will exit quietly.
SUPER_SECRETS
- Be vigilant that this directory NEVER gets pushed to a public repo.
- See note below regarding
.gitignore
file, but still be vigilant...I really can't afford a lawyer.
SUPER_SECRETS/super_secret_{env,env_vars,aliases,functions}
- Can be defined as standalones or written to dynamically by a script named
SUPER_SECRETS/build_super_secrets.sh
. - Should use that info to write to files described in (2).
- Can be defined as standalones or written to dynamically by a script named
SUPER_SECRETS/build_super_secrets.sh
(OPTIONAL)- This is a script that builds the environment variables, functions, etc. based on your sensitive info.
- Should use that info to write to files described in (2).
NOTE: Look at the .gitignore
file. Any variable with snake, camel case, or ALL_CAPS of super_secrets
will be ignored to make sure things do not get tracked.
Make sure to only put sensitive info inside the SUPER_SECRETS
directory!
If you want to put those under private version control, either clone the repo there or use symbolic links!
If you don't have sensitive info, omitting (1),(2), and (3) will not break anything.
If things your setup is static, you can just define (3) and omit (2).
An example of something you might want to do with build_super_secrets.sh is to define a "base_env_vars" file and then do some accounting of an ssh_config file for you that way you have all the devices you usually connect to under private version control and can simply port your environment rather than fussing with it every time you need to setup a new device.