Skip to content

Commit

Permalink
Merge pull request #48 from andresgongora/develop
Browse files Browse the repository at this point in the history
Update master to v1.2
  • Loading branch information
andresgongora authored May 27, 2019
2 parents 33cb842 + e01862f commit 89a8140
Show file tree
Hide file tree
Showing 15 changed files with 778 additions and 499 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Ignore developer's `test` and `config` files
*.config
*.test
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The following list is roughly sorted in reverse cronological order.


* olmari <[email protected]>
Variable padding for _status.sh_
Major improvements to `status.sh`



Expand Down
66 changes: 46 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ and sys-administration helpers. You can find more details and similar tools on
Note that some script snippets might be from third parties.
I collected them over many years from forums, wikis, and chats.
The original authors, if known, are referenced within the individual scripts.
If you recognize cone in a script (especially the older ones) as your own
or know the author, and the file has no reference, kindly let me know.
If you recognize a snippet and the file has no reference
(specially in the older ones), kindly let me know.


![Example with status.sh and fancy-bash-prompt.sh](doc/screenshot.png)



<!--------------------------------------+-------------------------------------->
Expand All @@ -23,16 +25,19 @@ or know the author, and the file has no reference, kindly let me know.

For now, the easiest way to install this scripts is to clone this repository
and then tell your `.bashrc` file to source those scripts you want.
When you install the scripts as a user, you have to store them somewhere
on your system. For this, we suggest the folder `~/scripts`, but feel
free to use any other location.

```
## Clone repository to ~/.config/scripts
cd ~/.config
## Clone repository to your computer
git clone https://github.com/andresgongora/scripts.git
cd scripts
## Source individual scripts. Choose the ones you want (or all).
echo 'source ~/.config/scripts/terminal/fancy-bash-prompt.sh' >> ~/.bashrc
echo 'source ~/.config/scripts/terminal/alias.sh' >> ~/.bashrc
echo 'source ~/.config/scripts/terminal/status.sh' >> ~/.bashrc
echo "source $(pwd)/terminal/fancy-bash-prompt.sh" >> ~/.bashrc
echo "source $(pwd)/terminal/alias.sh" >> ~/.bashrc
echo "source $(pwd)/terminal/status.sh" >> ~/.bashrc
```

If you want to use `fancy-bash-promt.sh` you also need power-line fonts.
Expand All @@ -42,20 +47,35 @@ Depending on your distro you can install it as:
## ArchLinux
sudo pacman -S powerline-fonts
## Ubuntu
## Debian, Ubuntu
sudo apt install fonts-powerline
```

Lastly, you may configure your scripts by editing the individual `.config`
files included in this repo. For example, to configure the colors in
`fancy-bash-promt.sh` or `status.sh`, you can do as follows.
Lastly, you may configure your scripts by first copying the individual
`*.config.example`-files included in this repo to your user's
`~/.config/scripts/` folder. First create the folder:

```
mkdir ~/.config/scripts
```

Then copy configurations you need into place, while you still are on the downloaded scripts-folder:

```
cp config_templates/status.config.example ~/.config/scripts/status.config
cp config_templates/fancy-bash-prompt.config.example ~/.config/scripts/fancy-bash-prompt.config
```

Then you can modify them for your needs. For example, to configure
the colors in`fancy-bash-promt.sh` or `status.sh`, you can do as follows:

```
## Colors and behaviour of status.sh
nano ~/.config/scripts/status.config
## Colors of fancy-bash-promt.sh
nano ~/.config/scripts/terminal/fancy-bash-prompt.config
nano ~/.config/scripts/fancy-bash-prompt.config
## Colors and behaviourt of status.sh
nano ~/.config/scripts/terminal/status.config
```


Expand Down Expand Up @@ -110,14 +130,16 @@ your manual intervention. Check the content of each script for details.





<!--------------------------------------+-------------------------------------->
# Contribute
<!--------------------------------------+-------------------------------------->

This project is only possible thanks to the effort of and passion of many,
including mentors, developers, and of course, our beloved coffe vending machine.
If you like this collection of scripts and want to contribute in any way,
you are most welcome.
you are most welcome to do so.

You can find a detailed list of everyone involved in the development of
these scripts in [AUTHORS.md](AUTHORS.md). Thanks to all of you!
Expand All @@ -133,8 +155,11 @@ these scripts in [AUTHORS.md](AUTHORS.md). Thanks to all of you!
if you notice that something is not right, tell us.
We'll try to fix it ASAP.
* Become a developer: fork this repo and become an active developer!
Take a look at the [issuess](https://github.com/andresgongora/scripts/issues)
for suggestions of where to start. Also, take a look at our
[coding style](coding_style.md).
* Push your one-time changes: even if its a tiny change,
feel free to fill in a pull-request :)
feel free to fill in a pull-request!



Expand All @@ -143,18 +168,20 @@ these scripts in [AUTHORS.md](AUTHORS.md). Thanks to all of you!
There are two branches in this repository:

* **master**: this is the main branch, and thus contains fully functional
scripts. When you want to use the scripts as a _user_,
scripts. When you want to use the scripts as an _user_,
this is the branch you want to clone or download.
* **develop**: this branch contains all the new features and most recent
contributions. It is always _stable_, in the sense that you can use it
without major inconveniences. However, because we are still working on it,
its very prone to undetected bugs and it might be subject to major
without major inconveniences.
However, its very prone to undetected bugs and it might be subject to major
unanounced changes. If you want to contribute, this is the branch
you should pull-request to.






<!--------------------------------------+-------------------------------------->
# License
<!--------------------------------------+-------------------------------------->
Expand All @@ -164,7 +191,6 @@ Copyright (c) 2014-2019, Andres Gongora - www.andresgongora.com
* This software is released under a GPLv3 license.
Read [license-GPLv3.txt](LICENSE),
or if not present, <http://www.gnu.org/licenses/>.

* If you need a closed-source version of this software
for commercial purposes, please contact the authors.

100 changes: 100 additions & 0 deletions coding_style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!--------------------------------------+-------------------------------------->
# Bash coding style
<!--------------------------------------+-------------------------------------->

This document is intended as a primer and reference to ensure a consistent style
between all scripts and auxiliary files (e.g. config files). This file will
slowly grow as needed.





<!--------------------------------------+-------------------------------------->
# Variables
<!--------------------------------------+-------------------------------------->

### Global variables

Avoid global variables unless strictly needed. Even if they are meant to be
unset at the end of the script, it is always possible that the script stops
prematurely or that the developer forgets about it. Global variables can
_contamiante_ the user's run space and lead to unexpected behaviour.

Global variables are named in uppercase and using underscores.

```
MY_VAR=2
MY_SUPER_STRING="Hello world!"
```



## Local variables

Declare _local_ variables using `local` rather than `declare` or other options.
Because local variables can not be declared in the main body of the script,
this will enforce wrapping everithing into functions, which is not a bad thing.

Local variables are named all in lower case and using underscores.

```
local my_var=2
local my_super_string="Hello world!"
```





<!--------------------------------------+-------------------------------------->
# Functions
<!--------------------------------------+-------------------------------------->

Each function shall do only one thing, otherwise, the function shall be
divided into two separate functions. Following this rule is not always easy,
but it ensures that the code is easy to read, modular and reusable.

Functions are named using camel case, with the first letter in lower case. Also,
all names must be or contain a verb that describes the action that will
performed by the function. An exception to this rule is when the function
returns (prints) a boolean. In this case, the function starts with `is` or
`has` to make it easier to read.

```
getNewValue()
printTemperature()
lockSystem()
getGPSCoordinates()
reload()
isSystemOverloaded()
hasEnoughMemory()
```




<!--------------------------------------+-------------------------------------->
# Tabs vs spaces
<!--------------------------------------+-------------------------------------->

* **Tabs** for indenting
* **Spaces** for alignment (its rarely needed)

```
getData()
{
<tab> if [ $VAR -gt 2 ]; then
<tab> <tab> aux_var=$(pollSystem "/home/user/made/up/path" |\
<tab> <tab> <spaces............> head -n 1" |\
<tab> <tab> <spaces............> sed '/somereggexblackmagic' |
<tab> <tab> <spaces............> tr -d " ")
<tab> <tab> echo "$aux_var"
<tab> fi
}
```

**Why??** - Because some of us just want to see the world burn



2 changes: 1 addition & 1 deletion common/color.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ getEffectCode()
none)
echo $NONE
;;
defualt)
default)
echo $NONE
;;
bold)
Expand Down
8 changes: 0 additions & 8 deletions common/config

This file was deleted.

Loading

0 comments on commit 89a8140

Please sign in to comment.