From d997b794fad3c93508985f40a135f2a2b6deb24b Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 20 Mar 2023 16:49:10 +0330 Subject: [PATCH] Shell: Load a different rc file when in POSIX mode --- Base/etc/posixshrc | 39 +++++++++++++++++++++++++++++++++++++++ Userland/Shell/Shell.h | 2 ++ Userland/Shell/main.cpp | 9 +++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 Base/etc/posixshrc diff --git a/Base/etc/posixshrc b/Base/etc/posixshrc new file mode 100644 index 0000000000..ce4c9e8b19 --- /dev/null +++ b/Base/etc/posixshrc @@ -0,0 +1,39 @@ +#!sh + +alias fm=FileManager +alias mag=Magnifier +alias sh=Shell +alias tb=Taskbar +alias te=TextEditor +alias he=HexEditor +alias pp=PixelPaint +alias iv=ImageViewer +alias pi=Piano +alias calc=Calculator +alias calendar=Calendar +alias ins=Inspector +alias sp=SoundPlayer +alias help=Help +alias br=Browser +alias hs=HackStudio +alias sdb=Debugger +alias sm=SystemMonitor +alias pv=Profiler +alias ws=WebServer +alias ue=UserspaceEmulator +alias fe=FontEditor +alias ss=Spreadsheet +alias vp=VideoPlayer + +alias ll='ls -l' + +if [ "$(id -u)" = "0" ]; then + prompt_color=31 +else + prompt_color=32 +fi + +export PROMPT="\\X\\u@\\h:\\w\\a\\e[$prompt_color;1m\\h\\e[0m:\\e[34;1m\\w\\e[0m \\p " +export TMPDIR=/tmp + +PROGRAMS_ALLOWED_TO_MODIFY_DEFAULT_TERMIOS="stty" diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h index 544599278c..6ecf7cb989 100644 --- a/Userland/Shell/Shell.h +++ b/Userland/Shell/Shell.h @@ -92,6 +92,8 @@ class Shell : public Core::Object { public: constexpr static auto local_init_file_path = "~/.shellrc"; constexpr static auto global_init_file_path = "/etc/shellrc"; + constexpr static auto local_posix_init_file_path = "~/.posixshrc"; + constexpr static auto global_posix_init_file_path = "/etc/posixshrc"; bool should_format_live() const { return m_should_format_live; } void set_live_formatting(bool value) { m_should_format_live = value; } diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 9ef4136352..e01212bef4 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -232,8 +232,13 @@ ErrorOr serenity_main(Main::Arguments arguments) shell->run_file(file_path, false); } }; - run_rc_file(Shell::Shell::global_init_file_path); - run_rc_file(Shell::Shell::local_init_file_path); + if (posix_mode) { + run_rc_file(Shell::Shell::global_posix_init_file_path); + run_rc_file(Shell::Shell::local_posix_init_file_path); + } else { + run_rc_file(Shell::Shell::global_init_file_path); + run_rc_file(Shell::Shell::local_init_file_path); + } shell->cache_path(); }