217 lines
7.8 KiB
Bash
217 lines
7.8 KiB
Bash
#!/usr/bin/env bash
|
|
# executed by bash(1) for non-login shells.
|
|
|
|
# ==============================
|
|
# ALIASES
|
|
# ==============================
|
|
|
|
# ==============================
|
|
# Overlays
|
|
# ==============================
|
|
|
|
if command -v dircolors 1> /dev/null; then
|
|
alias dir='dir --color=auto'
|
|
alias vdir='vdir --color=auto'
|
|
|
|
# had to add -a because grep interprete a part of syslog as a binary
|
|
alias grep='grep --color=auto -a'
|
|
alias fgrep='fgrep --color=auto'
|
|
alias egrep='egrep --color=auto'
|
|
|
|
alias ls='ls --color=auto'
|
|
else
|
|
alias grep='grep -a'
|
|
fi
|
|
|
|
# most common usage of df/du
|
|
if command -v hl 1> /dev/null; then
|
|
alias df='df -Tha --total | hlauto --df'
|
|
else
|
|
alias df='df -Tha --total'
|
|
fi
|
|
alias du='du -ach'
|
|
|
|
# better ncdu
|
|
if command -v ncdu 1> /dev/null; then
|
|
alias ncdu='ncdu -e --exclude-kernfs --color dark'
|
|
fi
|
|
|
|
# nano with backups
|
|
if command -v nano 1> /dev/null; then
|
|
mkdir -p ~/.cache/nano/backups
|
|
alias nano='nano -BGSceilqy% --atblanks -T 4 -C ~/.cache/nano/backups'
|
|
# clean nano backups
|
|
alias nano-clean='rm -rf ~/.cache/nano/backups/*'
|
|
fi
|
|
# force vim usage
|
|
if command -v vim 1> /dev/null; then
|
|
alias vi='vim'
|
|
fi
|
|
|
|
# ==============================
|
|
# New/Updated Utils
|
|
# ==============================
|
|
|
|
# login to root with sudo but keeping your ssh-agent and tmux env
|
|
alias sudoi='sudo -i --preserve-env=TMUX,WINDOWID,SSH_AGENT_PID,TERM_PROGRAM'
|
|
|
|
# short cd ..
|
|
alias cd..='cd ..'
|
|
alias ..='cd ..'
|
|
# last location
|
|
alias back='cd "$OLDPWD"'
|
|
|
|
# new upgraded ls, check fzf versions in functions
|
|
if command -v exa 1> /dev/null; then
|
|
alias l='exa -abghHl --git --icons --color always --group-directories-first --time-style=long-iso'
|
|
fi
|
|
|
|
# most common usage of ps
|
|
alias psf='ps faux'
|
|
# grep in psf
|
|
alias psg='ps faux | grep -v grep | grep -i -e VSZ -e'
|
|
|
|
# grep in history
|
|
alias hgrep='history | grep -i'
|
|
# print the 15 last lines from history
|
|
alias recent='fc -l'
|
|
|
|
# mkdir verbose and recursive
|
|
alias mkd='mkdir -pv'
|
|
|
|
# better man
|
|
alias manu='man --encoding UTF-8 --no-hyphenation --pager "less --ignore-case --LONG-PROMPT --mouse --quit-at-eof --quit-if-one-screen --RAW-CONTROL-CHARS --squeeze-blank-lines --status-column --tilde --use-color"'
|
|
|
|
# less with follow like tail -f
|
|
alias less-follow='less --auto-buffers --follow-name +F --ignore-case --LONG-PROMPT --mouse --quit-at-eof --RAW-CONTROL-CHARS --squeeze-blank-lines --status-column --tilde --use-color'
|
|
|
|
# find alternative
|
|
if command -v fdfind 1> /dev/null; then
|
|
alias fd='fdfind'
|
|
alias fdh='fdfind -H'
|
|
fi
|
|
|
|
# shape the bandwidth allowd for a command with trickle: standalone, D:100KB/s, U10KB/s
|
|
if command -v trickle 1> /dev/null; then
|
|
alias slow='trickle -s -d 100 -u 10 -t 1'
|
|
fi
|
|
|
|
if command -v xclip 1> /dev/null; then
|
|
# shortcuts to copy/paste text contents
|
|
alias xclip-in-txt='xclip -in -rmlastnl -selection clipboard'
|
|
alias xclip-txt-out='xclip -out -rmlastnl -selection clipboard'
|
|
# shortcuts to copy/paste other contents
|
|
alias xclip-in-png='xclip -in -selection clipboard -t image/png'
|
|
alias xclip-in-jpeg='xclip -in -selection clipboard -t image/jpeg'
|
|
alias xclip-in-gif='xclip -in -selection clipboard -t image/gif'
|
|
alias xclip-in-webp='xclip -in -selection clipboard -t image/webp'
|
|
alias xclip-in-svg='xclip -in -selection clipboard -t image/svg'
|
|
alias xclip-in-ico='xclip -in -selection clipboard -t image/ico'
|
|
alias xclip-in-tiff='xclip -in -selection clipboard -t image/tiff'
|
|
alias xclip-out-png='xclip -out -selection clipboard -t image/png'
|
|
alias xclip-out-jpeg='xclip -out -selection clipboard -t image/jpeg'
|
|
alias xclip-out-gif='xclip -out -selection clipboard -t image/gif'
|
|
alias xclip-out-webp='xclip -out -selection clipboard -t image/webp'
|
|
alias xclip-out-svg='xclip -out -selection clipboard -t image/svg'
|
|
alias xclip-out-ico='xclip -out -selection clipboard -t image/ico'
|
|
alias xclip-out-tiff='xclip -out -selection clipboard -t image/tiff'
|
|
fi
|
|
|
|
# ps alternative on rust
|
|
if command -v procs 1> /dev/null; then
|
|
alias procs='procs --insert VmRss --insert VmSwap --insert Threads --insert Priority --insert ElapsedTime --insert State --sortd VmSwap'
|
|
fi
|
|
|
|
# ==============================
|
|
# New commands or external programs
|
|
# ==============================
|
|
|
|
# custom motd dashboard
|
|
if [[ -f "/etc/update-motd.d/00-motdfetch" ]]; then
|
|
alias motd='/etc/update-motd.d/00-motdfetch'
|
|
fi
|
|
|
|
# SSH and ET with MOTD
|
|
alias sshmotd='ssh -o SetEnv=SSH_MOTD=1'
|
|
if command -v et 1> /dev/null; then
|
|
alias etmotd='et --ssh-option SetEnv=SSH_MOTD=1'
|
|
fi
|
|
|
|
# open/attach to a default tmux session named local or ssh
|
|
if command -v tmux 1> /dev/null; then
|
|
alias tmux-local='systemd-run -q --scope --user tmux new-session -A -s local && exit'
|
|
alias tmux-ssh='systemd-run -q --scope --user tmux new-session -A -s ssh && exit'
|
|
fi
|
|
|
|
# vifm: tui file explorer
|
|
if command -v vifmrun 1> /dev/null && command -v vifm 1> /dev/null; then
|
|
alias vifm='vifmrun'
|
|
alias vf='vifmrun'
|
|
fi
|
|
|
|
# dragon for drag&drop function
|
|
if command -v dragon 1> /dev/null; then
|
|
alias drag='dragon --and-exit --on-top'
|
|
alias drop='dragon --and-exit --on-top --target'
|
|
fi
|
|
|
|
# glow: tui/cli markdown pager explorer
|
|
if command -v glow 1> /dev/null; then
|
|
alias glw='glow -l -p -w 80 -s dark'
|
|
fi
|
|
|
|
if command -v tidy-viewer 1> /dev/null; then
|
|
alias tv='tidy-viewer'
|
|
fi
|
|
|
|
# HLEDGER
|
|
if command -v hledger 1> /dev/null; then
|
|
export LEDGER_FILE=$HOME/.finance/$(date +"%Y").journal
|
|
fi
|
|
|
|
# get local meteo for 3 days
|
|
alias meteo='echo -e "┌─────────┐\n│ wttr.in │ ${MYCITY}:\n└─────────┘\n" && curl "wttr.in/$(echo ${MYCITY} | tr " -" "+")?mM2FQ&lang=${LANGUAGE/*:}"'
|
|
|
|
# mimic3: tts interactive command, just paste text inside
|
|
if command -v mimic3 1> /dev/null; then
|
|
alias mimic3-fr='mimic3 --voice fr_FR/tom_low --play-program paplay --interactive'
|
|
alias mimic3-en='mimic3 --voice en_US/ljspeech_low --play-program paplay --interactive'
|
|
alias mimic3-pl='mimic3 --voice pl_PL/m-ailabs_low --play-program paplay --interactive'
|
|
fi
|
|
|
|
# Neomutt, notmuch, mbsync
|
|
if command -v neomutt 1> /dev/null; then
|
|
alias ntt='neomutt -f "📫Boite à lettres"'
|
|
if command -v notmuch 1> /dev/null && command -v mbsync 1> /dev/null; then
|
|
# Sync all Mailboxes, Notmuch and Afew, then launch Neomutt
|
|
alias ntt-sync='notmuch new && mbsync mutt && notmuch new && neomutt -f "📫Boite à lettres"'
|
|
# Sync some Mailboxes, Notmuch and Afew, then launch Neomutt
|
|
alias ntt-sync-base='notmuch new && mbsync mutt-fast && notmuch new && neomutt -f "📫Boite à lettres"'
|
|
# Reindex Notmuch and Afew for main, then launch Neomutt
|
|
alias ntt-index='notmuch new && neomutt -f "📫Boite à lettres"'
|
|
fi
|
|
if command -v msmtp-queue 1> /dev/null; then
|
|
# Flush send mail queue with msmtpq, then launch Neomutt
|
|
alias ntt-flush='msmtp-queue -r && neomutt -f "📫Boite à lettres"'
|
|
fi
|
|
fi
|
|
|
|
# Display webcam output with MPV
|
|
if command -v mpv 1> /dev/null && [[ -c "/dev/video0" ]]; then
|
|
alias mpv-webcam='mpv av://v4l2:/dev/video0 --profile=low-latency --untimed'
|
|
if [[ -c "/dev/video2" ]]; then
|
|
alias mpv-fakecam='mpv av://v4l2:/dev/video2 --profile=low-latency --untimed'
|
|
fi
|
|
fi
|
|
|
|
# easy downloads with yt-dlp
|
|
if command -v yt-dlp 1> /dev/null && command -v ffmpeg 1> /dev/null; then
|
|
alias yt-audio-low='yt-dlp --no-update --socket-timeout 50 --force-ipv4 --limit-rate 1M --downloader wget --paths ${XDG_DOWNLOAD_DIR} --quiet --progress --prefer-free-formats --check-formats --format worstaudio'
|
|
alias yt-video-medium='yt-dlp --no-update --socket-timeout 50 --force-ipv4 --limit-rate 1M --downloader wget --paths ${XDG_DOWNLOAD_DIR} --quiet --progress --prefer-free-formats --check-formats --format "bestvideo[height<=?360][vbr>100][vbr<500]+worstaudio"'
|
|
fi
|
|
|
|
# to reconnect by tcp:5555 to the adb device currently tethering
|
|
if command -v adb 1> /dev/null; then
|
|
alias adb-reconnect='adb disconnect; adb connect $(ip route | egrep "^default" | awk "{print \$3}"):5555'
|
|
fi
|