# https://github.com/LukeSmithxyz/voidrice/blob/master/.config/shell/aliasrc
for cmd in hardcode-fixer ventoy units_cur fbgrab powertop nft rpi-imager fdisk dmesg; do
alias $cmd="sudo $cmd"
done
for cmd in pacdiff visudo; do
alias $cmd="sudo -E $cmd"
done
for cmd in loop o 'watch -c'; do
alias ${cmd%% *}="$cmd "
done
unset cmd
# note: the following code pipe to while read will not work, because pipe create subshell
#git -C "$HOME/programs/config_local_arch" branch | awk '{print ($1=="*")?$2:$1}' | grep -v master | while read -r branch; do
# `man bash`: "Each command in a multi-command pipeline, where pipes are created, is executed in a subshell, which is a separate process."
# https://stackoverflow.com/questions/56327528/bash-aliases-set-in-while-loop-not-persisting
# can be tested via $BASHPID, note $$ will not work, because $$ does not show subshell pid
# another way is: echo "$(exec sh -c 'echo "$PPID"')"
# `man bash`:
# > BASHPIP Expands to the process ID of the current bash process. This differs from $$ under certain circumstances, such as subshells that do not require bash to be re-initialized.
# > $ Expands to the process ID of the shell. In a subshell, it expands to the process ID of the current shell, not the subshell.
# https://unix.stackexchange.com/questions/484442/how-can-i-get-the-pid-of-a-subshell
for branch in $(git -C "$HOME/programs/config_local_arch" branch | awk '{print ($1=="*")?$2:$1}' | grep -v master); do
case "$branch" in
master|pp) ;;
*) alias "s$branch"="ssh $branch";;
esac
done
unset branch
# different name
alias a=alarm
# /dev/ttyACM0 can be in config file, or as environmantal variable, see /usr/share/doc/adafruit-ampy/README.md
#alias ap='ampy -p /dev/ttyACM0'
alias b='lsblk -o NAME,FSTYPE,FSVER,LABEL,UUID,FSAVAIL,FSUSED,FSUSE%,MOUNTPOINTS'
alias c=cfg
#alias cr=curl
alias cri='curl -Is'
alias crig='curl -Is www.google.com'
alias d='sdcv --color'
# Using '"$PAGER"' will cause complete-alias unable to complete "e <tab>" and
# "e --<tab>". I don't know why alias v='"$EDITOR"' does not have this issue, I
# guess maybe it is related to less has some fzf completion? see `complete -p
# less` output is "complete -F _fzf_path_completion less". Temporary ignore
# shellcheck warnings about this if not met any issues.
alias e="$PAGER"
# https://superuser.com/a/1202867
alias fdu="find . -maxdepth 1 -execdir du -sh '{}' \+ | sort -h"
alias g=git
alias gcd='git clone --depth=1'
alias gr='grep --color=auto -i'
alias grr='grep --color=auto -iIR'
alias h=htop
alias i=nsxiv
alias j=journalctl
alias ju='journalctl --user'
alias l='ls --color=auto -A --group-directories-first'
alias ll='ls --color=auto -lAh --group-directories-first'
#alias lo=loop
alias lop='loop ping'
alias lopd='loop ping 9.9.9.9'
alias m=man
alias mpf='mpra -c "$HOME/programs/repos/fly/any/fsh-git"; sudo pacman -Sy fsh-git --noconfirm'
alias p=pacman
# Pacman Qqne Redirect
alias pqr='pacman -Qqne > "$XDG_CONFIG_HOME/myconf/pacman_Qqne"; pacman -Qqme > "$XDG_CONFIG_HOME/myconf/pacman_Qqme"'
alias pt=pactree
alias pu=paru
alias qre='qrencode -t utf8i -m 1'
alias r='rem -cu+2 -@'
# https://askubuntu.com/a/22043
alias s='sudo '
alias sa='ssh-add -l || ssh-add'
alias se='sudo -E '
alias sp='ssh pp'
alias spd='speedtest; librespeed-cli'
# can test this mess with `alias tt='echo "\$haha \"lala\""'`
alias sun='printf "set \$Longitude \"120.95\"\nset \$Latitude \"31.38\"\nrem [sunrise()] msg sunrise\nrem [sunset()] msg sunset" | remind -n -'
# another way:
# can test this mess with `alias tt="echo '\$haha \"lala\"'"`
#alias sun="printf 'set \$Longitude \"-121.89\"\nset \$Latitude \"37.34\"\nrem [sunrise()] msg sunrise\nrem [sunset()] msg sunset' | remind -n -"
alias sv=sudoedit
alias y=systemctl
alias yd='systemctl list-dependencies --all'
alias ydr='systemctl list-dependencies --all --reverse'
alias ye='systemctl list-unit-files --state=enabled'
# sYstemctl Enabled Redirect
alias yer='systemctl list-unit-files --state=enabled > "$XDG_CONFIG_HOME/myconf/sye"; systemctl --user list-unit-files --state=enabled > "$XDG_CONFIG_HOME/myconf/syue"'
alias yr='systemctl restart'
alias ys='systemctl status'
alias yu='systemctl --user'
alias yue='systemctl --user list-unit-files --state=enabled'
alias yus='systemctl --user status'
alias v='"$EDITOR"'
alias va='"$EDITOR" "$XDG_DOCUMENTS_DIR/notes/computer/arch_install.md"'
alias vc='"$EDITOR" "$XDG_DOCUMENTS_DIR/notes/computer/cli_notes.md"'
alias vd='vidir'
alias vd2='vidir2 --linktargets'
alias vq='"$EDITOR" "$XDG_DOCUMENTS_DIR/notes/others/questions_ideas_tips.md"'
alias vn='"$EDITOR" "$(find "$XDG_DOCUMENTS_DIR/notes" -mindepth 1 -path "*/\.git" -prune -o -type f -print | fzf)"'
alias vni='"$EDITOR" -ni NONE'
alias vr='"$EDITOR" "$DOTREMINDERS"'
alias vrc='"$EDITOR" +e\ \$MYVIMRC'
alias vrm='"$EDITOR" "$XDG_DOCUMENTS_DIR/notes/others/recurring_maintenance.md"'
alias vt='"$EDITOR" "$XDG_DOCUMENTS_DIR/notes/others/tmp_mobile_notes.md"'
alias xmr='monero-wallet-cli --config-file="$HOME/.bitmonero/monero-wallet-cli.conf"'
alias xmrds='monerod status; monerod print_net_stats'
alias xr='xset r rate 250 30'
alias za='zoxide add'
#alias zq='zoxide query'
#alias zqi='zoxide query -i'
# same name
alias absolutely-proprietary='echo n | absolutely-proprietary -f'
alias alsamixer='alsamixer -V all'
# I can't find a quick and easy way to temperory disable cloc config file except to change config file. Using an alias can disable --vcs with just \cloc.
alias cloc='cloc --vcs auto'
alias diff='diff --color=auto'
alias glmark2='glmark2 --fullscreen --annotate'
alias grep='grep --color=auto'
#alias info='info --vi-keys'
alias ls='ls --color=auto'
alias radeontop='radeontop -c'
alias rem='rem -@'
alias remind='remind -@'
alias rm='rm -I'
alias sdcv='sdcv --color'
alias shellcheck='shellcheck -x'
alias tree='tree -aC -I .git | "$PAGER"'
alias uname='uname -a'
alias vkmark='vkmark --fullscreen'
# deprecated
# all green color, no auto turn off color when pipe to nvim
#alias pactree='pactree -c'
不用记啊,这都是我自己选择的别名,因为命令用的多了不想每次打太多字所以我就会选择一个短的别名拿来用,好叭,虽然是自己选的,也是需要稍稍记一丢丢的
我以前闲着没事喜欢用以下命令筛选出我常用的需要打很多字的命令:
然后我会选择一个短的别名,我的别名选择逻辑是尽量短,首先先选择第一个字母,例如sudo我选择了s,若是第一个字母的别名被用了,我会选择两个字母的,例如systemctl我选择了sy,两个字母的别名有时我喜欢选择头两个字母,有时我喜欢选择两个音节或单词的首字母,以此类推会有3个字母甚至更多字母的别名,因为有时候2个字母的别名也被占用了,我脚本的命名逻辑也大差不离,当然古早时期我并不遵循这个逻辑,就会有些比较长名字的别名和脚本
某种意义上我是一半活在终端里的人,很多软件我都只用cli命令行或TUI终端界面而不是GUI图形界面,比如我的纯文本编辑器是neovim是TUI,邮箱客户端是neomutt是TUI,我一般不用文件管理器而是用cd和zoxide都是cli但偶尔会用lf是TUI,密码管理器是pass是cli,词典是sdcv是cli,日历是remind是cli,音乐播放器是mpv是cli,视频播放器是mpv是伪GUI,计算器是bc是cli,单位/货币转换是units是cli,多媒体格式转换是ffmpeg是cli,文档格式转换是pandoc是cli,资源管理器是htop-vim是TUI,天气预报用我的wtr脚本是cli,等等等
收藏备用