1
0
Fork 0
dotfiles/home/dot_config/zsh/custom/101-function.zsh

96 lines
2.3 KiB
Bash
Raw Normal View History

2018-04-11 19:52:53 +00:00
# edit alias
2018-03-10 04:04:29 +00:00
vialias() {
$EDITOR $ZSH_CUSTOM/100-alias.zsh
source $ZSH_CUSTOM/100-alias.zsh
}
2018-04-11 19:52:53 +00:00
# edit function
2018-03-10 04:04:29 +00:00
vifunction() {
$EDITOR $ZSH_CUSTOM/101-function.zsh
source $ZSH_CUSTOM/101-function.zsh
}
2018-03-23 15:27:34 +00:00
2018-04-11 19:52:53 +00:00
# scan network
2018-03-23 15:27:34 +00:00
nmap-libvirt() {
__nmap_iface 'virbr[0-9]+' $@
}
nmap-tun() {
2018-04-11 19:52:53 +00:00
__nmap_iface '(tun|tap)[0-9]+' $@
2018-03-23 15:27:34 +00:00
}
nmap-local() {
__nmap_iface '(eth|wlan)[0-9]+' $@
}
__nmap_iface() {
local iface="$1"
shift
local opt=${@:--T5}
for link in $(ip link show up | grep -Eo "$iface"); do
2018-03-23 15:27:34 +00:00
for addr in $(ip addr show $link | grep -oP '(?<=inet )([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}'); do
addr_list="$addr_list $addr"
done
done
printf "Scanning %s\n" "$addr"
nmap $opt $addr_list
2018-03-23 15:27:34 +00:00
}
2018-04-11 19:52:53 +00:00
# calculator
\=() {
bc -l <<<"$*"
}
2018-04-29 17:31:31 +00:00
2019-08-29 00:54:49 +00:00
# start game mode
gamemode() {
2020-09-02 19:58:19 +00:00
#if ! [ -S /tmp/win10.sock ]; then
#echo "Cannot find spice socket! Is the vm started?"
#else
2018-10-12 00:25:32 +00:00
echo "Setup cpuset cgroup for host"
sudo cset set -c 0,4 -s system
sudo cset proc -m -f root -t system
sudo cset proc -k -f root -t system --force
2018-04-29 17:31:31 +00:00
2018-10-12 00:25:32 +00:00
echo "Setup cpumask"
2018-12-07 00:26:00 +00:00
for i in /sys/devices/virtual/workqueue/*/cpumask; do
sudo sh -c "echo 001 > $i"
done;
echo "Setup interrupt affinity"
for i in $(sed -n -e 's/ \([0-9]\+\):.*vfio.*/\1/p' /proc/interrupts); do
sudo sh -c "echo 0,4 > /proc/irq/$i/smp_affinity_list"
done
2018-05-14 19:13:12 +00:00
2020-09-11 20:28:13 +00:00
#LD_PRELOAD="/usr/\$LIB/libgamemodeauto.so" until-success looking-glass-client -p 0 -c /tmp/win10.sock app:renderer=opengl egl:vsync=yes win:fullScreen=yes -k $@
2021-04-10 18:44:32 +00:00
gamemoderun until-success looking-glass-client
2018-04-29 17:31:31 +00:00
2018-10-12 00:25:32 +00:00
echo "Restore system"
2018-12-07 00:26:00 +00:00
# irq
for i in $(sed -n -e 's/ \([0-9]\+\):.*vfio.*/\1/p' /proc/interrupts); do
sudo sh -c "echo ff > /proc/irq/$i/smp_affinity"
done
2018-10-12 00:25:32 +00:00
# cpumask
2018-12-07 00:26:00 +00:00
for i in /sys/devices/virtual/workqueue/*/cpumask; do
sudo sh -c "echo ff > $i"
done;
2018-10-12 00:25:32 +00:00
# cpuset
sudo cset set -d system &>/dev/null
2020-09-02 19:58:19 +00:00
#fi
2018-04-29 17:31:31 +00:00
}
2021-01-03 03:04:45 +00:00
# netshoot
netshoot-docker() {
set +x
docker run --rm -it --name netshoot $@ nicolaka/netshoot
set -x
}
netshoot-kube() {
set +x
kubectl run netshoot --rm -i --tty --image nicolaka/netshoot -- /bin/bash
set -x
}