Shell: Load a different rc file when in POSIX mode

This commit is contained in:
Ali Mohammad Pur 2023-03-20 16:49:10 +03:30 committed by Andreas Kling
parent 832478ad0c
commit d997b794fa
Notes: sideshowbarker 2024-07-18 03:35:30 +09:00
3 changed files with 48 additions and 2 deletions

39
Base/etc/posixshrc Normal file
View File

@ -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"

View File

@ -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; }

View File

@ -232,8 +232,13 @@ ErrorOr<int> 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();
}