Skip to content

Commit

Permalink
Merge pull request #145 from andresgongora/release
Browse files Browse the repository at this point in the history
Release v2.2
  • Loading branch information
andresgongora authored Dec 18, 2019
2 parents 7445456 + e47223a commit bd34efe
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 156 deletions.
6 changes: 5 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You may add your name, email, a link to your personal web-site/blog/profile
Main developer


* **Sami Olmari**
* **Sami Olmari**
<[email protected]>
www.olmari.fi
2019 - Major improvements to `status.sh`
Expand All @@ -38,6 +38,10 @@ You may add your name, email, a link to your personal web-site/blog/profile
2019 - Incorporate git-related information to `fancy-bash-promt.sh`


* **PeterJRiches**
2019 - Proofreading of comments and explanation fixes





Expand Down
71 changes: 38 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You can find more details and similar tools on
[Yet Another Linux'n Electronics Blog](https://yalneb.blogspot.com/).


- System status report with the most relevan information when you open up a new
- System status report with the most relevant information when you open up a new
terminal. It also works over SSH to monitor your server or RaspberryPi!!
- Fancy bash prompt with colors. Makes separating your input from
command-outputs that much easier.
Expand All @@ -28,55 +28,52 @@ The recommended way to install synth-shell is to run the provided setup script.
This will guide you step by step through the process and let you choose what
to install. It will also allow you to install the script for your user only,
or system-wide (super user privileges required). To proceed,
[open and play this link in a separate tab](https://www.youtube.com/watch?v=k6ZMYWPQID0),
and execute the following to feel like
[Hackerman](https://www.youtube.com/watch?v=KEkrWRHCDQU&list=WL&index=63&t=0s):
[open and play this link in a separate tab](https://www.youtube.com/embed/MpN91wHAr1k)
if you want to feel like
[Hackerman](https://www.youtube.com/embed/KEkrWRHCDQU),
then enter the following into your terminal or telnet session:
```
git clone --recursive https://github.com/andresgongora/synth-shell.git
chmod +x synth-shell/setup.sh
synth-shell/setup.sh
rm -fr synth-shell
rm -fr synth-shell # optional, to remove the cloned git repo
bash
source ~/.bashrc
```


If you want to use `fancy-bash-promt.sh` you also need power-line fonts.
Depending on your distro you can install it as follows (the exact name of the package varies from distro to distro):
Depending on your distro you can install them as follows (the exact name of the package varies from distro to distro):

* ArchLinux: `sudo pacman -S powerline-fonts`
* Debian/Ubuntu: `sudo apt install fonts-powerline`



### Script configuration/customization
You can configure your scripts by modifying the corresponding configurtion
You can configure your scripts by modifying the corresponding configuration
files. In addition to said files, you can also find configuration examples
in the following folders depending on how you isntalled it:
in the following folders depending on how you installed **synth-shell**:

* Current user only: `~/.config/synth-shell/`
* System wide: `~/etc/synth-shell/`



### Manual instalation of individual scripts
If you want to skip the above steps, and are only intereset in a very
specific script, you can easily use it by its own.
### Manual installation of individual scripts
If you want to skip the above steps, and are only interested in a very
specific script, you can easily use it on its own.
However, some scripts might source other scripts from the `bash-tools` folder,
as they provided shared functioanlities to all scripts. If you are interested
as they provide shared functionalities to all scripts. If you are interested
in a single script from my collection, check whether it depends on a script from
bash-tools, and copy the content of said dependency into the script you want.



### Uninstallation
It's hard to say goodbye, but we had good times together, didn't we? :)
```
git clone --recursive https://github.com/andresgongora/synth-shell.git
chmod +x synth-shell/setup.sh
synth-shell/setup.sh uninstall
rm -fr synth-shell
```
It's hard to say goodbye, but we had good times together, didn't we? :)
Just run the script again as if to install it,
but choose `uninstall` when prompted.



Expand All @@ -92,16 +89,24 @@ rm -fr synth-shell


### status.sh
Provides a summarized system report in a single glance everytime you open up a
Provides a summarized system report at a single glance every time you open up a
new terminal. If it detects that any system parameter (e.g. cpu load,
memory, etc.) is over a critical threshold, it will provide a warning and
additional information about the cause. Last but not least, it also prints an
additional information about the cause. Last but not least, it also prints a
user configurable logo such that you may impress your crush from the library
with some awesome ASCII art.

Feel free to customize your prompt to match your exact requirements with some
of the many available options. For details please check the appropriate
`~/.config/synth-shell/status.config` or `/etc/synth-shell/status.config`
depending on your installation option.

![status configuration options](doc/status_config_preview.png)



### fancy-bash-prompt.sh
Adds colors and triangular separators to you bash prompt.
Adds colors and triangular separators to your bash prompt.
For best results, consider installing (and telling your terminal to use)
the `hack-ttf` font alongside the powerline-fonts (the later is required for
the separators).
Expand All @@ -116,8 +121,8 @@ the separators).
# Contribute
<!--------------------------------------+-------------------------------------->

This project is only possible thanks to the effort of and passion of many,
including developers, testers, and of course, our beloved coffe vending machine.
This project is only possible thanks to the effort and passion of many,
including developers, testers, and of course, our beloved coffee vending machine.
You can find a detailed list of everyone involved in the development
in [AUTHORS.md](AUTHORS.md). Thanks to all of you!

Expand All @@ -143,13 +148,13 @@ If you like this project and want to contribute, you are most welcome to do so.
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 an _user_,
scripts. When you want to use the scripts as a _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, its very prone to undetected bugs and it might be subject to major
unanounced changes. If you want to contribute, this is the branch
However, it's very prone to undetected bugs and it might be subject to major
unannounced changes. If you want to contribute, this is the branch
you should pull-request to.


Expand All @@ -164,16 +169,16 @@ There are two branches in this repository:

Why **synth-shell**? That's a quite easy question. Its started out as a loose
bunch of (super simple) scripts that I kept around to aid me during
system maintenance. But after a while, a started to get the hang out of bash
and wrote more complex stuff. I wanted my code not only to work
system maintenance. But after a while, as I started to get the hang of bash
and wrote more complex stuff, I wanted my code not only to work
and be purely useful, but also to provide some eye-candy.

Naturally, it didn't start the way you see it today. Many scripts started out as
an ugly attempt to get the behaviour I wanted, but using many snippets from
Naturally, it didn't start the way you see it today; Many scripts started out as
an ugly attempt to get the behaviour I wanted, by using many snippets from
different third parties. This meant that the code was usually quite ugly and
full of bugs - not because of the third parties, but because of the way I
integrated them. yet over time, I rewrote all scripts from scratch, removed
the fluff, and also got lot's of help by super friendly and engaged
integrated them. Yet over time, I rewrote all scripts from scratch, removed
the fluff, and also got lots of help from super-friendly and engaged
[contributors](AUTHORS.md). The result is what you see today.
I admit it, it's nothing fancy, but writing these scripts provided me with
lots of joy.
Expand Down
2 changes: 1 addition & 1 deletion config_templates/fancy-bash-prompt.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## COLORS
##
## Control the color and format scheme of the bash prompt.
## The prompt is divided into segments, listed belows starting from the left:
## The prompt is divided into segments, listed below starting from the left:
## - USER: shows the user's name.
## - HOST: shows the host's name.
## - PWD: shows the current directory.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
##==============================================================================
## COLORS
##
## Control the color and format scheme of the bash prompt.
## The prompt is divided into segments, listed belows starting from the left:
## - USER: shows the user's name.
## - HOST: shows the host's name.
## - PWD: shows the current directory.
## - GIT: if inside a git repository, shows the name of current branch.
## - INPUT: actual bash input.
##
## Valid color options:
## white black light-gray dark-gray
## red green yellow blue cyan purple
## light-red light-green light-yellow light-blue light-cyan light-purple
## values in the range [0-255] for 256 bit colors
##==============================================================================

font_color_user="black"
background_user="208"
texteffect_user="bold"

font_color_host="black"
background_host="180"
texteffect_host="bold"

font_color_pwd="black"
background_pwd="white"
texteffect_pwd="bold"

font_color_git="light-gray"
background_git="dark-gray"
texteffect_git="bold"

font_color_input="208"
background_input="none"
texteffect_input="bold"



##==============================================================================
## BEHAVIOR
##==============================================================================
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
show_git=true # Enable/Disable git info if inside a repo


16 changes: 8 additions & 8 deletions config_templates/status.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##==============================================================================
## LOGO
##
## Configure the logo to you liking. You can either use the default or
## Configure the logo to your liking. You can either use the default or
## set your own ASCII art down below.
##
## - You can either add it as a single line, or multiline (terminated with \).
Expand Down Expand Up @@ -44,10 +44,10 @@ logo="
## UPTIME System uptime (time since boot)
## USER Current user and host names
## NUMLOGGED Show number of logged in users
## NAMELOGGED Show name of logged in users
## NAMELOGGED Show names of logged in users
## LOCALIPV4 IPv4
## EXTERNALIPV4 External IPv4 (might be slow)
## SERVICES Sumary of failed services
## SERVICES Summary of failed services
## CPUUTILIZATION Sys load average(eg. 0.23, 0.26, 0.27 )
## CPUTEMP CPU temperature (requires lm-sensors)
##
Expand Down Expand Up @@ -96,7 +96,7 @@ print_info="
##
## Control the color and format scheme of the status report.
## -c color: color name or 256bit color code
## -b background ground color: color name or 256bit color code
## -b background color: color name or 256bit color code
## -e effect: bold, blink, dim, underline...
##
## Valid color names (16 bit):
Expand All @@ -119,11 +119,11 @@ format_logo=" -c blue -e bold"
##==============================================================================
## STATUS BARS
##
## This optios control the behaviourt of the visual status bars that are plotted
## This option controls the behaviour of the visual status bars that are plotted
## for CPU, Memory, Swap and HDD usage. You can set the percentage that
## determine when the current usage is deemed critical. If said percentage
## is surprased, the color of the bars will change and extra information
## might be plotted in addition (e.g. if the CPU usage is to high, the most
## determines when the current usage is deemed critical. If said percentage
## is surpassed, the color of the bars will change and extra information
## might be plotted in addition (e.g. if the CPU usage is too high, the most
## demanding processes are printed to terminal).
##==============================================================================

Expand Down
14 changes: 14 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<!--------------------------------------+-------------------------------------->
# v2.2
<!--------------------------------------+-------------------------------------->

- Improvement and fixes to textfiles and code comments
- Fixed "N/A" message printed for SWAP_MON if there is no swap
- Add preview of the configuation options for status.sh
- fancy_bash_prompt: Update titlebar of terminal-window when changing folder






<!--------------------------------------+-------------------------------------->
# v2.1.5
<!--------------------------------------+-------------------------------------->
Expand Down
29 changes: 15 additions & 14 deletions doc/coding_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ slowly grow as needed.
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.
_contaminate_ the user's run space and lead to unexpected behaviour.

Global variables are named in uppercase and using underscores.

Expand All @@ -35,7 +35,7 @@ MY_SUPER_STRING="Hello world!"

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.
this will enforce wrapping everything into functions, which is not a bad thing.

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

Expand All @@ -59,7 +59,7 @@ 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
be 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.

Expand All @@ -83,7 +83,7 @@ hasEnoughMemory()
<!--------------------------------------+-------------------------------------->

* **Tabs** for indenting
* **Spaces** for alignment (its rarely needed)
* **Spaces** for alignment (It's rarely needed.)

```
getData()
Expand All @@ -110,25 +110,26 @@ getData()
<!--------------------------------------+-------------------------------------->

### Line length
Limit lines to 80 characters whenever possible (code + characters).
Limit lines to 80 characters whenever possible (code + comments).
Use backslash '\' to continue code on a second line.
This is because of the following reasons:
* Traditionally, temrinals were 80 chars wide. This no longer holds true, but
* Traditionally, terminals were 80 chars wide. This no longer holds true, but
is as good as any other line-length limit in a similar range.
* When working on a single monitor, its useful to visualize two files side
by side. With more than 80 characres per line, it becomes difficul unless
the scriin is very wide
* When solving conflicts when mergin two files, the same applies; only that
this time its useful to visualize 3 files side by side.
* When working on a single monitor, it's useful to visualize two files side
by side. With more than 80 characters per line, it becomes difficult unless
the screen is very wide.
* When solving conflicts when merging two files, the same applies; only that
this time it's useful to visualize three files side by side.




### New lines to separate code
If adding new lines to separate chunks of code, use either 1, 2, 3 or 6 lines.

* 1 line if the code is very related
* 2 lines if the code in inside the same function, and the function is short
* 3 lines if the code in inside the same function, and the function is
* 2 lines if the code is inside the same function, and the function is short
* 3 lines if the code is inside the same function, and the function is
complex. In this case, a "header-comment" must be placed above each chunk
explaining what it does.
* 6 lines To separate bigger code sections, like to separate the sections that
Expand All @@ -144,7 +145,7 @@ If adding new lines to separate chunks of code, use either 1, 2, 3 or 6 lines.
<!--------------------------------------+-------------------------------------->

### System binary calls
Please do not call any system binary using only it's name, wrap it in `'`,
Please do not call any system binary using only its name - wrap it in `'`,
or use `which`.

For example, do not do call `ls` or `/usr/bin/ls`, as the
Expand Down
Binary file added doc/status_config_preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bd34efe

Please sign in to comment.