Skip to content

Instantly share code, notes, and snippets.

@jedahan
Created March 19, 2017 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedahan/9d1f609504a8362efc8bed2a5ab78e3c to your computer and use it in GitHub Desktop.
Save jedahan/9d1f609504a8362efc8bed2a5ab78e3c to your computer and use it in GitHub Desktop.
weird update script
function up { # upgrade everything
uplog=$(mktemp -t up.XXXXXX)
(($+commands[tmux])) && {
tmux select-window -t update 2>/dev/null || tmux rename-window update
tmux split-window -d -p 40 -t update "echo  $uplog; tail -f $uplog"
}
function fun { (( $+functions[$1] || $+commands[$1] )) && echo -n "updating $2..." }
fun config 'dotfiles' && { config pull } &>> $uplog && c <<< 
fun zpm 'zsh plugins' && { zpm update } &>> $uplog && c <<< ▲
fun tldr 'tldr' && { tldr --update } &>> $uplog && c <<< ⚡
fun brew 'brews' && { brew upgrade; brew cleanup } &>> $uplog && c <<< 
fun nvim 'neovim' && { nvim +PlugUpdate! +PlugClean! +qall } &>> $uplog && c <<< 
fun rustup 'rust' && { rustup update stable; rustup update beta } &>> $uplog && c <<< 
fun cargo 'crates' && { cargo install-update --all } &>> $uplog && c <<< 
s 'Updated!\s+(.+/.+)' -r '$1' -N $uplog
s 'Upgrading' -A1 -N $uplog | head -2 | tail -1
s 'updated.*rustc' -N $uplog | cut -d' ' -f7 | paste -s -
s '(.*)Yes$' --replace '$1' $uplog
(($+commands[tmux])) && tmux kill-pane -t 0:update.-1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment