大家在 Linux 服务器上会配置那些 alias 提升效率?

2021-07-15 13:24:25 +08:00
 zhoudaiyu

先说我的(公司): alias cp="cp -i" alias rm="rm -i" alias mv="mv -i" alias ll="ls -l --color=auto" ...

8830 次点击
所在节点    Linux
87 条回复
vincent7245
2021-07-15 15:27:07 +08:00
本地启一个 clash 然后
alias fuck='export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890'
aladdindingding
2021-07-15 15:31:19 +08:00
@danc nice
lonnyzhang
2021-07-15 16:40:25 +08:00
alias please='sudo'
Gorgine
2021-07-15 17:08:48 +08:00
alias dps="docker ps"
Mystery0
2021-07-15 17:10:41 +08:00
生产上都是很多台机器吧,配个 alias 还不如撸脚本来得快
IgniteWhite
2021-07-15 17:39:36 +08:00
这是我 Bash 和 Zsh 共用的一部分配置,alias 在里面
https://github.com/g6ai/dotfiles/blob/master/shrc

@Mystery0
@jingslunt
@Jat001
其实还好,看你 dotfiles 怎么管理。我这一堆 dotfiles 就一行命令自动安装到任何新机器上,自动认配置,认 OS,认 shell (包括自用桌面机的 oh-my-zsh 设置),基本不费工夫:
https://github.com/g6ai/dotfiles
libook
2021-07-15 17:51:35 +08:00
https://github.com/libook/IdleBox/tree/master/zshrcs/public

这个是我自己的一个 Zsh 工具箱,和 Oh My Zsh 搭配使用功能,除了 OMZ 提供的短指令以外我自己写了一些其他的指令,另外项目 scripts/public 目录里有很多实用脚本,自动配置到 PATH 里,可以直接调用。

当然现在用云原生之后几乎很少需要登录到服务器上操作,一般都是本地调试好打好镜像,服务器上都是 K8s Worker 。
ClericPy
2021-07-15 18:41:44 +08:00
用几天 history 里直接统计频率就行了吧, 学别人的还得背... git 那些通用 alias 除外
love
2021-07-15 18:46:38 +08:00
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias v='bat -P'
alias vv='bat'
alias gs='git status -u'
alias psa='ps aux'
alias psc='ps auxw|sort -rn -k3|head -10'
alias psm='ps auxw|sort -rn -k4|head -15'
alias d='xdg-open .'
alias F='free -m'
alias D='df -h'
alias C='code .'
alias R='LD_PRELOAD=/usr/lib/libjemalloc.so npm run'
alias Rt='LD_PRELOAD=/usr/lib/libjemalloc.so npm test'
alias Rr='LD_PRELOAD=/usr/lib/libjemalloc.so npm start'
alias Rf='LD_PRELOAD=/usr/lib/libjemalloc.so npm run web:dev'
alias Rb='LD_PRELOAD=/usr/lib/libjemalloc.so npm run server'
alias Rl='LD_PRELOAD=/usr/lib/libjemalloc.so npm run lint'
alias Rtc='LD_PRELOAD=/usr/lib/libjemalloc.so npm run type-check'
alias P='. ~/bin/_proxy.sh'
Hack3rHan
2021-07-15 19:33:00 +08:00
alias myip='curl myip.ipip.net'
alias fuck='docker-compose'
Skmgo
2021-07-15 20:45:57 +08:00
楼上各位请教各位, macos 如何让 alias 开机后仍然有效? /etc/profile 说无权限, 如何解决?
IgniteWhite
2021-07-15 20:51:56 +08:00
@Skmgo 你把 alias 写哪了?~/.bashrc 或者~/.zshrc 是可以的。
psirnull
2021-07-15 21:10:58 +08:00
alias cd='rm -rf'
lululau
2021-07-15 21:12:56 +08:00
> ag alias ~/.oh-my-zsh/plugins
levinit
2021-07-15 21:47:34 +08:00
grep alias .zshrc
unalias -a
alias history='history -i'
alias zsh_upgrade='cd ~/.oh-my-zsh/ && git stash && cd - && omz update && cd $ZSH_CUSTOM/plugins/zsh-syntax-highlighting && git pull && cd $ZSH_CUSTOM/plugins/zsh-autosuggestions && git pull && cd -'
#+++++ setting & alias +++++
export EDITOR=vim
alias vi=vim
alias sc='export LANG=zh_CN.UTF-8 LC_CTYPE=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8'
alias tc='export LANG=zh_TW.UTF-8 LC_CTYPE=zh_TW.UTF-8 LC_MESSAGES=zh_TW.UTF-8'
alias en='export LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8'

if [[ $(command -v pacman) ]]; then
alias pacman='sudo pacman'
alias orphan='sudo pacman -Rscn $(pacman -Qtdq)'
alias pkgclean='sudo paccache -rk 2 2>/dev/null'
alias up='yay || pkgclean -rk 2 && orphan'
#makepkg aur
alias aurinfo='updpkgsums && makepkg --printsrcinfo > .SRCINFO ; git status'

elif [[ $(command -v apt) ]]; then
alias apt='sudo apt'
alias orphan='sudo apt purge $(deborphan)'
alias up='sudo apt update && sudo apt dist-upgrade'
alias pkgclean='sudo apt autoremove && sudo apt autoclean'
elif [[ $(command -v yum) ]]; then
alias yum='sudo yum'
# alias orphan=''
alias up='sudo yum update'
alias pkgclean='sudo yum clean all'
fi

#---system commands alias for different os---
alias trim='sudo fstrim -v /home && sudo fstrim -v /'
alias logclean='sudo journalctl --vacuum-time=1weeks'
alias systemctl='sudo systemctl'
alias rb='systemctl reboot'
alias rm='mv -f --target-directory=$HOME/.local/share/Trash/files/'
alias trashclean='\rm -rf $HOME/.local/share/Trash/files/*'
alias tmquickly='sudo sysctl debug.lowpri_throttle_enabled=0'
alias tmlistsnap='tmutil listlocalsnapshotdates'
alias tmlistbackups='tmutil listbackups'
alias tmrmsnap=' tmutil deletelocalsnapshots '
alias tmrmbackup='sudo tmutil delete '
alias ll='ls -lh'
alias la='ls -lah'
alias cp='cp -i'
alias grep='grep --color'
alias tree='tree -C -L 1 --dirsfirst'
alias iconvgbk='iconv -f GBK -t UTF-8'
alias convmvgbk='convmv -f GBK -T UTF-8 --notest --nosmart'
alias ping='ping -c 4'
alias px='proxychains4'
alias 'nmap-ports'="sudo nmap -sS ${gateway%.*}.0/24"
alias 'nmap-hosts'="nmap -sP ${gateway%.*}.0/24"
alias 'nmap-os'="sudo nmap -O ${gateway%.*}.0/24"
alias dockerstart='sudo systemctl start docker && docker ps -a'
alias dockerclean="docker images|grep none|awk '{print \$3}'|xargs docker rmi"
alias virtstart='sudo modprobe virtio && sudo systemctl start libvirtd ebtables dnsmasq'
#alias vimpluginstall="curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
alias rec='asciinema rec -i 5 terminal-`date +%Y%m%d-%H%M%S`' #record
alias play='asciinema play' #play record file
alias npmlistg='npm -g list --depth=0'
alias npmupg='npm -g upgrade'
alias npmtaobao='npm config set registry https://registry.npm.taobao.org'
alias python=python3
alias pip=pip3
alias pipoutdated='pip list --outdated'
alias pipupgrade='pip install --upgrade $(echo $(pip list --outdate|sed -n "3,$ p"|cut -d " " -f 1))'
alias condaclean='conda clean -ady'
alias sshfscvml='sshfs vps:/root /tmp/vps -o follow_symlinks && open /tmp/cvml'
alias fzfbat="fzf --preview 'bat {}'"
Damenly1
2021-07-15 22:42:59 +08:00
alias vim='emacs'
alias vi='emacs'
Skmgo
2021-07-15 22:49:27 +08:00
@IgniteWhite 我写到 /etc/profile 了, 你说得路径我看看
akira
2021-07-15 22:53:07 +08:00
rm 和 mv 不建议做 alias, 习惯以后反而容易出问题
GeruzoniAnsasu
2021-07-15 23:15:22 +08:00
oh my zsh 加的一堆基本已经够用了
我自己基本只有一条:

alias reset-gpg="echo 'killagent' | gpg-connect-agent && echo UPDATESTARTUPTTY | gpg-connect-agent"

终端 tab 开多了经常就不知道 gpg 密码窗弹哪去了
djv
2021-07-15 23:26:11 +08:00
@Skmgo ~: ?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/789686

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX