Fix comment and color for valid command, while change histfile name

This commit is contained in:
Night Kaly 2024-10-27 01:43:44 +01:00
parent 77855ac6f9
commit 7fcaa3ba9b
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
2 changed files with 4 additions and 4 deletions

View file

@ -1,7 +1,7 @@
#ifndef CONSTANTS_H_
#define CONSTANTS_H_
#define HISTFILE ".90s_history" // history file name
#define HISTFILE "90s_history" // history file name
#define TOK_BUFSIZE 64 // buffer size of each token
#define RL_BUFSIZE 1024 // size of each command
#define TOK_DELIM " \t\r\n\a" // delimiter for token

View file

@ -124,15 +124,15 @@ void highlight(char *buffer, char **paths) {
if (valid) {
if (command_without_arg != NULL) {
buffer += cmd_len;
printf("\x1b[38;2;137;180;250m%s\x1b[0m\x1b[38;2;255;255;255m%s\x1b[0m", command_without_arg, buffer); // print green as valid command, but only color the command, not the arguments
printf("\x1b[38;2;166;227;161m%s\x1b[0m\x1b[38;2;255;255;255m%s\x1b[0m", command_without_arg, buffer); // print green as valid command, but only color the command, not the arguments
buffer -= cmd_len;
} else {
printf("\x1b[38;2;137;180;250m%s\x1b[0m", buffer); // print green as valid command
printf("\x1b[38;2;166;227;161m%s\x1b[0m", buffer); // print green as valid command
}
} else {
if (command_without_arg != NULL) {
buffer += cmd_len;
printf("\x1b[38;2;243;139;168m%s\x1b[0m\x1b[38;2;255;255;255m%s\x1b[0m", command_without_arg, buffer); // print green as valid command, but only color the command, not the arguments
printf("\x1b[38;2;243;139;168m%s\x1b[0m\x1b[38;2;255;255;255m%s\x1b[0m", command_without_arg, buffer); // print red as invalid command, but only color the command, not the arguments
buffer -= cmd_len;
} else {
printf("\x1b[38;2;243;139;168m%s\x1b[0m", buffer); // print red as invalid command