345 lines
7.5 KiB
Plaintext
345 lines
7.5 KiB
Plaintext
alias tt='zellij'
|
|
alias tls='zellij list-sessions'
|
|
alias t='zellij attach'
|
|
alias tat='zellij attach'
|
|
alias tlr='zellij delete-all-sessions'
|
|
|
|
alias cr='cd /opt/rust && ls'
|
|
|
|
yt() {
|
|
yt-dlp -o "%(epoch>%Y-%m-%d_%H-%M-%S)s.%(ext)s" "$1"
|
|
}
|
|
alias cx='codex'
|
|
alias cl='claude'
|
|
alias clc='claude -c'
|
|
alias nhs='micro ~/.bash_history'
|
|
|
|
nc() {
|
|
micro /etc/caddy/sites/$1.txt
|
|
systemctl restart caddy
|
|
systemctl status caddy
|
|
}
|
|
|
|
alias op='openlist'
|
|
alias ct='cd /opt/tmp'
|
|
alias nsh='micro ~/.ssh/config'
|
|
alias las='echo $SSH_CLIENT'
|
|
alias csh='cd /opt/data/oplist/share && ls'
|
|
alias tal='tar -tvf'
|
|
tax() {
|
|
if [ $# -ne 2 ]; then
|
|
echo "Usage: tax <archive.tar.*> <destination_directory>"
|
|
return 1
|
|
fi
|
|
|
|
local archive="$1"
|
|
local destination="$2"
|
|
|
|
case "$archive" in
|
|
*.tar)
|
|
tar -xvf "$archive" -C "$destination"
|
|
;;
|
|
*.tar.gz|*.tgz)
|
|
tar -xzvf "$archive" -C "$destination"
|
|
;;
|
|
*.tar.bz2|*.tbz2)
|
|
tar -xjvf "$archive" -C "$destination"
|
|
;;
|
|
*.tar.xz|*.txz)
|
|
tar -xJvf "$archive" -C "$destination"
|
|
;;
|
|
*)
|
|
echo "Unsupported archive format: $archive"
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
tac() {
|
|
if [ $# -lt 2 ]; then
|
|
echo "Usage: tac <archive.tar.*> <file_or_directory1> [<file_or_directory2> ...]"
|
|
return 1
|
|
fi
|
|
|
|
local archive="$1"
|
|
shift # 移除第一个参数,剩下的都是要压缩的文件或目录
|
|
|
|
case "$archive" in
|
|
*.tar)
|
|
tar -cvf "$archive" "$@"
|
|
;;
|
|
*.tar.gz|*.tgz)
|
|
tar -czvf "$archive" "$@"
|
|
;;
|
|
*.tar.bz2|*.tbz2)
|
|
tar -cjvf "$archive" "$@"
|
|
;;
|
|
*.tar.xz|*.txz)
|
|
tar -cJvf "$archive" "$@"
|
|
;;
|
|
*)
|
|
echo "Unsupported archive format: $archive"
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
alias csv='cd /etc/systemd/system/ && ls'
|
|
alias hs='history'
|
|
alias lg='journalctl -xeu'
|
|
alias gc='git clone'
|
|
coa() {
|
|
conda activate $1
|
|
}
|
|
|
|
cod() {
|
|
conda deactivate
|
|
}
|
|
|
|
coc() {
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: cac <env_name> [python_version]"
|
|
return 1
|
|
fi
|
|
|
|
if [ -z "$2" ]; then
|
|
echo "y" | conda create --name "$1"
|
|
else
|
|
echo "y" | conda create --name "$1" python="$2"
|
|
fi
|
|
}
|
|
|
|
alias col='conda env list'
|
|
|
|
cor() {
|
|
conda env remove --name $1 --yes
|
|
}
|
|
|
|
alias py='python'
|
|
|
|
alias sts='systemctl status'
|
|
alias sdr='systemctl daemon-reload'
|
|
|
|
function str() {
|
|
systemctl start "$1" && systemctl status "$1"
|
|
}
|
|
|
|
function stp() {
|
|
systemctl stop "$1" && systemctl status "$1"
|
|
}
|
|
|
|
function rstr() {
|
|
systemctl restart "$1" && sleep 3 && systemctl status "$1"
|
|
}
|
|
|
|
alias enable='systemctl enable'
|
|
alias disable='systemctl disable'
|
|
alias sdr='systemctl daemon-reload'
|
|
alias a='aria2c -c -s4 -x4'
|
|
alias pon="export ALL_PROXY=http://localhost:2080 https_proxy=http://localhost:2080 http_proxy=http://localhost:2080 && curl ip.sb"
|
|
alias pof="unset ALL_PROXY http_proxy https_proxy && curl ip.sb"
|
|
alias d='docker'
|
|
alias ds='docker stop'
|
|
alias dst='docker stats'
|
|
alias dlg='docker logs'
|
|
alias dp='docker ps'
|
|
alias dbp='echo "y" | docker builder prune'
|
|
alias dpa='docker ps -a'
|
|
alias dcu='docker compose up'
|
|
alias dcud='docker compose up -d'
|
|
alias dcd='docker compose down'
|
|
alias dcp='docker compose pull'
|
|
alias dcr='docker compose restart'
|
|
alias dim='docker images'
|
|
alias dvl='docker volume ls'
|
|
alias dpr='echo "y" | docker image prune && docker images'
|
|
alias docker-compose='docker compose'
|
|
alias dip="docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'"
|
|
alias ck="cd /opt/docker-compose && ls"
|
|
|
|
dt() {
|
|
docker run --rm -it $1 sh
|
|
}
|
|
|
|
dbd() {
|
|
docker build -t git.nvme.cc/adminroot/$1 .
|
|
docker images
|
|
}
|
|
|
|
alias dvr='docker volume rm -f'
|
|
alias dfv='docker system df -v'
|
|
|
|
alias w='wget --content-disposition'
|
|
alias h='htop'
|
|
|
|
c() {
|
|
if [ -z "$1" ]; then
|
|
cd ~
|
|
else
|
|
cd "$1"
|
|
fi
|
|
ls
|
|
}
|
|
|
|
alias cdd='cd ../ && ls'
|
|
|
|
alias ce='cd /etc && ls'
|
|
alias co='cd /opt && ls'
|
|
alias dfh='df -h | grep -v '/var/lib/docker' | grep -vE '^tmpfs''
|
|
alias sr='source /etc/profile && source ~/.bashrc'
|
|
alias nn='micro'
|
|
alias nnd='micro compose.yml'
|
|
alias dush='du -sh'
|
|
|
|
function din() {
|
|
docker exec -it "$1" /bin/sh
|
|
}
|
|
|
|
function dinb() {
|
|
docker exec -it "$1" /bin/bash
|
|
}
|
|
|
|
portcheck() {
|
|
lsof -i :$1
|
|
}
|
|
alias p='portcheck'
|
|
|
|
countfiles() {
|
|
dir="${1:-.}"
|
|
find "$dir" -type f | rev | cut -d"." -f1 | rev | sort | uniq -c
|
|
}
|
|
alias lst=countfiles
|
|
|
|
lsd() {
|
|
du -h --max-depth=1 $1 | sort -h
|
|
}
|
|
|
|
findfile() {
|
|
find . -type f -name "*.$1" -exec du -h '{}' + | sort -h
|
|
}
|
|
alias f='findfile'
|
|
|
|
alias nb='micro ~/.bashrc'
|
|
alias na='micro ~/.alias.txt'
|
|
alias nau='rm ~/.alias.txt && wget https://git.nvme.cc/adminroot/setup/raw/branch/main/alias.txt -O ~/.alias.txt'
|
|
alias clog='sudo journalctl --vacuum-time=1d'
|
|
alias mk='mkdir -p'
|
|
alias l='ls'
|
|
alias s='ls'
|
|
|
|
alias cc='cbm'
|
|
|
|
alias v2='v2ray'
|
|
|
|
alias ary='apt remove -y'
|
|
alias auy='apt update -y'
|
|
alias aiy='apt install -y'
|
|
alias agy='apt upgrade -y'
|
|
|
|
alias pir='pip install -r'
|
|
|
|
function pir-cn() {
|
|
pip install -r $1 -i https://mirrors.ustc.edu.cn/pypi/web/simple
|
|
}
|
|
|
|
alias rm='rm -r'
|
|
alias cp='cp -r'
|
|
|
|
alias 7za='7z a -m0=Copy'
|
|
function 7zx() {
|
|
local archive="$1"
|
|
local outdir="${2:-.}"
|
|
|
|
if [[ ! -f "$archive" ]]; then
|
|
echo "❌ 文件不存在: $archive" >&2
|
|
return 1
|
|
fi
|
|
|
|
mkdir -p "$outdir"
|
|
|
|
local lower_name="${archive,,}" # 全小写处理后缀名,提升兼容性
|
|
|
|
# 支持的 .tar.* 格式(多层压缩)
|
|
local tar_pattern='\.(tar\.xz|txz|tar\.gz|tgz|tar\.bz2|tbz2|tar\.zst|tzst)$'
|
|
|
|
# 支持的直接压缩格式
|
|
local direct_pattern='\.(zip|7z|rar)$'
|
|
|
|
if [[ "$lower_name" =~ $tar_pattern ]]; then
|
|
7z x -so "$archive" | 7z x -si -ttar -o"$outdir"
|
|
elif [[ "$lower_name" =~ $direct_pattern ]]; then
|
|
7z x "$archive" -o"$outdir"
|
|
else
|
|
echo "⚠️ 不支持的格式: $archive" >&2
|
|
return 2
|
|
fi
|
|
}
|
|
|
|
function 7zxd() {
|
|
local password="$1"
|
|
local files=()
|
|
|
|
while IFS= read -r -d '' f; do
|
|
files+=("$f")
|
|
done < <(find . -maxdepth 1 -type f \( \
|
|
-iname '*.zip' -o -iname '*.7z' -o -iname '*.rar' -o \
|
|
-iname '*.tar.gz' -o -iname '*.tgz' -o -iname '*.tar.bz2' -o -iname '*.tbz2' -o \
|
|
-iname '*.tar.xz' -o -iname '*.txz' -o -iname '*.tar.zst' -o -iname '*.tzst' -o \
|
|
-iname '*.part1.rar' -o -iname '*.001' \
|
|
\) -print0)
|
|
|
|
if [[ ${#files[@]} -eq 0 ]]; then
|
|
echo "📂 当前目录下无可解压的压缩包"
|
|
return 0
|
|
fi
|
|
|
|
for file in "${files[@]}"; do
|
|
echo "📦 正在解压: $file"
|
|
local base="${file%.*}"
|
|
|
|
if [[ -n "$password" ]]; then
|
|
7z x "$file" -p"$password" -aoa -y
|
|
else
|
|
7z x "$file" -aoa -y
|
|
fi
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
echo "✅ 解压成功,删除源文件..."
|
|
|
|
local prefix="${file%%.*}"
|
|
find . -maxdepth 1 -type f -regex "./$prefix\\..*" -delete
|
|
else
|
|
echo "❌ 解压失败: $file"
|
|
fi
|
|
done
|
|
}
|
|
|
|
mtm() {
|
|
find $1 -type f \( -iname "*.mp4" -o -iname "*.avi" -o -iname "*.mov" \) -exec mv {} $2 \;
|
|
}
|
|
|
|
function ua() {
|
|
ufw allow $1 && ufw status
|
|
}
|
|
function ud() {
|
|
ufw delete allow $1 && ufw status
|
|
}
|
|
alias us='ufw status'
|
|
function ura() {
|
|
ufw route allow $1 && ufw status
|
|
}
|
|
function urd() {
|
|
ufw route delete allow $1 && ufw status
|
|
}
|
|
|
|
alias ip4='curl ip.sb -4'
|
|
alias ip6='curl ip.sb -6'
|
|
|
|
alias nnc='micro /etc/caddy/Caddyfile'
|
|
alias csr='systemctl restart caddy && systemctl status caddy'
|
|
alias cap='caddy hash-password'
|
|
|
|
alias psr='systemctl restart php8.2-fpm && systemctl status php8.2-fpm'
|
|
|
|
alias ll='ls -a'
|