nikiforov-alexander / helpful-bash-scripts

Collection of Bash scripts that were very helpful during my PhD

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Collection of Helpful Bash Scripts

1. Main File Included Everywhere

Main file that is included everywhere is helpful_bash_funcs.sh. In this file a lot of very simple, yet needed functions are defined:

  • cf : enhanced cat file

  • em : enhanced echo

  • _ : bash decorator

  • crdir : enhanced mkdir

  • crdir_if_not_exist : enhanced mkdir, check is dir exists

  • crdir_if_exist_overwrite : enhanced mkdir, overwrites dir if exists

  • ss_and_vim : creates alias vv that after you type ss will open script file

  • colorful functions: make output colorful

    • gray

    • red

    • green

    • blue

    • resetcolor

  • check_if_it_exists : checks if file exists

  • set_var : enhanced set of variabe

  • echo_var : echoes variable by name

  • cd : enhanced cd function, used in scripts

  • exit : enhanced exit function, when used in scripts, prints more info

2. Aliases

File with Bash aliases aliases.sh has collection of very simple but useful commands, and is used to run many of the scripts defined here. It may be better to add all of them to $PATH but I liked it this way.

To follow naming convention of .bash_aliases I usually create a link in $HOME directory to this file:

ln -s /path/to/aliases.sh ~/.bash_aliases

In the file itself I use set_alias function to keep track of aliases I’ve created. It might seem as overkill, but I like verbosity. Although for now set_alias function does not do much.

Later I plan to include description for alias may be.

3. Git Scripts

Collection of helpful Git scripts. For now just one, hopefully will be more

3.1. Add Untracked Files To .gitignore

The script add_files_to_gitignore.sh is script that is used to add all 'Untracked' files to .gitignore.

If you are not in top-level directory, script will show it to you and ask to go there and run git status again to make sure you want put those files to .gitignore.

Script creates .gitignore if it does not exist.

3.2. Nice listing script

I added ls-with-pwd.sh script, that prints files nicely.

The major difference that now it also prints PWD before actual $ symbol.

Also it colors file grouping them by first letter.

Here is nice image:

snapshot

About

Collection of Bash scripts that were very helpful during my PhD


Languages

Language:Shell 100.0%