Repository navigation
Expand file tree
/
Copy path_mixrc
More file actions
45 lines (41 loc) · 1.5 KB
/
Copy path_mixrc
File metadata and controls
45 lines (41 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- ~/.rc/_mixrc — public Mix shell toolkit (wrapper)
--
-- Sourced from ~/.mixrc (the user's personal trampoline; bash-parallel
-- to ~/.bashrc → ~/.sh/_shrc). Provides shell-foundational env that the
-- _lib/ topic modules can rely on ($ostyp, $SUDO, $HOME), then
-- glob-loads ~/.rc/_lib/*.mix in lexical order.
--
-- This file is the public, shareable wrapper. No machine-local content,
-- no secrets. User additions go in ~/.mixrc (machine-local, not in git)
-- or in topic modules dropped into ~/.rc/_lib/ that the user owns.
--
-- The mix binary itself lives in the sibling repo github.com/markc/mix;
-- see README.md for the full manual and install steps.
$HOME = env("HOME")
-- OS detection (ini-parse /etc/os-release; modules key off $ostyp)
$ostyp = "unknown"
if is_file("/etc/os-release") then
$os_info = ini_parse(read_file("/etc/os-release"))
if has_key($os_info, "_global") then
$os_id = $os_info["_global"]["ID"]
if $os_id != nil and $os_id != "" then
$ostyp = $os_id
end
end
end
-- SUDO prefix when non-root (string; functions use as ${SUDO}systemctl ...)
$uid = trim(sh "id -u")
if $uid != "0" then
$SUDO = "/usr/bin/sudo "
else
$SUDO = ""
end
-- Glob-load topic modules. Lexical sort (verified) means NN- prefix
-- controls order: 10-path → 20-aliases → 30-pkgmgr → 40-ssh-hosts →
-- 50-tools → 60-prompt → 70-functions.
$rc_lib = "${HOME}/.rc/_lib"
if is_dir($rc_lib) then
for each $f in glob("${rc_lib}/*.mix")
source $f
end
end