Skip to content

Instantly share code, notes, and snippets.

@maxwellb
Created December 20, 2018 21:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxwellb/2e275b740951385a448eaa5e90116d95 to your computer and use it in GitHub Desktop.
Save maxwellb/2e275b740951385a448eaa5e90116d95 to your computer and use it in GitHub Desktop.
clear-motd
#!/usr/bin/env bash
# To use set the follow alias in your .bash_profile or .bashrc
# and then save this file as ~.motd, and chmod +x on it.
#
# alias clear='clear && ([ -x ~/.motd ] && ~/.motd || true) || ([ -f ~/.motd ] && cat ~/.motd)'
#
# Copyright (c) 2018 Maxwell Bloch, MIT licensed
#
echo `df -h ~ | xargs echo | cut -d' ' -f12` used, `df -h ~ | xargs echo | cut -d' ' -f11` free on \$HOME
pushd ~ >/dev/null
# [ ! -z `which npm` ] && cat <<-END | while read r; do [ -d node_modules/$r ] || npm i --no-package-lock $r >/dev/null 2>/dev/null; done
# tfunk
# END
[ ! -z `which npm` ] && sed -rne 's;.*require\(\s*[''"](.*?)[/"''].*;\1;p' ~/.motd | while read r; do
[ -d node_modules/$r ] || npm i --no-package-lock $r >/dev/null 2>/dev/null
done
[ ! -z `which node` ] && tail -n +$((`grep -n -e '^### MOTD' ~/.motd | cut -d: -f1` + 1)) ~/.motd | node
popd >/dev/null
exit 0
### MOTD node script below here
const tfunk=require("tfunk");
function $() { console.log(tfunk.apply(null, arguments)); }
$(`
{yellow:${new Date().toLocaleString("en-US", {timeZone: "America/New_York"})}
`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment