diff --git a/README.md b/README.md
index e899bad..a9feed5 100644
--- a/README.md
+++ b/README.md
@@ -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...**
@@ -39,19 +50,18 @@ 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):
@@ -59,28 +69,27 @@ as follows (the exact name of the package varies from distro to distro):
* 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.
@@ -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.
+
+
@@ -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!
@@ -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!
@@ -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).
diff --git a/doc/changelog.md b/doc/changelog.md
index b2f9158..18fc13a 100644
--- a/doc/changelog.md
+++ b/doc/changelog.md
@@ -2,7 +2,21 @@
# v2.3
+-
+
+
+
+
+
+
+
+# v2.4
+
+
- Better README.
+- Add alias scripts.
+- Add better-ls script.
+- Add reminder during installation of optional packages.
diff --git a/setup.sh b/setup.sh
index 2ed0386..5081cfe 100755
--- a/setup.sh
+++ b/setup.sh
@@ -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
@@ -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 ""
+
+
+
;;
@@ -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
}
@@ -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
}
@@ -374,6 +404,13 @@ promptUser()
##
installer()
{
+ local SCRIPTS="
+ status
+ fancy-bash-prompt
+ better-ls
+ alias
+ "
+
case "$1" in
install|uninstall) installerSystem "$1";;
*) promptUser;;
diff --git a/synth-shell/alias.sh b/synth-shell/alias.sh
index effa794..47f5101 100755
--- a/synth-shell/alias.sh
+++ b/synth-shell/alias.sh
@@ -23,6 +23,7 @@
+
##==============================================================================
## SIMPLE COMMAND OPTIONS
##==============================================================================
@@ -36,49 +37,46 @@ alias free='\free -mht'
+
##==============================================================================
-## COMMAND OVERRIDES
+## BETTER SUDO
##==============================================================================
-## GET CURRENT FOLDER
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-
+alias sudo='\sudo '
-## BETTER LS
-BETTER_LS_FILE="$DIR/better-ls.sh"
-if [ -f $BETTER_LS_FILE ]; then
- chmod +x "$BETTER_LS_FILE"
- alias ls="$BETTER_LS_FILE"
+if [ "$PS1" ]; then
+ complete -cf sudo
fi
-if [ -f /usr/bin/prettyping ]; then
- alias ping='prettyping --nolegend' ## Replace ping with prettyping
-fi
-if [ -f /usr/bin/bat ]; then
- alias cat='bat' ## Replace cat with bat
-fi
-## BETTER HISTORY
-BETTER_HISTORY_FILE="$DIR/better-history.sh"
-if [ -f $BETTER_HISTORY_FILE ]; then
- source "$BETTER_HISTORY_FILE"
-fi
+##==============================================================================
+## BETTER HISTORY
+##==============================================================================
+betterHistory()
+{
+ local blue="\033[0;34m"
+ local nocolor="\033[0m"
+ export HISTTIMEFORMAT=`echo -e ${blue}[%F %T] $nocolor `
+ export HISTSIZE=10000
+ export HISTFILESIZE=50000
+ export HISTCONTROL=ignoreboth # don't put duplicate lines or lines starting with space in the history.
+}
+betterHistory
-##==============================================================================
-## BETTER SUDO
-##==============================================================================
-alias sudo='\sudo '
+## BETTER COMMAND HISTORY (CTRL+r) >>>>>>>UNDER CONSTRUCTION<<<<<<<<<<<<<<<<<<<<
+#if [ -f /usr/bin/fzf ]; then
+# alias preview="fzf --preview 'bat --color \"always\" {}'"
+# # add support for ctrl+o to open selected file in VS Code
+# export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'"
+#fi
-if [ "$PS1" ]; then
- complete -cf sudo
-fi
diff --git a/synth-shell/better-history.sh b/synth-shell/better-history.sh
index e5b1b69..461b0ca 100755
--- a/synth-shell/better-history.sh
+++ b/synth-shell/better-history.sh
@@ -27,22 +27,4 @@
-##==============================================================================
-## BETTER TERMINAL HISTORY
-##==============================================================================
-MY_BASH_BLUE="\033[0;34m" #Blue
-MY_BASH_NOCOLOR="\033[0m"
-HISTTIMEFORMAT=`echo -e ${MY_BASH_BLUE}[%F %T] $MY_BASH_NOCOLOR `
-export HISTSIZE=10000
-export HISTFILESIZE=50000
-HISTCONTROL=ignoreboth # don't put duplicate lines or lines starting with space in the history.
-
-
-
-## BETTER COMMAND HISTORY (CTRL+r) >>>>>>>UNDER CONSTRUCTION<<<<<<<<<<<<<<<<<<<<
-if [ -f /usr/bin/fzf ]; then
- alias preview="fzf --preview 'bat --color \"always\" {}'"
- # add support for ctrl+o to open selected file in VS Code
- export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'"
-fi
diff --git a/synth-shell/better-ls.sh b/synth-shell/better-ls.sh
index 76f48ab..6fbb1a7 100755
--- a/synth-shell/better-ls.sh
+++ b/synth-shell/better-ls.sh
@@ -71,48 +71,48 @@
## BETTER LS
##==============================================================================
-shopt -s extglob
-LS='ls'
-
-
-## IF NO ARGUMENTS PASSED -> run better ls version on current folder
-if [ $# -eq 0 ]; then
-
- ## IF THE CURRENT FOLDER IS NOT EMPTY -> Display all
- files=$($LS -U * 2> /dev/null | wc -l)
- if [ "$files" != "0" ]
- then
- ## List implied . and .., visible folders, then visible files
- $LS -d {.,..,*} -lA --color=auto --human-readable \
- --time-style=long-iso --group-directories-first;
-
-
- ## List hidden folders and files (only if they exist)
- hidden_files=$($LS -U -d .!(|.) 2> /dev/null | wc -l)
- if [ "$hidden_files" != "0" ]
- then
- echo ""
- $LS -d .!(|.) -l --color=auto --hide='..' \
- --human-readable --time-style=long-iso \
- --group-directories-first;
+ls()
+{
+ echo "$@"
+ shopt -s extglob
+ local LS="$(which ls)"
+
+
+ ## IF NO ARGUMENTS PASSED -> run better ls version on current folder
+ if [ $# -eq 0 ]; then
+
+ ## IF THE CURRENT FOLDER IS NOT EMPTY -> Display all
+ files=$($LS -U * 2> /dev/null | wc -l)
+ if [ "$files" != "0" ]
+ then
+ ## List implied . and .., visible folders, then visible files
+ $LS -d {.,..,*} -lA --color=auto --human-readable \
+ --time-style=long-iso --group-directories-first;
+
+
+ ## List hidden folders and files (only if they exist)
+ hidden_files=$($LS -U -d .!(|.) 2> /dev/null | wc -l)
+ if [ "$hidden_files" != "0" ]
+ then
+ echo ""
+ $LS -d .!(|.) -l --color=auto --hide='..' \
+ --human-readable --time-style=long-iso \
+ --group-directories-first;
+ fi
+
+ ## IF THE CURRENT FOLDER IS EMPTY -> List . and ..
+ else
+ $LS -d {.,..,} -lA --color=auto --human-readable \
+ --time-style=long-iso --group-directories-first;
fi
- ## IF THE CURRENT FOLDER IS EMPTY -> List . and ..
+
+ ## IF ARGUMENTS PASSED -> run standard ls but with some tweaks (eg: colors)
else
- $LS -d {.,..,} -lA --color=auto --human-readable \
- --time-style=long-iso --group-directories-first;
+ $LS --color=auto --human-readable --time-style=long-iso \
+ --group-directories-first "$@";
fi
+}
-
-## IF ARGUMENTS PASSED -> run standard ls but with some tweaks (eg: colors)
-else
- $LS -la --color=auto --human-readable --time-style=long-iso \
- --group-directories-first "$@";
-fi
-
-
-
-unset LS
-exit 0
### EOF ###