# #### config for login mode
# only login mode need PATH, other mode will retrieve it from parent shell.
if IS_LOGIN {
set PATH = '/usr/local/bin:/usr/bin:/bin'
}
# #### config for interactive mode
if IS_INTERACTIVE {
# ## ---appearance---
let logo = '
⚡┓
┃ ┓┏┏┳┓┏┓
┗┛┗┻┛┗┗┗ '
print logo.clr(rand.int(1,230)) 'lightweight'.clr(38) 'ultimate'.clr(48) 'modern'.clr(51) 'efficient'.clr(45)
# ## welcome msg
# set LUME_WELCOME= 'Welcome to Lumesh!'
# ## prompt
# template could be normal expression or func.
# avaluable tmplate var: $CWD, $CWD_SHORT, $CFM_TAG, $STRICT_TAG, $STATUS, $DURATION, $JOBS
# if template is lambda/func, it will be evaluated everytime.
# avaluable fields in ctx: cfm,strict,status,duration,jobs
set LUME_PROMPT_SETTINGS = {
starship: 0,
lazy: 0,
continuation: "... ",
template: string.blue('$CWD_SHORT') + '|' + string.green('$CFM_TAG') + '|' + string.blue('$STRICT_TAG') + '❯ '.bold().yellow(),
# template: (dir,ctx) -> {
# string.blue($dir) + ' |'.green().bold() \
# + ($ctx.cfm ? 'CFM'.green() + '|' : '') \
# + ($ctx.strict ? 'S'.yellow() + '| ' : '' ) \
# + (if (fs.exists '.git') {git branch --show-current | .cyan()} else '') \
# + '> '.green().bold()
# }
}
# ## base theme for syntax: 'one_dark', 'ayu_dark', 'light'
LUME_THEME = 'ayu_dark'
# ## syntax theme modify
# LUME_THEME_CONFIG = {
# keyword: "\x1b[38;5;75m",
# operator: COLOR.violet,
# ...
# }
# LUME_EDITOR_THEME = {
# hint : "grey",
# completion_bg : "black",
# completion_fg : "dark_yellow",
# completion_selected_bg : "red",
# completion_selected_fg : "white"
# }
# ## ---interactive---
# ## default strict mode
# set LUME_STRICT = true
# ## default cmd_frist_mode
# set LUME_CFM = none
# ## history file
# set LUME_HISTORY_FILE = '/tmp/lume_histroy'
# == completion
# set LUME_COMPLETION_DIR = '~/Library/Application Support/completions'
set LUME_COMPLETION_CYCLE = false
# ## report compute result type and values. default true.
# set LUME_PRINT_DIRECT= false
# ## sudo cmd for Alt+s
# set LUME_SUDO_CMD = 'doas'
# ## key bindings
# ## key bindings
# Key format: "MODIFIER_key" (order CTRL_ALT_SHIFT: e.g., "CTRL_ALT_k", "CTRL_q", "ALT_h")
# Value type:
# String -> inserts text into current line
# lambda/function -> executes immediately with environment access
# fn receive one arg as current buffer.
# ### cmdmark manage
let save_cmdmark = (b) -> {if !$b {b = ui.text('mark cmd:')}; $b.trim()+"\n" >> '~/.cache/lumesh/cmdmark'; println "\t[MARKED]"}
let select_cmdmark = (b) -> { fs.read ~/.cache/lumesh/cmdmark ?! | .lines() | ui.pick('select cmdmark:') }
let save_dirmark = (b) -> if !fs.read(~/.cache/lumesh/dirmark).lines().contains(cwd()) ?: true { cwd()+"\n" >> '~/.cache/lumesh/dirmark'; println "\t[MARKED]"}
let select_dirmark = (b) -> { fs.read ~/.cache/lumesh/dirmark ?! | .lines() | ui.pick('select dirmark:') | 'cd ' + _ }
let timestamp = "'" + time.now().to_string('%Y-%m-%d %H:%M:%S') + "'"
let fix_typos = (b) -> $b.replace('gerp', 'grep').replace('mroe', 'more').replace('les', 'less')
# ### menu
fn menu(b){
let m = {
save_cmdmark,
select_cmdmark,
save_dirmark,
fix_typos
}
let ex = { ui.pick $m.keys() 'Fuzzy Execute' ?! | $m.at() }
ex($b)
} #?: e -> eprint e.msg
# ## binding
set LUME_HOT_BINDINGS = {
CTRL_q: 'exit',
ALT_m: save_cmdmark,
CTRL_SHIFT_M: select_cmdmark,
CTRL_SHIFT_D: select_dirmark,
ALT_e: fix_typos,
CTRL_SHIFT_t: timestamp,
'CTRL_/': menu,
}
# ### functions for slash bindings
let select_cmdmark = (b) -> { fs.read ~/.cache/lumesh/cmdmark ?! | .lines() | ui.pick('select cmdmark:') | eval_str() }
let select_dirmark = (b) -> { fs.read ~/.cache/lumesh/dirmark ?! | .lines() | ui.pick('select dirmark:') | cd _ }
let fuzzy_go = (b) -> {let base = $b ~: g'~|/' ? $b : './'; let max = $b == '/' ? 2 : 5; fd -t d --max-depth $max . $base | ui.pick('Fuzzy Go:') ?! | cd _}
let open_file = (b) -> {fd -t file | ui.pick('select file:') ?! | open -- _}
let edit_file = (b) -> {let e = sys.has('EDITOR') ? $EDITOR : 'vi'; fd -t file | ui.pick('edit file:') | $e _}
let search_content = (b) -> {
let t = len($b)>0 ? $b : ui.text 'search in filetype:' ?: 'all'
ui.text 'search:' | rg -t $t --line-number --column --no-heading --smart-case --color=never -- _ | ui.pick 'select' ?! | .split(':') | .at(0) | open -- _
}
let git_commit = (b) -> {
git add -A;
ui.text('commit message:') ?! | git commit -m _
}
# ## use `/key arg`to execute; `/hist`,`/history`,`/cds`,`/q` already builtin, never use these keys
set LUME_SLASH_BINDINGS = {
sm: save_cmdmark,
sd: save_dirmark,
m: select_cmdmark,
d: select_dirmark,
g: fuzzy_go,
o: open_file,
e: edit_file,
sc: search_content,
cm: git_commit,
}
# ## use `/` to execute menu
# `/ query` for fuzzy jump already builtin
fn LUME_SLASH_MENU(){
let m = {
save_cmdmark,
save_dirmark,
select_cmdmark,
select_dirmark,
fuzzy_go,
open_file,
edit_file,
search_content,
git_commit,
}
let ex = { ui.pick $m.keys() 'Fuzzy Execute' ?! | $m.at() }
if ex {ex('')}
} ?: e -> print e.msg
# ## abbreviations
set LUME_ABBREVIATIONS = {
o: 'open',
bi: 'brew install',
bs: 'brew search',
bu: 'brew update',
bg: 'brew upgrade',
xr: 'brew uninstall',
}
# ## alias
alias int = into.int()
alias str = into.string()
alias each = list.map()
alias table = into.table()
alias join = list.join()
alias fopen = fs.read()
alias fls = fs.ls('-l')
alias fmv = fs.mv()
alias frm = fs.rm()
alias fcp = fs.cp()
alias fhead = fs.head()
alias ftail = fs.tail()
alias doc = open https://www.lumesh.cc.cd
alias config = vi about.info().prelude
# ## ---ai---
# ## default AI Helper settings. following is default.
let base = fs.dir_name($SCRIPT)
let syntax = fs.read($base + '/syntax.md')
set LUME_AI_CONFIG = {
# host: 'localhost:11434',
# api_key: '',
# model: '',
# chat_url: '/v1/chat/completions',
# complete_max_tokens: 10,
# chat_max_tokens: 100,
# hint_prompt: '',
# chat_prompt: '',
syntax,
}
# ## ---update---
# uncomment this if you have lman installed.
# use lman
# fn update() {
# lman::update()
# }
}
# else {
# #### config for script mode
# }
# #### config for all mode
PATH = '~/.local/bin:' + $PATH ?.
# IFS affect: 0:never; 2:cmd args; 4:for; 8:string.split; 16:csv; 32:pick; 62:all
set LUME_IFS_MODE=2
# set LUME_MODULES_PATH = ~/Library/Application Support/lumesh/mods
# set LUME_MAX_SYNTAX_RECURSION = 100
# set LUME_MAX_RUNTIME_RECURSION = 800