你给 Shell 配置了哪些 alias?

2019-09-04 23:14:11 +08:00
 wuhuaji

刚写的一篇博文,记录我积累的一些 alias,自觉日积月累还是能省下不少时间。

分享到这里,我定义的部分通用 alias :

alias pg='ps aux | grep $1'
//查找进程,通过 ps aux | grep xxx,来查找进程应该是个非常高频的操作,自定义了一个`pg`来代替,非常省事。eg: pg nginx

alias untar='tar -zxvf' #解压 tar

alias msq='mysql -uroot -pPASSPWORD'
#本地有一个 MySQL 测试用,而命令行中是进 MySQL 也是比较高频的操作,直接配一个 msq 操作

alias sshxxx='ssh wuhuaji@xxx.xxx.xxx.xxx'
#登录远程机器,通过设置别名,拷贝密钥之后登录机器就是敲几个字的事

alias mem="telnet 127.0.0.1 11211"
#公司在用 memcached,配置 mem 直接连接 memcached

alias python='python3'
#避免每次写敲 python 运行的是 Python 2

# git 的一些快捷操作
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gpo='git push origin master'
alias gpd='git push origin dev'
alias gpu='git pull upstream master'

#前端开发
alias nrs='npm run serve'
alias nrb='npm run build'

# 也写一点 laravel
alias art="php artisan"
alias phpunit='./vendor/bin/phpunit'
alias tinker='php artisan tinker'
alias migrate="php artisan migrate"

V 友们定义了哪些高效的 alias,分享一下 :)

4092 次点击
所在节点    问与答
35 条回复
noqwerty
2019-09-04 23:27:42 +08:00
ssh 那个利用 ~/.ssh/config 更合理吧。Git 相关的我基本靠 zsh 或者 fish shell
GoLand
2019-09-04 23:29:46 +08:00
alias random-str="base64 /dev/urandom | tr -d '/+' | dd bs=32 count=1 2>/dev/null"
alias myip="curl 'http://ip.taobao.com/service/getIpInfo2.php' --data 'ip=myip'"
alias gfw="export all_proxy=http://127.0.0.1:1087"
alias ugfw="unset all_proxy"

几个比较常用的
shakespaces
2019-09-04 23:31:12 +08:00
ssh 那个应该在 config 里配置比较好,配好直接 ssh xxx 就可以了
whoami9894
2019-09-04 23:38:27 +08:00
pg 不错,学到了
lostberryzz
2019-09-04 23:54:21 +08:00
curl -s myip.ipip.net | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
curl -s ip111cn.appspot.com | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1, 3}\b"

分享两个获取国内和国际 IP 的 alias
msg7086
2019-09-04 23:59:16 +08:00
sss='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
rcc='rclone copy --progress --drive-chunk-size=256M --transfers 1 --stats-file-name-length 80'

话说你都提到 ssh 密钥登录了,MySQL 倒是没有配置成 socket 认证免密登录?
wuhuaji
2019-09-05 00:05:37 +08:00
@noqwerty @shakespaces 其实我是不知道到 .ssh/config (其实以前是知道的,后面不知道怎么搞忘了),学到了,确实配在 .ssh/config 更合理 :)


@GoLand gfw 这个很实用啊!@lostberryzz 我也配了一个获取 ip 的,但我用的不多,就没发出来。


@msg7086 其实我是没配置过 MySQL 免密登录,改天试着配下 :)
weixiangzhe
2019-09-05 00:09:51 +08:00
大部分都是自定义的玩意


# 开启代理
alias http_proxy="export ALL_PROXY=socks5://127.0.0.1:1080 && curl ipinfo.io"
# 用 nvim 代替 vim
alias vim='nvim'

# ---- 之前 mac 的习惯 ---
# xdg-open 到 open
alias open='xdg-open '
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias say='echo "$1" | espeak -s 120 2>/dev/null'

# 查单词
alias s='ydcv'

# 直接运行下 ts
alias tscRun='tsc $1 && node ${1%%.ts}'

# 重置下键位
alias resetKeys='/home/aizigao/.xkb/xcape_set'

# 更新 arch 的中国源
alias update-pacman-mirrors='sudo pacman-mirrors -i -c China -m rank'

# 同步下个人笔记
alias syncNote='cd ~/MyWorkPlace/boostNote && gaa && gc -m sync && gl && gp && cd -1'
wuhuaji
2019-09-05 00:14:01 +08:00
@weixiangzhe 写文本笔记手动同步么?
weixiangzhe
2019-09-05 00:16:11 +08:00
@wuhuaji 恩呢 对的
AlphaTr
2019-09-05 00:19:05 +08:00
alias cd='rm -rf'
AEANWspPmj3FUhDc
2019-09-05 01:46:18 +08:00
赞同楼上 ssh 在 ~/.ssh/config 中配置更好。
同理,git 的配置放在 .gitconfig 中更好。
MrGba2z
2019-09-05 02:07:56 +08:00
profilegem
没验证发不了 bitbucket 的链接。。
wuhuaji
2019-09-05 07:47:57 +08:00
@ivlioioilvi git 配在 gitconfig 中,敲命令需要 git 前缀吧,git xxx 这样,觉得有点麻烦直接配在 shell 中了
gIrl1990
2019-09-05 07:54:03 +08:00
fish shell 一把梭, 不用配置~
ech0x
2019-09-05 07:54:21 +08:00
自己写的 alias 只有 vim=nvim
Mac 上推荐 给 open -a XXXX 写个函数
mcfog
2019-09-05 07:58:42 +08:00
alias 这个东西吧,很多时候是欺骗自己高效
ssh 有人说了我说点别的
pg: 了解一下 pgrep 和 pkill
untar:z 可以省略 v 基本上是污染屏幕,这个命令很好背:eXtract File -xf,Create File -cf
msq:不说免密,用密码也可以写在 dotfile 里面
nrs:我喜欢 yarn 的优点之一就是不用打 run
WildCat
2019-09-05 08:03:12 +08:00
alias rm=trash
tuding
2019-09-05 08:17:01 +08:00
不习惯用 alias
tt67wq
2019-09-05 08:17:42 +08:00
alias aget="aria2c --conf=$HOME/.aria2/aria2.conf"

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

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

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

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

© 2021 V2EX