vim, gitconfig, update.sh
[dotfiles_afify.git] / .scripts / format_usb.sh
blob5a19e87601eb990838ec2e74f422ea5eb34fccc8
1 #!/bin/sh
3 usb=$(lsblk --noheadings --raw -o NAME,SIZE |\
4 awk '$1~/sd[a-z]$/' |\
5 dmenu -i -p "choose disk"|\
6 awk '{print $1}')
7 if [ ! "$usb" ]; then exit;fi
9 wipe=$(printf "no\nyes" |\
10 dmenu -p "WARNING wipe $usb" -nb "#000" -nf "#FFF" -sb "#FF0000" -sf "#FFF")
12 dmenu -P -p "sudo " |\
13 sudo -S -- sh -c "if [ $wipe = yes ] ; then\
14 dd bs=4M if=/dev/urandom of=/dev/$usb status=progress oflag=sync;fi;\
15 printf \"o\nn\np\n1\n2048\n\nw\n\" | sudo fdisk /dev/$usb;\
16 sudo mkfs.ext4 /dev/${usb}1 && notify-send 'formated ''$usb'"