Files
gists/config/shell/shell_aliases
T
tobias f540e08437 fix(shell): repair broken aliases, modernize, make bash/zsh + linux/mac portable
- drop hardcoded /home/tke/.http_proxy sourcing; both proxy installers
  (update_bashrc_proxy.sh #PROXY_A93JK2, install_proxy.sh
  #PROXY_BRIDGE_CONFIG) inject their own bashrc lines
- fix 'set $_Z_OWNER=' (set positional params instead of the variable)
- prefer zoxide over z.sh, load only one jumper instead of both
- dockertags: dead Docker Hub v1 API -> v2, handle library/ prefix
- rot13: handle uppercase
- ppxml: drop dead duplicate with typo'd xmllin command
- exa (unmaintained) -> eza, fallback lsd -> ls; single ll definition
- guard linux-only bits (locate -A, ntfsmount, usbguard, apt+fzf, mc)
  and optional tools with command -v; batcat support for ubuntu
- unsetproxy: grep -P is GNU-only, unset vars explicitly instead
- quote ${workdir:-$(pwd)} mounts; dedupe mv/cp/pip/python
- guard shopt autocd (macOS bash 3.2)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 16:56:39 +02:00

101 lines
5.8 KiB
Plaintext

# shell_aliases — portable aliases for bash and zsh, Linux and macOS.
# Sourced (not executed); everything optional is guarded so missing tools are skipped.
alias cp='cp -vi'
alias mv='mv -vi'
alias sless='less -S -R'
# --- docker run wrappers ---
# naming: trailing/extra "n" = network enabled, otherwise --network=none
alias dockerstatus='docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock moncho/dry'
alias dockerip="docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'"
alias dritn='docker run -i -t --rm '
alias drit='docker run -i -t --rm --network=none'
alias dritpwn='docker run -i -t --rm -v "$(mktemp -d):/output" -v "$(pwd)":/data:ro'
alias dritpwnrw='docker run -i -t --rm -v "$(mktemp -d):/output" -v "$(pwd)":/data:rw'
alias dritpw='docker run -i -t --rm --network=none -v "$(mktemp -d):/output" -v "$(pwd)":/data:ro'
alias dritpwrw='docker run -i -t --rm --network=none -v "$(mktemp -d):/output" -v "$(pwd)":/data:rw'
alias kali='docker run --rm -it -v "${workdir:-$(pwd)}":/root/workdir kalilinux/kali-rolling'
alias lazydocker='docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v /opt/lazydocker:/.config/jesseduffield/lazydocker lazyteam/lazydocker'
alias powershell='docker run --rm -it -v "${workdir:-$(pwd)}":/data mcr.microsoft.com/powershell pwsh'
alias pwsh=powershell
alias dockerips="docker ps -q | xargs docker inspect --format '{{.Name}}{{range \$n, \$c := .NetworkSettings.Networks}} {{\$n}}: {{\$c.IPAddress}}{{end}}'"
alias dissect='dritpw tabledevil/dissect'
# --- remnux containers ---
alias remnux_crits_start='sudo docker run --rm --name critsy -it -v "${workdir:-$(pwd)}":/home/nonroot/workdir -p 8443:8443 remnux/crits'
alias remnux_crits_stop='sudo docker stop critsy'
alias remnux_jsdetox_start='sudo docker run --rm --name jsdetoxy -p 3000:3000 remnux/jsdetox'
alias remnux_jsdetox_stop='sudo docker stop jsdetoxy'
alias remnux_mastiff='sudo docker run --rm -it -v "${workdir:-$(pwd)}":/home/nonroot/workdir remnux/mastiff'
alias remnux_msf='docker run --rm -it -p 443:443 -v ~/.msf4:/root/.msf4 -v /tmp/msf:/tmp/data remnux/metasploit'
alias remnux_pescanner='docker run --rm -it --dns=192.168.130.1 -v "${workdir:-$(pwd)}":/home/nonroot/workdir remnux/pescanner bash'
alias remnux_rekall='docker run --rm -it -p 8000:8000 --dns=192.168.130.1 -v "${workdir:-$(pwd)}":/home/nonroot/files remnux/rekall bash'
alias remnux_thug='sudo docker run --rm -it --dns=192.168.130.1 -v /var/log/docker/thug_logs:/home/thug/logs remnux/thug ./thug.py -F '
alias remnux_viper='docker run --rm -it --dns=192.168.130.1 -v "${workdir:-$(pwd)}":/home/nonroot/workdir remnux/viper bash'
alias remnux_vol='docker run --rm -it -v "${workdir:-$(pwd)}":/home/nonroot/memdumps remnux/volatility bash'
# --- text / data helpers ---
alias ppxml='xmlstarlet format --indent-tab'
alias evtvd='vd -f csv --skip 5'
alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m'"
alias uniq2='awk '"'"'{a[$0]++; if (a[$0]==1) print $0 }'"'"
# --- linux-only tools ---
if [[ "$OSTYPE" == linux* ]]; then
alias locate='locate -i -A'
alias ntfsmount='sudo mount -o ro,show_sys_files,streams_interface=windows'
fi
[ -f /usr/lib/mc/mc-wrapper.sh ] && alias mc='. /usr/lib/mc/mc-wrapper.sh'
if command -v usbguard >/dev/null 2>&1; then
alias usbb='usbguard list-devices -b'
alias usba='usbguard allow-device'
fi
if command -v apt-cache >/dev/null 2>&1 && command -v fzf >/dev/null 2>&1; then
alias searchpackage="apt-cache search '' | sort | cut --delimiter ' ' --fields 1 | fzf --multi --cycle --reverse --preview 'apt-cache show {1}' | xargs -r sudo apt install -y"
fi
# --- python / rust tool shims ---
command -v python3 >/dev/null 2>&1 && alias python='python3'
command -v pip3 >/dev/null 2>&1 && alias pip='pip3'
command -v fdfind >/dev/null 2>&1 && alias fd='fdfind'
# --- modern ls: eza > lsd > plain ls ---
if command -v eza >/dev/null 2>&1; then
alias ll='eza -l --icons --group-directories-first'
alias lt='eza -lT --level 2 --git-ignore --group-directories-first'
elif command -v lsd >/dev/null 2>&1; then
alias ll='lsd -lAF'
alias lt='lsd -lA --tree --depth 2'
else
alias ll='ls -lAF'
fi
# --- bat as manpager (bat on most distros, batcat on ubuntu/debian) ---
if command -v bat >/dev/null 2>&1; then
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
elif command -v batcat >/dev/null 2>&1; then
alias bat='batcat'
export MANPAGER="sh -c 'col -bx | batcat -l man -p'"
fi
# --- functions ---
function bindiff() { cmp -l "${1}" "${2}" | gawk '{printf "%s,%02X,%02X\n",$1,strtonum(0$2),strtonum(0$3) }' ; }
function avscan(){ av="${1:-kaspersky}" ; if [ "${av}" == "update" ] ; then ( docker pull tabledevil/kaspersky ; docker pull tabledevil/sep ; docker pull tabledevil/clamav) ; elif [[ $# -eq 2 ]] ; then dritpw "tabledevil/${av}" "${2}" ; else dritpw "tabledevil/${av}" scan ; fi ; }
function dockerfa() { [[ $# -eq 0 ]] && wpd=$(readlink -f . ) || wpd=$(readlink -f "${1}"); docker run -it --rm -v "${wpd}":/data tabledevil/file-analysis;}
function docker_killall() { docker rm $(docker stop $(docker ps -a -q --filter ancestor="${1}" --format="{{.ID}}")) ; }
# list tags of a docker hub repo, optionally filtered (hub API caps at 100 per page)
function dockertags() {
local repo="${1:?usage: dockertags <repo> [filter]}"
[[ "$repo" != */* ]] && repo="library/${repo}"
local tags
tags=$(curl -fsSL "https://hub.docker.com/v2/repositories/${repo}/tags/?page_size=100" \
| python3 -c 'import json,sys; [print(r["name"]) for r in json.load(sys.stdin).get("results",[])]')
[ -n "$2" ] && tags=$(echo "${tags}" | grep "$2")
echo "${tags}"
}
function unsetproxy() { unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY all_proxy ALL_PROXY ftp_proxy FTP_PROXY ; }
function nsrt() { local col=$1; shift; awk -v c="$col" '{print $c, $0}' "$@" | sort -k1,1 -n | cut -d' ' -f2-; }