ramnes / context-color Goto Github PK
View Code? Open in Web Editor NEW:rainbow: To each context its own shell color
License: GNU General Public License v3.0
:rainbow: To each context its own shell color
License: GNU General Public License v3.0
https://www.shellcheck.net/ suggests some issues:
In context-color line 19:
readonly PROGNAME=$(basename $0)
^-- SC2086: Double quote to prevent globbing and word splitting.
In context-color line 49:
expr 1 + "$(__context_color_hash)" % \( "$(__context_color_count)" - 1 \)
^-- SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
In context-color line 53:
local capname="setaf"
^-- SC2039: In POSIX sh, 'local' is undefined.
In context-color line 60:
local sequence="$(tput $capname $(__context_color_number))"
^-- SC2039: In POSIX sh, 'local' is undefined.
^-- SC2155: Declare and assign separately to avoid masking return values.
^-- SC2046: Quote this to prevent word splitting.
In context-color line 77:
local delim=""
^-- SC2039: In POSIX sh, 'local' is undefined.
^-- SC2034: delim appears unused. Verify it or export it.
In context-color line 97:
eval set -- $args
^-- SC2086: Double quote to prevent globbing and word splitting.
In context-color line 118:
echo -n "$(__context_color_sequence)"
^-- SC2039: In POSIX sh, echo flags are undefined.
Hello,
I've experienced an issue that I didn't notice first:
When using the classic $(context-color) command for customizing my prompt like this:
PS1='[\d \A] \[\e[31m\]\u\[\e[0m\]@\[\e[0m\]$(context-color -c hostname)\h\[\e[0m\]:\w\\$ '
The prompt always used 1 line for big command lines; E.g long lines are wrapped around themselves, meaning that the new line overlaps the previous one. So the terminal wasn't usable anymore.
I figured this was a classic issue with PS1 customization and it is because the colour code wasn't wrapped inside brackets as in \[\e[31m\]
where the colour code \e[31m
is wrapped inside \[ \]
. So to sort this problem out I just changed $(context-color -c hostname)
to \[$(context-color -c hostname)\]
and it worked fine.
I don't know if this is normal and expected behavior?
โฆ with bats, maybe?
Edit: bats now lives at https://github.com/bats-core/bats-core
Great script, it would be good for a --safe option or similar to make Root and all its text output RED.
This maybe enforces red for danger when using root.
This looks great!
A simple question: Do I need to add the
export PS1="$(context-color -p)$PS1\[\e[0m\]"
line to the ~/.bashrc
of every user I might be su
'ing as?
Thanks.
$ context-color -c 'echo hi'
$ context-color -c "date" -p
\[\]
Running export PS1="$(context-color -p)$PS1\[\e[0m\]"
does not seem to change my current prompt colors. From the README, I thought it would change them immediately. I'm not really sure why it didn't.
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
Ubuntu 17.10
$ context-color --command "date"
Illegal option --
/home/user/bin/context-color: 1: eval: ommand: not found
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
ubuntu 17.10
I use black backgrounds, but it's possible to get black foreground context colors, which makes text hard to read. Is it possible to avoid black?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.