From d6f0af204f09d7770c3a4c651a113a1afec8b61c Mon Sep 17 00:00:00 2001 From: Harish K Date: Thu, 13 Jun 2019 13:57:37 +0530 Subject: [PATCH] My custom shell script snippets --- home/.local/bin/hari-tools.sh | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 home/.local/bin/hari-tools.sh diff --git a/home/.local/bin/hari-tools.sh b/home/.local/bin/hari-tools.sh new file mode 100644 index 0000000..5413d59 --- /dev/null +++ b/home/.local/bin/hari-tools.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + + +sshInTabs(){ + logins="$@" + for i in $logins; do + gnome-terminal --tab -- bash -c "retry=y; while [ \"\$retry\" = 'y' ]; do ssh $i; echo \'Retry? y/n \(n\) ?\'; read retry; done;"; + done +} + + +edit(){ + vim ~/.local/Apps/daily-utils/bin/hari-tools.sh +} + +## Convert text to wav +genSound(){ echo $1 | espeak --stdout | ffmpeg -i - -ar 8000 -y $2.wav ; } + + +clearSysRq(){ + sudo kbd_mode -s -C /dev/tty7 +} + +myIp(){ + curl 'https://api.ipify.org?format=json' +} + +#Create VMDK virtual disk from actual block devices +block_dev_to_vmdk(){ + [ -z "$2" ] && echo 'block_dev_to_vmdk ' && exit 1 + VBoxManage internalcommands createrawvmdk -filename $2 -rawdisk $1 +} + +# Print sha256 fignerprint of ssh public keys +sshsha256(){ awk '{print $2}' $1 | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 ; } + +cmd=$1 +shift +allFunctions=$(typeset -F | cut -d ' ' -f 3 | grep -v '^_' | tr '\n' ' ' ) +if [ -n "$cmd" ] && [[ " $allFunctions " =~ " $cmd " ]]; then + $cmd "$@" +else + cat<