diff --git a/cli/cli.odin b/cli/cli.odin index 382ec57..ec4faf8 100644 --- a/cli/cli.odin +++ b/cli/cli.odin @@ -14,9 +14,7 @@ import "core:sys/posix" import "core:path/filepath" import "core:unicode/utf8" -INPUT_MAX :: 4096 -HISTORY_MAX :: 2048 -HISTORY_FILE :: "skal.history" +import "../config" History :: struct { data: [dynamic][]rune, @@ -50,7 +48,7 @@ init_cli :: proc () { home_path := string(posix.getenv("HOME")) log.assertf(home_path != "", "Home path not found") - term.history.file = filepath.join({home_path, HISTORY_FILE}, context.allocator) + term.history.file = filepath.join({home_path, config.HISTORY_FILE}, context.allocator) log.assertf(mem_err == nil, "Memory allocation failed") USER_PERMISSIONS :: 0o600 @@ -112,7 +110,17 @@ get_prompt_prefix :: proc() -> string { user = string(pw.pw_name) } - prompt_parts := []string {user, " :: ", dir, " » "} + prompt_parts := []string { + config.USER_COLOR, + user, + config.DETAILS_COLOR, + " :: ", + config.DIR_COLOR, + dir, + config.DETAILS_COLOR, + " » ", + config.BASE_COLOR} + prompt, err := strings.concatenate(prompt_parts[:], context.temp_allocator) log.assertf(err == nil, "Memory allocation failed") diff --git a/config/config.odin b/config/config.odin new file mode 100644 index 0000000..57f5d43 --- /dev/null +++ b/config/config.odin @@ -0,0 +1,7 @@ +package config + +HISTORY_FILE :: "skal.history" +USER_COLOR :: "\x1b[0m" +DETAILS_COLOR :: "\x1b[34m" +DIR_COLOR :: "\x1b[32m" +BASE_COLOR :: "\x1b[0m" diff --git a/shell/shell.odin b/shell/shell.odin index 79f855c..19ba41c 100644 --- a/shell/shell.odin +++ b/shell/shell.odin @@ -10,6 +10,7 @@ import "core:log" import "../parser" import "../cli" +import "../config" ShellState :: enum { Continue, @@ -40,7 +41,7 @@ handle_backround_process :: proc"c"(sig: posix.Signal) { if background_pid > 0 && background_pid != foreground_pid { fmt.printf("skal: [%d] done", background_pid) - // Clear prompt + // todo: skip and redraw prompt with input } if foreground_pid == background_pid {