当前位置: 首页 > article >正文

mac控制台命令小技巧

shigen日更文章的博客写手,擅长Java、python、vue、shell等编程语言和各种应用程序、脚本的开发。记录成长,分享认知,留住感动。

hello伙伴们,作为忠实的mac骨灰级别的粉丝,它真的给我带来了很多效率上的提升。那作为接触的最多的软件之一——终端,其实shigen每天80%的时间都在终端上倒腾的,运行我的各种脚本工具。那效率肯定得提上上去了,shigen的电脑终端就很丝滑。

首先,答应我;不要再使用系统的终端了,使用 iterm2吧,它的功能很强大,而且支持很多自定义的配置。

shigen的iterm2

当然,为了酷炫,实际的并没有这么的花哨。

好了工具有了,那怎么提升效率呢?今天的分享主要是alias有关,也是shigen在实习的时候,跟着我的运维伙伴学到的。

我的alias

alias mci="mvn clean install"

# some alias
alias g=git
alias ga='git add'
alias gaa='git add --all'
alias gap='git add --patch'
alias gb='git branch'
alias gba='git branch -a'
alias gbr='git branch --remote'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gcl='git config --list'
alias gclean='git reset --hard && git clean -dfx'
alias gcm='git checkout master'
alias gcmsg='git commit -m'
alias gco='git checkout'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gcs='git commit -S'
alias gd='git diff'
alias gdc='git diff --cached'
alias gdt='git difftool'
alias gg='git gui citool'
alias gga='git gui citool --amend'
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
alias ggpull='git pull origin $(current_branch)'
alias ggpur='git pull --rebase origin $(current_branch)'
alias ggpush='git push origin $(current_branch)'
alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias gk='gitk --all --branches'
alias gl='git pull'
alias glg='git log --stat --max-count=10'
alias glgg='git log --graph --max-count=10'
alias glgga='git log --graph --decorate --all'
alias glo='git log --oneline --decorate --color'
alias globurl='noglob urlglobber '
alias glog='git log --oneline --decorate --color --graph'
alias glp=_git_log_prettily
alias gm='git merge'
alias gmt='git mergetool --no-prompt'
alias gp='git push'
alias gpoat='git push origin --all && git push origin --tags'
alias gr='git remote'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbi='git rebase -i'
alias grep='grep  --color=auto --exclude-dir={.bzr,.cvs,.git,.hg,.svn}'
alias grh='git reset HEAD'
alias grhh='git reset HEAD --hard'
alias grmv='git remote rename'
alias grrm='git remote remove'
alias grset='git remote set-url'
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
alias grup='git remote update'
alias grv='git remote -v'
alias gsd='git svn dcommit'
alias gsps='git show --pretty=short --show-signature'
alias gsr='git svn rebase'
alias gss='git status -s'
alias gst='git status'
alias gsta='git stash'
alias gstd='git stash drop'
alias gstp='git stash pop'
alias gsts='git stash show --text'
alias gts='git tag -s'
alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
alias gup='git pull --rebase'
alias gvt='git verify-tag'
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git ls-files --deleted -z | xargs -r0 git rm; git commit -m "--wip--"'
alias history='fc -l 1'
alias l='ls -lah'
alias la='ls -lAh'
alias ll='ls -lh'
alias ls='ls -G'
alias lsa='ls -lah'
alias po=popd
alias pu=pushd
alias v='f -e vim'

别小看短短的82行,可以实现的效率简直是提升了很多,下边shigen演示一下。

  • 查看文件的列表信息

查看文件列表

  • 查看git历史

查看git历史

就先选取两个作为参考的案例啦,当然,还有很多实际的操作,这里偏重的是gitls命令的封装。

其实shigen也自定义了脚本的命令,来一起看看吧。


那我常用的python脚本查看IP地址为例,我用的时候只需要一个命令即可:

IP查询工具

but,我要是使用python命令去敲就麻烦了!

原生的python命令

那具体咋设置的呢,分享出来:

~/.bash_profile中添加如下的命令即可:

alias ip-util="python3 ~/PycharmProjects/shigen-util/iputil/xdbSearcher.py"

接下来执行这个命令:

source ~/.bash_profile

怎么查看ip-util是啥呢?

which ip-util

which命令

这样你就可以高效的操作命令了,接下来效率直接拉满。

最后,最后再分享一个shigen觉得很有意思的命令:

history | awk '{CMD[$2]++;count++;} END { for (a in CMD )print CMD[ a ]" " CMD[ a ]/count*100 "% " a }' | grep -v "./" | column -c3 -s " " -t |sort -nr | nl | head -n10

将这一行命令粘贴到控制台就可以看出我们使用的历史命令的top榜。

历史命令top榜单

这样,就可以把我们常用的命令再次alias一下,我们的效率就提升啦。


以上就是今天分享的全部内容了,觉得不错的话,记得点赞 在看 关注支持一下哈,您的鼓励和支持将是shigen坚持日更的动力。同时,shigen在多个平台都有文章的同步,也可以同步的浏览和订阅:

平台账号链接
CSDNshigen01shigen的CSDN主页
知乎gen-2019shigen的知乎主页
掘金shigen01shigen的掘金主页
腾讯云开发者社区shigenshigen的腾讯云开发者社区主页
微信公众平台shigen公众号名:shigen

shigen一起,每天不一样!


http://www.kler.cn/news/133885.html

相关文章:

  • SQLite3 数据库学习(文章链接汇总)
  • 卷积神经网络(VGG-16)海贼王人物识别
  • CSS英文单词强制截断换行
  • 开拓经验专栏:从十来天的晨型人体验开始
  • Linux命令(125)之scp
  • 被锁总时间
  • 数据结构:红黑树的插入实现(C++)
  • 坐标系下的运动旋量转换
  • SingleTreePolicyInterpreter
  • k8s pod 处于Terminating的原因分析和解决处理——筑梦之路
  • 【Go入门】 Go的http包详解
  • QtC++与QUndoView详解
  • lv11 嵌入式开发 ARM指令集中(伪操作与混合编程) 7
  • P1304 哥德巴赫猜想
  • Fork/Join框架说明
  • OpenAI Assistants-API简明教程
  • 【人工智能Ⅰ】7-KNN 决策树
  • C复习-输入输出函数+流
  • MyBatis整合Spring Boot扫描Mapper相关配置
  • 在Ubuntu上用sane api实现通用扫描功能
  • Python OpenCV调整图像亮度对比度及RGB色彩
  • C++ ,VCPKG那些事
  • Linux终端与交互式Bash
  • 【数据分享】2023年我国省市县三级的独角兽企业数量(Excel/Shp格式)
  • 23111709[含文档+PPT+源码等]计算机毕业设计基于Spring Boot智能无人仓库管理-进销存储
  • 深度学习入门(第二天)——走进深度学习的世界 神经网络模型
  • 中级程序员——vue3+js+git面试题
  • 汽车虚拟仿真视频数据理解--CLIP模型原理
  • 【华为OD机试高分必刷题目】洗衣服(JavaPythonC++贪心算法实现)
  • 【数据结构(二)】单链表(3)