pureline icon indicating copy to clipboard operation
pureline copied to clipboard

let the user choose background color for newline module

Open rockandska opened this issue 7 years ago • 2 comments

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 :

rockandska avatar May 27 '18 21:05 rockandska

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 https://github.com/chris-marsh/pureline/pull/11 ?

chris-marsh avatar Jun 24 '18 14:06 chris-marsh

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

rockandska avatar Jun 24 '18 16:06 rockandska