95 lines
5.0 KiB
Bash
95 lines
5.0 KiB
Bash
alias ISO-datestamps='echo -en "\n Searching for files ...\r"; for i in /dev/sd[a-z] $(du -ahx ~/ 2>&1 | grep -v "\.iso". | grep "\.iso"| cut -f2) $(du -ahx / 2>&1 | grep -v "\.iso". | grep "\.iso"| cut -f2); do string=$(sudo hexdump -Cs 33598 -n16 $i | head -1 | cut -f2 -d"|" | cut -c"1-14"); [ "$string" != "" ] && echo " $string $i" ; done | sort -u'
|
|
alias cgrep='grep --color=always'
|
|
alias date_of_iso='for i in ./*.iso ./*/*.iso /dev/sd[a-z]; do echo " $(sudo hexdump -C -s33598 -n16 $i 2>/dev/null |head -1 | cut -f2 -d"|" | cut -c-14) $i" ; done | sort'
|
|
alias grep='grep --color=auto'
|
|
alias gsettings-list-recursively='for i in $(gsettings list-schemas | sort); do echo $i | grep --color=always $i; gsettings list-recursively $i | sort -u ; done | uniq |less -R'
|
|
alias less='less -g'
|
|
alias locate='du -ah / 2>&1 | grep '
|
|
alias ls='ls --color=auto'
|
|
alias plot-boot='systemd-analyze plot > /tmp/boot_plot.svg ; x-www-browser file:///tmp/boot_plot.svg &'
|
|
alias show-gsettings='for i in $(gsettings list-schemas | sort); do echo $i | grep --color=always $i ; gsettings list-recursively $i | sort ; done | less -R'
|
|
alias snipe='du -ah ./ 2>&1 | grep '
|
|
alias timed='clear; neofetch; systemd-analyze'
|
|
alias update-aliases='echo -en "\n\tUpdating aliases:\t"; for i in $(alias | grep "alias ". | cut -f1 -d= | cut -f2 -d" "); do echo -en "$i\t"; done ;echo; alias | tee ~/.bash_aliases > /dev/null'
|
|
alias vi='busybox vi'
|
|
alias vicr='for i in ./* ; do [ -f $i ] && vi -R "$i" ; done'
|
|
alias vicw='for i in ./* ; do [ -f $i ] && vi "$i" ; done'
|
|
alias view='vi -R'
|
|
alias write-out-iso='
|
|
iso=" "
|
|
dev=" "
|
|
line1="Type or copy-n-paste a file name from above."
|
|
line2="Type the full path to your USB device. (/dev/sdX)"
|
|
line3="The block device ${dev} was found and seems Ok to use."
|
|
lsblk_cmd="lsblk -o RM,NAME,VENDOR,MODEL,SIZE,MOUNTPOINT"
|
|
_abort="To abort this now, press Ctrl+C ."
|
|
_anykey="Hit any key"
|
|
_coward="Cowardly refusing to write to"
|
|
_empty="This field cannot be empty"
|
|
_cancel="to cancel"
|
|
_continue="to continue"
|
|
_knownISO="to enter the full path to the ISO."
|
|
_laststep="This is the final step."
|
|
_missing="File not found."
|
|
_mounted="The location is mounted."
|
|
_noblock="is not a block device."
|
|
_nochecks="No checks were done to determine this is an ISO image."
|
|
_noDEV="The location ${dev} does not exist yet, Plug in a USB ?"
|
|
_noISO="No ISO found in this directory."
|
|
_notlisted="Check your file name or the location and retry."
|
|
_passwd="To write to a USB, your password may be required."
|
|
_re_enter="to Re-Enter the location"
|
|
_restart1="To start over, Press Ctrl+C,"
|
|
_restart2="then move to a folder with the ISO."
|
|
_retry="to retry"
|
|
_search="Searching ${PWD} for ISOs ."
|
|
_write="Hit ANY key to write the file to"
|
|
|
|
clear
|
|
echo -en "\n\t${_passwd}\n\t"
|
|
sudo clear || echo -e "\tFailed password."
|
|
|
|
until [ ! -z "${iso}" ] && [ -e "${iso}" ] && ! (mount | grep -q "${iso}")
|
|
do clear
|
|
echo -e "\n ${_search}\n"
|
|
for i in ./*.iso ./*/*.iso ; do ls $i 2>/dev/null ; done | /bin/grep "\.iso" &&
|
|
echo -en "\n\t${line1}\n\n" || (
|
|
echo -en "\n\t${_noISO} \n\n ${_restart1} ${_restart2}\n\n Or ${_anykey} ${_knownISO}"
|
|
read -n1 -p " " pause && echo )
|
|
|
|
read -p " Path to ISO = " iso
|
|
[ -z "${iso}" ] && (echo -en "\n${_empty}." ; read -n1 -p " ${_anykey} ${_continue}. " back) && continue
|
|
[ ! -e "${iso}" ] && (echo -en "\n${_missing}." ; read -n1 -p " ${_anykey} ${_retry}. " back) && continue
|
|
( mount | grep -q "${iso}" ) && (echo -en "\n${_mounted}" ; read -n1 -p " ${_anykey} ${_retry}. " back) && continue
|
|
done
|
|
|
|
until [ ! -z $dev ] && [ -b $dev ] && ! (mount | grep -q $dev) && [ $dev != "/dev/sda" ] && [ $dev != "/dev/nvme01" ]
|
|
do clear
|
|
echo -e "\n\t Now choose the device to write the ISO to."
|
|
echo -e "\n ISO -----> $iso "
|
|
echo -e "\n$($lsblk_cmd)\n"; read -p "$line2 " dev
|
|
[ -z $dev ] && (echo -en "${_empty}."; read -n1 -p " ${_anykey} ${_continue}. " back) && continue
|
|
[ ! -e $dev ] && (echo -en "${_noDEV}\n\n"; read -n1 -p " ${_anykey} ${_retry}. " back) && continue
|
|
[ ! -b $dev ] && (echo -en "${dev} ${_noblock}"; read -n1 -p " ${_anykey} ${_retry}. " back) && continue
|
|
(mount | grep -q "$dev") && (echo -en "\n${_mounted}"; read -n1 -p " ${_anykey} ${_retry}. " back) && continue
|
|
[ $dev = "/dev/sda" ] && (echo -en "${_coward} ${dev} ."; read -n1 -p " ${_anykey} ${_retry}. " back) && continue
|
|
[ $dev = "/dev/nvme01" ] && (echo -en "${_coward} ${dev} ."; read -n1 -p " ${_anykey} ${_retry}. " back) && continue
|
|
done
|
|
|
|
clear
|
|
echo -e "\n\t${_laststep} ${_anykey} ${_continue}.\n"
|
|
echo -e " ISO -----> ${iso} "
|
|
echo -e " Device --> ${dev} "
|
|
echo -e "\n$($lsblk_cmd ${dev})"
|
|
|
|
|
|
echo -e "\n\tThe file $iso exists. \n\t(${_nochecks})"
|
|
echo -e " \tThe block device ${dev} was found and seems Ok to use."
|
|
echo -en "\n\t${_abort}\n\n\t${_write} $dev. "
|
|
read -n1 go
|
|
|
|
echo -e "\n Writing the file to $dev ..."
|
|
|
|
sudo dd bs=4M oflag=direct status=progress if="${iso}" of=${dev}
|
|
sync ${dev}'
|