Skip to content

Commit

Permalink
Merge pull request #152 from andresgongora/develop
Browse files Browse the repository at this point in the history
v2.4
  • Loading branch information
andresgongora authored Jan 23, 2020
2 parents d6fa011 + 4ef766b commit ecb7ec7
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 141 deletions.
92 changes: 68 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ combination of small bash scripts.
- Git statuses (requires pull/push, is dirty, etc.) if inside a directory that
is part of a git repository.
- Better separation between user input and command outputs.

- **better ls**: an `ls -la` on steroids alternative.

- **alias**: add colors and a nicer behaviour to basic commands.
- `grep`.
- `pacman`.
- `tree`.
- `dmesg`.
- `free`.
- `sudo`: autocomplete commands.
- `history`: nicer format and no duplicate (consecutively the same) commands.

- **More coming soon...**

Expand All @@ -39,48 +50,46 @@ tools on [Yet Another Linux'n Electronics Blog](https://yalneb.blogspot.com/).
### Automatic setup

The included [setup script](setup.sh) will guide you step by step through the
process and let you choose what features to install. During the setup, you can
process and let you choose what features to install. During this setup, you can
choose to install synth-shell for your user only (recommended) or system-wide
(superuser privileges required). To proceed,
[open and play this link in a separate tab](https://www.youtube.com/embed/MpN91wHAr1k)
and enter the following into your terminal or telnet session:
and enter the following into your terminal:
```
git clone --recursive https://github.com/andresgongora/synth-shell.git
chmod +x synth-shell/setup.sh
synth-shell/setup.sh
```

Once done, you can fire up a new terminal and enjoy the result. Note that for
`fancy-bash-prompt.sh` you might also need
Note that for `fancy-bash-prompt.sh` you might also need
[power-line fonts](https://github.com/powerline/fonts). You can instal it
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`

Finally, open up a new terminal and test that everything works. Sometimes,
despite power-line fonts being properly installed, the triangle separator is
still not shown. In this case, make sure that your `locale` is set to UTF-8 by
editing `/etc/locale.conf` file (select your language but in UTF-8 format) and
running `sudo locale-gen`.
despite power-line fonts being properly installed, the triangle separator
for `fancy-bash-prompt.sh` (if installed) might still not show. In this case,
make sure that your `locale` is set to UTF-8 by editing `/etc/locale.conf` file
(select your language but in UTF-8 format) and running `sudo locale-gen`.
[More info on locale](https://wiki.archlinux.org/index.php/locale).



### Configuration/customization
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 installed **synth-shell**:
files. You can find them, along example configuration files, in the following
folders depending on how you installed **synth-shell**:

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



### Uninstallation
It's hard to say goodbye, but we had good times together, didn't we? :)
Just run the setup script again as if to install it,
but choose `uninstall` when prompted.
Run the setup script again (like during the installation), but choose
`uninstall` when prompted.



Expand Down Expand Up @@ -119,6 +128,39 @@ 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).

As for the git status info, `fancy-bash-prompt.sh` prints an additional, fourth
separator with the name of the current branch and one of the following icons
to indicate the state of the repository (can be changed in the config file):

| Local-Upstream | Local branch has no changes | Local branch is dirty |
|:--------------------------------:|:---------------------------:|:---------------------:|
| Up to date | | ! |
| Ahead (you have to push) |||
| Behind (you have to pull) |||
| Diverged (you have to pull-push) |||



### better-ls.sh
Makes `ls` print more text, but nicely formated. When called, `ls` will now list
all files (`-la`), sort folders first, add colors to output, and list hidden
files last after a quick separator. However, if you chose to call `ls` with your
own parameters (e.g. `ls -l`) it will revert to the default behaviour except
for color and sorting options.



### Alias

- `grep` to `grep --color=auto`.
- `pacman` to `pacman --color=auto`.
- `tree` to `tree --dirsfirst -C`.
- `dmesg` to `dmesg --color=auto --reltime --human --nopager --decode`.
- `free` to `free -mht`.
- `sudo` adds `complete -cf sudo` to atucomplete commands.
- `history` various changes.




<br/><br/>
Expand All @@ -130,7 +172,7 @@ the separators).
<!--------------------------------------+-------------------------------------->

This project is only possible thanks to the effort and passion of many,
including developers, testers, and of course, our beloved coffee vending machine.
including developers, testers, and of course, our beloved coffee 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 @@ -148,6 +190,8 @@ If you like this project and want to contribute, you are most welcome to do so.
Take a look at the [issues](https://github.com/andresgongora/synth-shell/issues)
for suggestions of where to start. Also, take a look at our
[coding style](coding_style.md).
* Spread the word: telling your friends is the fastes way to get this code to
the people who might enjoy it!



Expand Down Expand Up @@ -180,17 +224,17 @@ used for system maintenance. In the beginning, they were simple aids to make my
life easier, but as I progressively got the hang out of bash, I also wanted them
to print some nice output to the terminal.

Naturally, it didn't start the way you see it today. The content of most scripts
were loose snippets from third parties that were somehow smashed together. They
worked, but not exactly the way I wanted. So, over time I have rewritten all
scripts from scratch, removed fluff, and teamed up with 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.
This repository was quite different at the beginning. The content of most
scripts were loose snippets from third parties that were somehow smashed
together. They worked, but not exactly the way I wanted. So, over time I have
rewritten most scripts from scratch, removed fluff, and teamed up with
super-friendly and engaged [contributors](AUTHORS.md). The result is what you
see today. I admit it, it's nothing fancy. But it was real fun working on the
scripts.

And the name? That's quite easy. I spent most of my coding frenzy
listening to [SynthWave](https://en.wikipedia.org/wiki/Synthwave) to feel like
[Hackerman](https://www.youtube.com/watch?v=KEkrWRHCDQU).
my idol, [Hackerman](https://www.youtube.com/watch?v=KEkrWRHCDQU).



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

-






<!--------------------------------------+-------------------------------------->
# v2.4
<!--------------------------------------+-------------------------------------->

- Better README.
- Add alias scripts.
- Add better-ls script.
- Add reminder during installation of optional packages.



Expand Down
105 changes: 71 additions & 34 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,29 +176,39 @@ installScript()


## COPY CONFIGURATION FILES
## - Create system config folder if there is none
## - Check if there is already some configuration in place
## - If none, copy current configuration
## - If there is, but different, copy with .new extension
## - Copy all examples files (overwrite old examples)
printInfo "Adding config files to $CONFIG_DIR"
## - Check if script has config file at all. If so:
## - Create system config folder if there is none
## - Check if there is already some configuration in place
## - If none, copy current configuration
## - If there is, but different, copy with .new extension
## - If example folder exists
## - Copy all examples files (overwrite old examples)
local sys_conf_file="${CONFIG_DIR}/${script_name}.config"
local conf_example_dir="${config_template_dir}/${script_name}.config.examples"
local conf_template="${config_template_dir}/${script_name}.config"

if [ ! -d $CONFIG_DIR ]; then
mkdir -p $CONFIG_DIR
fi

if [ ! -f "$sys_conf_file" ]; then
cp -u "${conf_template}" "${sys_conf_file}"
elif ( ! cmp -s "$conf_template" "$sys_conf_file" ); then
cp -u "${conf_template}" "${sys_conf_file}.new"
printWarn "Old configuration file detected"
printText "New file written to ${sys_conf_file}.new"
fi
if [ -f $conf_template ]; then

printInfo "Adding config files to $CONFIG_DIR"

cp -ur "$conf_example_dir" "${CONFIG_DIR}/"
if [ ! -d $CONFIG_DIR ]; then
mkdir -p $CONFIG_DIR
fi

if [ ! -f "$sys_conf_file" ]; then
cp -u "${conf_template}" "${sys_conf_file}"
elif ( ! cmp -s "$conf_template" "$sys_conf_file" ); then
cp -u "${conf_template}" "${sys_conf_file}.new"
printWarn "Old configuration file detected"
printInfo "New file written to ${sys_conf_file}.new"
fi

if [ -d "$conf_example_dir" ]; then
printInfo "Adding example config files to ${CONFIG_DIR}"
cp -ur "$conf_example_dir" "${CONFIG_DIR}/"
fi

fi



Expand All @@ -214,7 +224,32 @@ installScript()
chmod +x "$uninstaller"



printSuccess "Script $script_name succesfully installed"



## EXTRA NOTES DEPENDING ON SCRIPT
local optional_packages=""
if [ $script_name == "status" ]; then
local optional_packages="lm_sensors"
elif [ $script_name == "fancy-bash-prompt" ]; then
local optional_packages="powerline-fonts"
fi

if [ -n "$optional_packages" ]; then
printInfo "Consider installing the following packages as well."
printInfo "The exact name might change between distributions:"
printText "$optional_packages"
fi



## Print final separator
echo ""



;;


Expand All @@ -233,20 +268,14 @@ installScript()
##
installAll()
{
local action=$(promptUser "Install status? (Y/n)" "" "yYnN" "y")
case "$action" in
""|y|Y ) installScript install "status"
;;
*) echo ""
esac


local action=$(promptUser "Install fancy-bash-prompt? (Y/n)" "" "yYnN" "y")
case "$action" in
""|y|Y ) installScript install "fancy-bash-prompt"
;;
*) echo ""
esac
for script in $SCRIPTS; do
local action=$(promptUser "Install ${script}? (Y/n)" "" "yYnN" "y")
case "$action" in
""|y|Y ) installScript install "${script}"
;;
*) echo ""
esac
done
}


Expand All @@ -261,8 +290,9 @@ uninstallAll()
## RUN QUICK-UNINSTALLER
"$uninstaller"
else
installScript uninstall "status"
installScript uninstall "fancy-bash-prompt"
for script in $SCRIPTS; do
installScript uninstall "$script"
done
fi
}

Expand Down Expand Up @@ -374,6 +404,13 @@ promptUser()
##
installer()
{
local SCRIPTS="
status
fancy-bash-prompt
better-ls
alias
"

case "$1" in
install|uninstall) installerSystem "$1";;
*) promptUser;;
Expand Down
Loading

0 comments on commit ecb7ec7

Please sign in to comment.