refactor
This commit is contained in:
parent
ab70ed8fad
commit
34b6c7c149
8 changed files with 13 additions and 206 deletions
6
base.zsh
6
base.zsh
|
@ -38,9 +38,9 @@ zstyle ':completion:*' verbose true
|
|||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
||||
|
||||
# User
|
||||
# Config
|
||||
|
||||
export EDITOR="nano"
|
||||
export EDITOR="micro"
|
||||
export PATH=~/bin:$PATH
|
||||
alias zshconfig="nano ~/.zshrc"
|
||||
alias zshconfig="$EDITOR ~/.zshrc"
|
||||
alias zshrefresh="source ~/.zshrc"
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
|
||||
cpv() {
|
||||
rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@"
|
||||
}
|
||||
compdef _files cpv
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
encode64() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cat | base64
|
||||
else
|
||||
printf '%s' $1 | base64
|
||||
fi
|
||||
}
|
||||
|
||||
decode64() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cat | base64 --decode
|
||||
else
|
||||
printf '%s' $1 | base64 -d
|
||||
fi
|
||||
}
|
||||
alias e64=encode64
|
||||
alias d64=decode64
|
|
@ -1,83 +0,0 @@
|
|||
|
||||
alias x=extract
|
||||
|
||||
extract() {
|
||||
local remove_archive
|
||||
local success
|
||||
local extract_dir
|
||||
|
||||
if (( $# == 0 )); then
|
||||
cat <<-'EOF' >&2
|
||||
Usage: extract [-option] [file ...]
|
||||
|
||||
Options:
|
||||
-r, --remove Remove archive after unpacking.
|
||||
EOF
|
||||
fi
|
||||
|
||||
remove_archive=1
|
||||
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
|
||||
remove_archive=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "extract: '$1' is not a valid file" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
success=0
|
||||
extract_dir="${1:t:r}"
|
||||
case "${1:l}" in
|
||||
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
|
||||
(*.tar.xz|*.txz)
|
||||
tar --xz --help &> /dev/null \
|
||||
&& tar --xz -xvf "$1" \
|
||||
|| xzcat "$1" | tar xvf - ;;
|
||||
(*.tar.zma|*.tlz)
|
||||
tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -xvf "$1" \
|
||||
|| lzcat "$1" | tar xvf - ;;
|
||||
(*.tar.zst|*.tzst)
|
||||
tar --zstd --help &> /dev/null \
|
||||
&& tar --zstd -xvf "$1" \
|
||||
|| zstdcat "$1" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$1" ;;
|
||||
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;;
|
||||
(*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;;
|
||||
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;;
|
||||
(*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;;
|
||||
(*.bz2) bunzip2 "$1" ;;
|
||||
(*.xz) unxz "$1" ;;
|
||||
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;;
|
||||
(*.lz4) lz4 -d "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.z) uncompress "$1" ;;
|
||||
(*.zip|*.war|*.jar|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar x -ad "$1" ;;
|
||||
(*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
mkdir -p "$extract_dir/control"
|
||||
mkdir -p "$extract_dir/data"
|
||||
cd "$extract_dir"; ar vx "../${1}" > /dev/null
|
||||
cd control; tar xzvf ../control.tar.gz
|
||||
cd ../data; extract ../data.tar.*
|
||||
cd ..; rm *.tar.* debian-binary
|
||||
cd ..
|
||||
;;
|
||||
(*.zst) unzstd "$1" ;;
|
||||
(*)
|
||||
echo "extract: '$1' cannot be extracted" >&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
(( success = $success > 0 ? $success : $? ))
|
||||
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
|
||||
shift
|
||||
done
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
function find_dot_files() {
|
||||
function find_mac_files() {
|
||||
find . -name '.DS_Store';
|
||||
find . -name '._*';
|
||||
}
|
||||
|
||||
function clean_dot_files() {
|
||||
function clean_mac_files() {
|
||||
find . -name '.DS_Store' -type f -delete;
|
||||
find . -name '._*' -type f -delete
|
||||
}
|
|
@ -3,3 +3,4 @@ alias rsync-copy="rsync -avz --progress -h"
|
|||
alias rsync-move="rsync -avz --progress -h --remove-source-files"
|
||||
alias rsync-update="rsync -avzu --progress -h"
|
||||
alias rsync-synchronize="rsync -avzu --delete --progress -h"
|
||||
alias rsync-backup="rsync -avzhruP --update"
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
|
||||
user_commands=(
|
||||
cat
|
||||
get-default
|
||||
help
|
||||
is-active
|
||||
is-enabled
|
||||
is-failed
|
||||
is-system-running
|
||||
list-dependencies
|
||||
list-jobs
|
||||
list-sockets
|
||||
list-timers
|
||||
list-unit-files
|
||||
list-units
|
||||
show
|
||||
show-environment
|
||||
status)
|
||||
|
||||
sudo_commands=(
|
||||
add-requires
|
||||
add-wants
|
||||
cancel
|
||||
daemon-reexec
|
||||
daemon-reload
|
||||
default
|
||||
disable
|
||||
edit
|
||||
emergency
|
||||
enable
|
||||
halt
|
||||
hibernate
|
||||
hybrid-sleep
|
||||
import-environment
|
||||
isolate
|
||||
kexec
|
||||
kill
|
||||
link
|
||||
list-machines
|
||||
load
|
||||
mask
|
||||
poweroff
|
||||
preset
|
||||
preset-all
|
||||
reboot
|
||||
reenable
|
||||
reload
|
||||
reload-or-restart
|
||||
reset-failed
|
||||
rescue
|
||||
restart
|
||||
revert
|
||||
set-default
|
||||
set-environment
|
||||
set-property
|
||||
start
|
||||
stop
|
||||
suspend
|
||||
switch-root
|
||||
try-reload-or-restart
|
||||
try-restart
|
||||
unmask
|
||||
unset-environment)
|
||||
|
||||
for c in $user_commands; do; alias sc-$c="systemctl $c"; done
|
||||
for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done
|
||||
for c in $user_commands; do; alias scu-$c="systemctl --user $c"; done
|
||||
for c in $sudo_commands; do; alias scu-$c="systemctl --user $c"; done
|
||||
|
||||
alias sc-enable-now="sc-enable --now"
|
||||
alias sc-disable-now="sc-disable --now"
|
||||
alias sc-mask-now="sc-mask --now"
|
||||
|
||||
alias scu-enable-now="scu-enable --now"
|
||||
alias scu-disable-now="scu-disable --now"
|
||||
alias scu-mask-now="scu-mask --now"
|
||||
|
||||
function systemd_prompt_info {
|
||||
local unit
|
||||
for unit in $@; do
|
||||
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX"
|
||||
[[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]] && echo -n "${(U)unit}:" || echo -n "$unit:"
|
||||
if systemctl is-active $unit &>/dev/null; then
|
||||
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE"
|
||||
else
|
||||
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE"
|
||||
fi
|
||||
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX"
|
||||
done
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
alias downloadVid="youtube-dl -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=1080][ext=webm]+bestaudio\" --write-thumbnail"
|
||||
alias downloadVid1440="youtube-dl -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=1440][ext=webm]+bestaudio\" --write-thumbnail"
|
||||
alias downloadVid4K="youtube-dl -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=2160][ext=webm]+bestaudio\" --write-thumbnail"
|
||||
alias downloadAudio="youtube-dl -o \"%(playlist_index)s %(title)s.%(ext)s\" -x"
|
||||
alias downloadMusic="youtube-dl -x --add-metadata -o \"%(playlist_title)s/%(playlist_index)s %(title)s.%(ext)s\""
|
||||
alias downloadVid="yt-dlp --downloader aria2c -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=1080]+bestaudio\" --write-thumbnail"
|
||||
alias downloadVid1440="yt-dlp --downloader aria2c -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=1440]+bestaudio\" --write-thumbnail"
|
||||
alias downloadVid4K="yt-dlp --downloader aria2c -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=2160]+bestaudio\" --write-thumbnail"
|
||||
alias downloadAudio="yt-dlp --downloader aria2c -o \"%(playlist_index)s %(title)s.%(ext)s\" -x"
|
||||
alias downloadMusic="yt-dlp --downloader aria2c -x --add-metadata -o \"%(playlist_title)s/%(playlist_index)s %(title)s.%(ext)s\""
|
||||
alias dlBeat="yt-dlp --downloader aria2c --no-playlist --audio-format m4a -x"
|
||||
alias downloadYT="yt-dlp --downloader aria2c --write-thumbnail -o \"%(title)s.%(ext)s\""
|
||||
|
|
Loading…
Add table
Reference in a new issue