Browse Source

My custom shell script snippets

pull/1/head
Harish K 6 years ago
committed by GitHub
parent
commit
d6f0af204f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      home/.local/bin/hari-tools.sh

49
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 <path/to/block_dev> <path/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<<EOF
Available commands:
$(echo $allFunctions | sed 's/ /\n\t/g' | sort )
EOF
fi
Loading…
Cancel
Save