mirror of https://github.com/ericonr/ep.git
Use color support where appropriate.
Color choice might still be refined, as could support for 8 bit colors.
This commit is contained in:
parent
765316cf81
commit
089bb40acc
9
ep.c
9
ep.c
|
@ -15,6 +15,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
#include "info_strings.h"
|
#include "info_strings.h"
|
||||||
#include "ep.h"
|
#include "ep.h"
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ int main(int argc, char **argv)
|
||||||
/* show we are on a different machine */
|
/* show we are on a different machine */
|
||||||
print_ssh();
|
print_ssh();
|
||||||
|
|
||||||
print_pwd(home, pwd);
|
use_color(bcyan, print_pwd(home, pwd));
|
||||||
|
|
||||||
/* git status */
|
/* git status */
|
||||||
void *git_info;
|
void *git_info;
|
||||||
|
@ -117,7 +118,7 @@ int main(int argc, char **argv)
|
||||||
if (n > 1) {
|
if (n > 1) {
|
||||||
/* jobs emoji is wide */
|
/* jobs emoji is wide */
|
||||||
p(" ");
|
p(" ");
|
||||||
p(shell_jobs);
|
use_color(blue, p(shell_jobs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,13 +141,13 @@ int main(int argc, char **argv)
|
||||||
} else {
|
} else {
|
||||||
snprintf(dur, sizeof(dur), " %llds", command_duration);
|
snprintf(dur, sizeof(dur), " %llds", command_duration);
|
||||||
}
|
}
|
||||||
p(dur);
|
use_color(green, p(dur));
|
||||||
}
|
}
|
||||||
/* 127 means command not found, that prints a big enough message already */
|
/* 127 means command not found, that prints a big enough message already */
|
||||||
if (exit_status && exit_status != 127) {
|
if (exit_status && exit_status != 127) {
|
||||||
char ex[256];
|
char ex[256];
|
||||||
snprintf(ex, sizeof(ex), " [%d]", exit_status);
|
snprintf(ex, sizeof(ex), " [%d]", exit_status);
|
||||||
p(ex);
|
use_color(green, p(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
p(PROMPT);
|
p(PROMPT);
|
||||||
|
|
5
git.c
5
git.c
|
@ -5,6 +5,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
#include "ep.h"
|
#include "ep.h"
|
||||||
|
|
||||||
struct git_info {
|
struct git_info {
|
||||||
|
@ -17,13 +18,15 @@ void print_git(void *arg)
|
||||||
|
|
||||||
if (git_info->git_branch_name) {
|
if (git_info->git_branch_name) {
|
||||||
p(" ");
|
p(" ");
|
||||||
p(git_info->git_branch_name);
|
use_color(magenta, p(git_info->git_branch_name));
|
||||||
|
|
||||||
|
fg_color(blue);
|
||||||
if (git_info->git_status) {
|
if (git_info->git_status) {
|
||||||
p(" [");
|
p(" [");
|
||||||
p(git_info->git_status);
|
p(git_info->git_status);
|
||||||
p("]");
|
p("]");
|
||||||
}
|
}
|
||||||
|
reset_color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
lang.c
4
lang.c
|
@ -4,6 +4,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
#include "ep.h"
|
#include "ep.h"
|
||||||
|
|
||||||
enum lang_index {
|
enum lang_index {
|
||||||
|
@ -49,11 +50,14 @@ const struct lang_check l[] = {
|
||||||
|
|
||||||
/* bitmap of 1<<lang_index */
|
/* bitmap of 1<<lang_index */
|
||||||
void print_lang(uint64_t mask) {
|
void print_lang(uint64_t mask) {
|
||||||
|
/* only change color if we're going to print something */
|
||||||
|
if (mask) fg_color(red);
|
||||||
for (int i = 0; i < lang_index_n; i++) {
|
for (int i = 0; i < lang_index_n; i++) {
|
||||||
if (mask & (1 << i)) {
|
if (mask & (1 << i)) {
|
||||||
p(l[i].display);
|
p(l[i].display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mask) reset_color();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *lang_thread(void *arg)
|
void *lang_thread(void *arg)
|
||||||
|
|
3
ssh.c
3
ssh.c
|
@ -1,6 +1,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
#include "ep.h"
|
#include "ep.h"
|
||||||
|
|
||||||
void print_ssh(void)
|
void print_ssh(void)
|
||||||
|
@ -16,8 +17,10 @@ void print_ssh(void)
|
||||||
if (uname(&u) || !u.nodename[0])
|
if (uname(&u) || !u.nodename[0])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
fg_color(yellow);
|
||||||
p("(");
|
p("(");
|
||||||
p(u.nodename);
|
p(u.nodename);
|
||||||
p(") ");
|
p(") ");
|
||||||
|
reset_color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue