forked from sl-sh-dev/sl-sh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.slosh
More file actions
42 lines (31 loc) · 1.24 KB
/
Copy pathinit.slosh
File metadata and controls
42 lines (31 loc) · 1.24 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
(prn (version))
(prn "Using default slshrc written to \"~/.config/slosh/init.slosh\".")
(prn "Edit this file to remove this message and customize your shell")
; load the core lib
(load "core.slosh")
(defn parse-git-branch () (let (branch ($sh "git rev-parse --abbrev-ref HEAD 2>/dev/null"))
(if (equal? branch "")
(str "")
(str "(" branch ")"))))
(defn get-pwd ()
(str-replace (env 'PWD) (env 'HOME) "~"))
(defn set-prompt-tail (last-status)
(let (
debug (if (str-contains (version) "debug") "[DEBUG]" "")
status (if (= last-status 0) "" (str "\x1b[31m(" last-status ")\x1b[39m"))
)
(if (= *euid* 0)
(str "\x1b[31m" status "\n\x1b[31m" debug "λ #\x1b[39m ")
(str "\x1b[32m" status "\n\x1b[32m" debug "λ >\x1b[39m "))))
(def *ns* "SLOSH")
(defn __prompt ()
(str "\x1b[32m[" *ns* "]:" (env "HOST") ":\x1b[34m" (str-trim! (get-pwd)) "/\x1b[37m" (parse-git-branch) (set-prompt-tail *last-status*)))
(sh "alias ls='/bin/ls --color -F'")
(sh "alias ll='/bin/ls --color -Falh'")
(sh "alias vi=nvim")
(sh "alias vim=nvim")
(sh "export PATH=/bin:/usr/local/bin:~/bin:~/.cargo/bin")
(sh "export LC_ALL=en_US.UTF-8")
; load and activate syntax highlighting on the prompt
(load "sh-color.slosh")
(syntax-on)