Last active
August 23, 2023 14:44
-
-
Save linktohack/9cb45fe38b1baff7b44a to your computer and use it in GitHub Desktop.
ZSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export EDITOR=vim | |
export ZSH="$HOME/.oh-my-zsh" | |
ZSH_THEME="nicoulaj" | |
plugins=(asdf aws docker direnv fasd fzf git helm history jq kubectl macos) | |
source $ZSH/oh-my-zsh.sh | |
export FZF_DEFAULT_OPTS="--bind ctrl-k:kill-line,ctrl-b:preview-page-up,ctrl-f:preview-page-down" | |
export _FASD_BACKENDS="native spotlight" | |
export PATH="$PATH:$HOME/Library/Android/sdk/platform-tools" | |
export ANDROID_HOME="$HOME/Library/Android/sdk" | |
export JAVA_HOME="/Library/Java/Home" | |
alias gl="glgga --oneline" | |
alias j=z | |
alias tb="nc termbin.com 9999" | |
J() { | |
fasd -R | fzf --no-sort --query "$1" | perl -pe 's|^.*?/|/|' | \ | |
while read i; do | |
if [ -d "$i" ]; then | |
cd "$i" | |
else | |
cd "$(dirname "$i")" | |
fi | |
done | |
} | |
T() { | |
tldr --list | awk -v RS=', |\n' '/^[^\s]/ { print }' \ | |
| fzf --preview 'tldr {}' --query "$1" \ | |
| xargs -I{} tldr '{}' | |
} | |
e() { | |
if emacsclient -e nil 2>/dev/null 1>/dev/null; then | |
emacsclient --no-wait "$@" | |
else | |
open -a /Applications/Emacs.app --args -g 200x49 "$@" | |
fi | |
} | |
cde() { | |
cd "$(e --eval '(with-current-buffer (window-buffer) (expand-file-name default-directory))' | tr -d \")" | |
} | |
magit() { | |
if [ -d "$1" ]; then | |
pushd "$1"; | |
fi | |
e --eval '(prog1 (select-frame-set-input-focus (selected-frame)) (magit-status))' | |
} | |
ediff() { | |
local file_a="$(realpath "$1")" | |
local file_b="$(realpath "$2")" | |
e --eval "(prog1 (select-frame-set-input-focus (selected-frame)) (ediff-files \"${file_a}\" \"${file_b}\"))" | |
} | |
jdk() { | |
local version="$(/usr/libexec/java_home -V 2>&1 | sed '1d;$d' | awk '{ print $1 }' | fzf)" | |
export JAVA_HOME=$(/usr/libexec/java_home -v"$version"); | |
java -version | |
} | |
to() { | |
local interface=Wi-Fi | |
local pass=$(tor --hash-password 123) | |
local port=9051 | |
local args="ControlPort $port HashedControlPassword $pass" | |
sudo networksetup -setsocksfirewallproxy $interface 127.0.0.1 9050 off | |
sudo networksetup -setsocksfirewallproxystate $interface on | |
[ -z "$1" ] || args="$args ExitNodes {$1}" | |
echo "export all_proxy=socks://localhost:9050" | |
echo "export http_proxy=localhost:8123" | |
echo tor ${=args} | |
tor ${=args} | |
sudo networksetup -setsocksfirewallproxystate $interface off | |
} | |
tn() { | |
cat <<EOF | nc 127.0.0.1 9051 | |
authenticate "123" | |
signal newnym | |
EOF | |
} | |
sp () { | |
local interface=Wi-Fi | |
local port=${1:-9050} | |
# trap break SIGINT SIGTERM | |
if nc -z 127.0.0.1 $port; then | |
sudo networksetup -setsocksfirewallproxy $interface 127.0.0.1 $port off | |
sudo networksetup -setsocksfirewallproxystate $interface on | |
while true; do sleep 1; done | |
sudo networksetup -setsocksfirewallproxystate $interface off | |
fi | |
} | |
ssh-exit() { | |
ps aux | awk '/ssh:.+\[mux\]/ { print $2 }' | xargs kill | |
} | |
adb-wireless() { | |
local device | |
local address | |
adb devices | sed -e '1d;$d;/:/d' | awk '{ print $1 }' | while read -r device; do | |
adb -s "$device" tcpip 5555 | |
sleep 2 | |
address="$(adb -s "$device" shell ip route | awk '/wlan0/ { print $NF }')" | |
if [ ! -z "$address" ]; then | |
echo "Connecting to device '$device' through $address:5555..." | |
adb connect "$address:5555" | |
else | |
echo "Unable to find the IP adresse of device $device" | |
fi | |
done | |
} | |
compdef sshrc=ssh | |
compdef dockerrc=docker | |
compdef kubectlrc=kubectl | |
compdef surc=su | |
export KUBECONFIG='/Users/qle/Library/Application Support/Lens/kubeconfigs/7f0c5577-a67e-4262-a918-ff8d179d39c1' # Hyrule | |
### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT) | |
export PATH="/Users/qle/.rd/bin:$PATH" | |
### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment