Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let the user choose background color for newline module #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rockandska
Copy link
Contributor

Let the user too chose the background color for newline module.
Useful if you have a module who fill the wall line like mine (see bellow)

Without the modification:


With this modification :


@chris-marsh
Copy link
Owner

chris-marsh commented Jun 24, 2018

I don't experience the issues with the background color as shown in your first screenshot.
Is this caused by the changes made in PR #11 ?

@rockandska
Copy link
Contributor Author

I think it is not related.

But before provide you a test case, see this bug not related with the test i will provide you just to be sure that is not my module who include it

env -i bash --noprofile --norc --login
bash-4.3$ cd /tmp/pureline/
bash-4.3$ git rev-parse HEAD
1e44b57a67e9a5ab1c81cfffd8e0d2c359eda807
bash-4.3$ git diff
WARNING: terminal is not fully functional
diff --git a/pureline b/pureline
index be03be1..70d2833 100644
--- a/pureline
+++ b/pureline
@@ -387,6 +387,7 @@ else
        # define default modules to load
        declare -a pureline_modules=(
        'host_module        Yellow      Black       false'
+       'newline_module'
        'path_module        Blue        Black       0'
        'read_only_module   Red         White'
        )
bash-4.3$ source pureline                
 Darknet 
 /tmp/pureline  
-------------------------------- press ctrl+r -------------------------------------
bash-4.3$ source pureline                
 Darknet 
(reverse-i-search)`clo': git clone https://github.com/chris-marsh/pureline /tmp/pureline
-------------------------------- press escape, then move cursor to the left then to the right-----------------------
 Darknet 
 /tmp/pureline  git clone https://githubgit clone https://github.com/chris-marsh/pureline /tmp/pureline

Don't know why , but the line is clutter

Now, concerning adding the possibility to the user to define the background.
Add a module to fill the line :

function fillps1 {
       local bg_color=$1                  # Set the background color
       local fg_color=$2                  # Set the foregropund color
       PS1="${colors[${fg_color}]}${colors[On_${bg_color}]}$(printf "%$((${COLUMNS:=$(tput cols)} - 1))s")${colors[${bg_color}]}${colors['On_Default']}${symbols[hard_separator]}\e[0m\033[0G${PS1}"
       unset __last_color
}
$  env -i bash --noprofile --norc --login
bash-4.3$ cd /tmp/pureline/                     
bash-4.3$ git rev-parse HEAD                    
1e44b57a67e9a5ab1c81cfffd8e0d2c359eda807
bash-4.3$ git diff                              
WARNING: terminal is not fully functional
diff --git a/pureline b/pureline
index be03be1..04ce70b 100644
--- a/pureline
+++ b/pureline
@@ -380,13 +380,22 @@ declare -A symbols=(
 [behind]="-"
 )
 
+function fillps1 {
+       local bg_color=$1                  # Set the background color
+       local fg_color=$2                  # Set the foregropund color
+       PS1="${colors[${fg_color}]}${colors[On_${bg_color}]}$(printf "%$((${COLUMNS:=$(tput cols)} - 1))s")${colors[${bg_color}]}${colors['On_Default']}${symbols[hard_separator]}\e[0m\033[0G${PS1}"
+       unset __last_color
+}
+
 # check if an argument has been given for a config file
 if [ -f "$1" ]; then
        source $1
 else
        # define default modules to load
        declare -a pureline_modules=(
+       'fillps1        Green   Yellow'
        'host_module        Yellow      Black       false'
+       'newline_module'
        'path_module        Blue        Black       0'
        'read_only_module   Red         White'
        )
bash-4.3$ source pureline                       

You will get the same as my previous screenshot

http://imgur.com/2uIYh7dl.png

Base automatically changed from master to main February 15, 2021 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants