[READ-ONLY] Mirror of https://github.com/mrgnw/dotfiles. My shell customizations - aliases, functions, and themes.
dotfiles shell zinit zsh
0

Configure Feed

Select the types of activity you want to include in your feed.

dotfiles / net.zsh
2.4 kB 96 lines
1alias ts='tailscale' 2# check if tailscale is not in PATH 3if ! command -v tailscale &>/dev/null; then 4 alias tailscale='/Applications/Tailscale.app/Contents/MacOS/Tailscale' 5fi 6 7y() { 8 if [ $# -eq 0 ]; then 9 yt-dlp "$(pbpaste)" 10 else 11 yt-dlp "$@" 12 fi 13} 14yb(){ 15 y --cookies-from-browser firefox "$@" 16} 17 18dl(){ 19 # - dl {clipboard} 20 # - dl {url} 21 # - dl {clipboard} 22 # - dl {url} 23 # - dl {urls_in_file} to pwd 24 # - dl {urls_in_file} to {dir} 25 # - dl {url} to {output_file} 26 # dl (everything passes through to aria2c) 27 opts="--log-level=warn --download-result=full" 28 if [[ $# -eq 0 ]]; then aria2c ${=opts} "$(pbpaste)" 29 elif [[ $# -eq 1 ]] && [[ -f "$1" ]]; then aria2c ${=opts} -i "$1"; 30 elif [[ -f "$1" ]] && [[ -d "$2" ]]; then aria2c ${=opts} -i "$1" -d "$2" "$@"; 31 elif [[ $# -eq 2 ]]; then aria2c ${=opts} "$1" -o "$2"; 32 else aria2c ${=opts} "${=@}"; 33 fi 34} 35+bin(){ 36 # tries to download a binary, unzip if necessary, and move to ~/.binaries when done 37 ( 38 +d $HOME/.installs/; 39 src=${1:-$(pbpaste)}; 40 41 local filename=${src##*/}; # src after last slash 42 local name="${2:-${filename%%[._-]*}}" # $2 or chars before first [._-] of filename 43 echo $name 44 dl "$src"; 45 46 # unpack if it's a zip or tar.gz 47 if [[ $filename == *.zip ]]; then unzip -o $filename 48 elif [[ $filename == *.tar.gz ]]; then tar -xvf $filename 49 fi 50 51 chmod +x $name 52 mv $name $HOME/.binaries/$name 53 ) 54} 55 56gp() { 57 local hosts=( 58 "1.1.1.1" 59 "cloudflare.com" 60 "8.8.8.8" 61 "google.com" 62 ) 63 gping -s ${@:-${hosts[@]}} 64} 65 66# simple ping 67sp() { 68 ping ${@:-"1.1.1.1"} | awk \ 69 '{ gsub("time=", "") ;\ 70 gsub("icmp_seq=","");\ 71 print $5"\t" $7 " " $8 }'\ 72 OFMT="%.0f"; 73}; 74 75# ports 76port(){ lsof -ti:$1 } 77killport(){ lsof -ti:$1 | xargs kill } 78pforward(){ 79 FWD_FROM_HOST=$1 80 FWD_FROM_PORT=$2 81 FWD_TO_PORT=${3:-$2} 82 ssh -L $FWD_TO_PORT:$FWD_FROM_HOST:$FWD_FROM_PORT -N 127.0.0.1 83} 84 85ip() { 86 # copy just the ip address, output ip, city, country 87 curl -sS ipinfo.io | tee >(jq -r '.ip' | pbcopy) | jq '{ip:.ip, city:.city, country:.country}' 88} 89 90alias ttl='sudo sysctl net.inet.ip.ttl=65' 91alias flushdns='dscacheutil -flushcache' 92 93rcp(){ 94 rclone copy "$1" "$2" --progress --transfers=${3:-12} --multi-thread-streams 0 "${@:4}" 95 } 96ybr(){ yt-dlp --cookies-from-browser ${1:-safari} "$(pbpaste)" }