Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Friday, 3 November 2017

playing music on hold when launching a bash command

 This works using MacOS afplay
!/bin/bash

moh_file=~/Downloads/moh.mp3

afplay $moh_file &
pid=$!
trap "kill $pid" 2

while read line; do echo -e $line; done


kill $pid


Usage:
$ long-running-command [args] | moh_player

If you want to retain colours, run it through script:
$ script -q /dev/null long-running-command [args] | moh_player

Tuesday, 28 March 2017

Ubuntu dev machine space management

Visualize filesystems usage:
df -h
Show disk usage of un/hidden folders
 du -sch .[!.]* * |sort -h


Find working kernel
uname -r
List installed kernels
dpkg --list | grep linux-image 


Sort and display packages size:
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
Completely delete a package
sudo apt-get purge packagename
Delete unused packages
sudo apt-get autoremove
Clean Apt cache
sudo apt-get clean


Brew cache cleanup
rm -rf $(brew --cache)
Brew uninstall
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

RVM
rvm uninstall ruby-2.3.3
Uninstall gems
gem uninstall -aIx

NPM cache cleanup
npm cache clean
Yarn (Node.js) cache cleanup
yarn cache clean