Skip to content

Commit

Permalink
Fix setup script
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Gongora <[email protected]>
  • Loading branch information
andresgongora committed Apr 18, 2020
1 parent 32efe0a commit 967d4b7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@

You may install `synth-shell-prompt` from AUR:
https://aur.archlinux.org/packages/synth-shell-prompt-git/
Once installed, test it with:
```
. /usr/bin/synth-shell-greeter
```
And if you like it, add it permanently to your terminal with:
```
echo ". /usr/bin/synth-shell-greeter" >> ~/.bashrc
```



Expand All @@ -34,15 +42,17 @@ git clone --recursive https://github.com/andresgongora/synth-shell-greeter.git
synth-shell-greeter/setup.sh
```

You can then test your script by running it from wherever you installed it.
Usually this is to your user's `.config` folder, so you should run:
You can then test your script by sourcing it from wherever you installed it.
Usually this is to your user's `.config` folder, so you should run the following
command. Notice the `.`, this is meant to source the script to your
terminal session (i.e. include it into your session).
```
~/.config/synth-shell/synth-shell-greeter.sh
. ~/.config/synth-shell/synth-shell-greeter.sh
```

If you want it to appear everytime you open a new terminal, run
If you want it to appear everytime you open a new terminal, run either
```
echo "~/.config/synth-shell/synth-shell-greeter.sh" >> ~/.bashrc
echo ". ~/.config/synth-shell/synth-shell-greeter.sh" >> ~/.bashrc
```


Expand Down Expand Up @@ -79,7 +89,7 @@ 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 | | ! |
| Up to date | | |
| Ahead (you have to push) |||
| Behind (you have to pull) |||
| Diverged (you have to pull-push) |||
Expand Down
2 changes: 1 addition & 1 deletion config/synth-shell-prompt.config
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ texteffect_input="bold"
## BEHAVIOR
##==============================================================================

local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt


Expand Down
15 changes: 11 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@


##==============================================================================
##
include(){ { [ -z "$_IR" ]&&_IR="$PWD"&&cd "$(dirname "$PWD/$0")"&&include "$1"&&cd "$_IR"&&unset _IR;}||{ local d=$PWD&&cd "$(dirname "$PWD/$1")"&&. "$(basename "$1")"&&cd "$d";}||{ echo "Include failed $PWD->$1"&&exit 1;};}
## EXTERNAL DEPENDENCIES
##==============================================================================
[ "$(type -t include)" != 'function' ]&&{ include(){ { [ -z "$_IR" ]&&_IR="$PWD"&&cd $(dirname "${BASH_SOURCE[0]}")&&include "$1"&&cd "$_IR"&&unset _IR;}||{ local d=$PWD&&cd "$(dirname "$PWD/$1")"&&. "$(basename "$1")"&&cd "$d";}||{ echo "Include failed $PWD->$1"&&exit 1;};};}

include 'bash-tools/bash-tools/user_io.sh'
include 'bash-tools/bash-tools/hook_script.sh'
include 'bash-tools/bash-tools/assemble_script.sh'






##==============================================================================
## SETUP
##==============================================================================

## SWITCH BETWEEN AUTOMATIC AND USER INSTALLATION
if [ "$#" -eq 0 ]; then
OUTPUT_SCRIPT="$HOME/.config/synth-shell/synth-shell-prompt.sh"
OUTPUT_CONFIG_DIR="$HOME/.config/synth-shell"
cp "$OUTPUT_CONFIG_DIR/synth-shell-prompt.config" \
"$OUTPUT_CONFIG_DIR/synth-shell-prompt.config.backup"
printInfo "Installing script as $OUTPUT_SCRIPT"
USER_CHOICE=$(promptUser "Add hook your .bashrc file or equivalent?\n\tRequired for autostart on new terminals" "[Y]/[n]?" "yYnN" "y")
case "$USER_CHOICE" in
Expand Down
18 changes: 11 additions & 7 deletions synth-shell-prompt/synth-shell-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ include '../config/synth-shell-prompt.config'

synth_shell_prompt()
{



##==============================================================================
## FUNCTIONS
##==============================================================================
Expand Down Expand Up @@ -229,8 +226,9 @@ prompt_command_hook()



##------------------------------------------------------------------------------
##
##==============================================================================
## MAIN
##==============================================================================

## LOAD USER CONFIGURATION
local user_config_file="$HOME/.config/synth-shell/synth-shell-prompt.config"
Expand Down Expand Up @@ -322,12 +320,18 @@ prompt_command_hook()


}
## CALL SCRIPT
## CALL SCRIPT FUNCTION
## CHECK IF SCRIPT IS _NOT_ BEING SOURCED
## CHECK IF COLOR SUPPORTED
## - Check if compliant with Ecma-48 (ISO/IEC-6429)
## - Call script
## - Unset script
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
echo -e "Do not run this script, it will do nothing.\nPlease source it instead by running:\n"
echo -e "\t. ${BASH_SOURCE[0]}\n"

elif [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
synth_shell_prompt
unset synth_shell_prompt

fi

0 comments on commit 967d4b7

Please sign in to comment.