Skip to content

Instantly share code, notes, and snippets.

@ser1zw
Last active December 11, 2023 00:53
Show Gist options
  • Save ser1zw/3c34f7ebe18214f2696dc0548198c8d2 to your computer and use it in GitHub Desktop.
Save ser1zw/3c34f7ebe18214f2696dc0548198c8d2 to your computer and use it in GitHub Desktop.
update-allenv
#!/usr/bin/env python
import os
import subprocess
HOMEDIR = os.getenv('HOME')
GIT_COMMAND = 'git pull --rebase origin master'
git_clone_dirs = ['.rbenv', '.rbenv/plugins/ruby-build', '.pyenv']
brew_commands = ['perlbrew self-upgrade', 'perlbrew -f install-cpanm', 'nodebrew selfupdate']
for dir in [HOMEDIR + '/' + d for d in git_clone_dirs]:
os.chdir(dir)
s = subprocess.check_output(GIT_COMMAND.split(' ')).strip()
print(s.decode())
for c in brew_commands:
s = subprocess.check_output(c.split(' ')).strip()
print(s.decode())
#!/bin/bash
set -euo pipefail
GIT_PULL_DIRS=$(cat <<EOS
/home/seri/.rbenv
/home/seri/.rbenv/plugins/ruby-build
/home/seri/.pyenv
EOS
)
SPECIFIC_UPGRADE_COMMANDS=$(cat <<EOS
nodebrew selfupdate
EOS
)
for dir in $(echo ${GIT_PULL_DIRS}); do
(
cd ${dir}
git pull --rebase origin $(git branch --show-current)
)
done
IFS=$'\n'
for cmd in $(echo ${SPECIFIC_UPGRADE_COMMANDS}); do
/bin/bash -c ${cmd}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment