pureline icon indicating copy to clipboard operation
pureline copied to clipboard

Add a way to dim specific exit codes

Open lynxhug opened this issue 5 years ago • 2 comments
trafficstars

I'm using terminal inside Dolphin so there is always 130 exit code in terminal panel when you change directory by clicking it. This commit is adding functionality to change color of return code module for specific exit codes to a different from specified in config file. Basically to grey out Control-C interrupt. With undefined new variables script will operate without changes.

lynxhug avatar May 17 '20 22:05 lynxhug

Sorry I've not been very active here over the past while, but eventually coming back to PureLine and the PRs :)

I like the idea of dimming, but I'm thinking it might be simpler to not show 130's?

function return_code_segment {                                                                                                                                                                 
    [[ ${__return_code} -eq 0 || ${__return_code} -eq 130 ]] && return                                                                                                                         
                                                                                                                                                                                               
    local bg_color="$1"                                                                                                                                                                        
    local fg_color="$2"                                                                                                                                                                        
    local content rc_symbol                                                                                                                                                                    
    pl_symbol rc_symbol 'return_code'                                                                                                                                                          
    content="${rc_symbol} ${__return_code}"                                                                                                                                                    
    add_segment "$content" "$fg_color" "$bg_color"                                                                                                                                             
    __return_code=0                                                                                                                                                                            
} 

chris-marsh avatar Mar 08 '21 21:03 chris-marsh

Completely hide exit code could be a problem if some other program use it for some reason rather than leaving it for the shell to signal that program was terminated by user. Also for confirmation sake i still want to know that any other programs that i do interrupt with ctrl+c is returning 130 exit code and not 0 for some reason. Probably very low chance for both occurrences but i would still prefer that no exit code on pureline will mean only 0 exit code.

lynxhug avatar Mar 13 '21 09:03 lynxhug