mirror of
https://codeberg.org/Mo8it/dotfiles.git
synced 2025-01-01 15:39:20 +00:00
Add xonsh update script
This commit is contained in:
parent
ec44964baa
commit
d4c812980b
1 changed files with 49 additions and 0 deletions
49
.scripts/update.xsh
Normal file
49
.scripts/update.xsh
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env xonsh
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
def get_out(out_obj):
|
||||||
|
for line in out_obj:
|
||||||
|
print(line, end="")
|
||||||
|
|
||||||
|
return out_obj.out.split("\n")
|
||||||
|
|
||||||
|
def press_to_exit():
|
||||||
|
read -s -n 1 -p "Exit"
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if $ARG1 == "rpm-ostree":
|
||||||
|
out = get_out(!(rpm-ostree upgrade | tee))
|
||||||
|
|
||||||
|
if out[-2] != "No upgrade available.":
|
||||||
|
press_to_exit()
|
||||||
|
elif $ARG1 == "flatpak":
|
||||||
|
flatpak update -y
|
||||||
|
flatpak remove --delete-data --unused
|
||||||
|
elif $ARG1 == "pipx":
|
||||||
|
out = get_out(!(pipx upgrade-all --include-injected | tee))
|
||||||
|
|
||||||
|
if "did not change" not in out[-2]:
|
||||||
|
press_to_exit()
|
||||||
|
elif $ARG1 == "cargo":
|
||||||
|
out = get_out(!(cargo install-update -a | tee))
|
||||||
|
|
||||||
|
pattern = r"updated (\d+) packages"
|
||||||
|
match = re.search(pattern, out[-2])
|
||||||
|
|
||||||
|
if match is None:
|
||||||
|
press_to_exit()
|
||||||
|
return
|
||||||
|
|
||||||
|
num_updated_packages = match.group(1)
|
||||||
|
|
||||||
|
if num_updated_packages != "0":
|
||||||
|
press_to_exit()
|
||||||
|
elif $ARG1 == "npm":
|
||||||
|
npm update -g
|
||||||
|
elif $ARG1 == "nvim":
|
||||||
|
nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerSync"
|
||||||
|
else:
|
||||||
|
print(f"{$ARG1} not found!")
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in a new issue