2021-09-16 21:53:45 +02:00
|
|
|
#!/usr/bin/env lua
|
|
|
|
local function run(cmd)
|
|
|
|
-- check if the command exists
|
|
|
|
local pname = cmd:gmatch("%S+")()
|
|
|
|
local handle = io.popen("which " .. pname .. " 2> /dev/null")
|
|
|
|
handle:read("*a")
|
|
|
|
_, _, exit_code = handle:close()
|
|
|
|
|
|
|
|
if exit_code == 0 then
|
2021-09-17 17:52:48 +02:00
|
|
|
-- 8 is len of text around "running" prompt
|
|
|
|
local len = #cmd + 8
|
|
|
|
local hr = string.rep("=", len)
|
|
|
|
|
|
|
|
print(
|
|
|
|
string.format(
|
|
|
|
"%s\nrunning \27[32m%s\27[0m\n%s\n",
|
|
|
|
hr,
|
|
|
|
cmd,
|
|
|
|
hr
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2021-09-16 21:53:45 +02:00
|
|
|
os.execute(cmd)
|
|
|
|
else
|
|
|
|
print("\27[31mCouldn't find process with name " .. pname .. "\27[0m in path.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- commands that require interaction
|
|
|
|
local function run_fg()
|
|
|
|
run [[nvim '+:PackerSync' '+:CocUpdate' '+:TSUpdate']]
|
|
|
|
end
|
|
|
|
|
|
|
|
-- commands that require no interaction
|
|
|
|
local function run_bg(args)
|
|
|
|
run [[paru -Syu --noconfirm]]
|
|
|
|
run [[rustup update]]
|
2021-09-17 00:24:45 +02:00
|
|
|
run [[fw sync]]
|
2021-09-16 21:53:45 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- if "bg" was passed as argument, only run uninteractive commands
|
|
|
|
if arg[1] ~= "bg" then
|
|
|
|
run_fg()
|
|
|
|
end
|
|
|
|
|
|
|
|
run_bg()
|
|
|
|
|