From aeb88f527771460ceaca868dbe1b3fbcb2f82a64 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Thu, 16 Sep 2021 21:53:45 +0200 Subject: [PATCH] add sysupdate lua script --- scripts/sysupdate | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 scripts/sysupdate diff --git a/scripts/sysupdate b/scripts/sysupdate new file mode 100755 index 0000000..a315bc6 --- /dev/null +++ b/scripts/sysupdate @@ -0,0 +1,34 @@ +#!/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 + print("running \27[32m" .. cmd .. "\27[0m\n") + 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]] +end + +-- if "bg" was passed as argument, only run uninteractive commands +if arg[1] ~= "bg" then + run_fg() +end + +run_bg() +