社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
系统:
CentOS6.5,CentOS6.9,CentOS7.4 (64位操作系统)
Shell:
bash,强烈推荐zsh,玛尼?没听说过?池建强大神的博客推荐一下: 终极 Shell
有人说顶级程序员可以顶得上100个初级程序员,好多人不信,这!里!让!你!相!信!一!下!
autojump是什么
autojump是一个Linux命令行工具,它允许你通过模糊匹配就可以一步跳转到想要的目录,不管你在哪里(目录)!是不是很神奇?是不是比cd``````tab
这些命令好用百倍?OK,下面介绍一下autojump
的安装、配置及使用
通过yum
安装基本安装不上,应该是yum
源里没有,去网上看了下也没有找到autojump
的yum
源,这里通过git
安装
autojump
git clone git://github.com/joelthelion/autojump.git
先跳转到autojump的根目录下
cd autojump/
安装:
./install.py
或者
python install.py
还是把安装日志附上吧
[root@data3 autojump]# ./install.py
Installing autojump to /root/.autojump ...
creating directory: /root/.autojump/bin
creating directory: /root/.autojump/share/man/man1
creating directory: /root/.autojump/etc/profile.d
creating directory: /root/.autojump/share/autojump
copying file: ./bin/autojump -> /root/.autojump/bin
copying file: ./bin/autojump_argparse.py -> /root/.autojump/bin
copying file: ./bin/autojump_data.py -> /root/.autojump/bin
copying file: ./bin/autojump_match.py -> /root/.autojump/bin
copying file: ./bin/autojump_utils.py -> /root/.autojump/bin
copying file: ./bin/icon.png -> /root/.autojump/share/autojump
copying file: ./docs/autojump.1 -> /root/.autojump/share/man/man1
creating directory: /root/.autojump/etc/profile.d
creating directory: /root/.autojump/share/autojump
creating directory: /root/.autojump/functions
copying file: ./bin/autojump.sh -> /root/.autojump/etc/profile.d
copying file: ./bin/autojump.bash -> /root/.autojump/share/autojump
copying file: ./bin/autojump.fish -> /root/.autojump/share/autojump
copying file: ./bin/autojump.zsh -> /root/.autojump/share/autojump
copying file: ./bin/_j -> /root/.autojump/functions
Please manually add the following line(s) to ~/.bashrc:
[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
Please restart terminal(s) before running autojump.
根据安装日志的提示,在.bashrc文件里添加下面的配置
[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
source一下就行了
source .bashrc
autojump会在你每次启动命令时记录你当前的位置,并把它添加到自身的数据库。
这样哪个目录使用的次数越多,表示这个目录越重要,权重越大,进行模糊跳转的时候输入得越简单。
使用方式
autojump pattern
**autojump 也可以缩写为j **
pattern就是要跳转的目录的模糊匹配
不太明白?好,来个Demo
比如说你经常使用的一个目录为:/home/java/apache-tomcat-8.5.16-case/webapps/case/WEB-INF/classes/config
使用命令
j co
就可以直接跳转到该目录下
j是autojump
的简写
co是config
目录的简写
当然如果这个目录你使用得特别特别多的话使用j c也是可以的
如果使用得没有那么多的话j co可能匹配到其他的目录上,这个时候你可能就需要输入j config
了
另外你刚刚安装好的时候是不能直接使用的,autojump
不知道你经常使用哪个目录,怎么给你跳转?用一会儿就行了
你还可以查看一下当前多个目录的权重
j --stat
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!