> 文章列表 > 【Linux 常用shell 目录任意跳转命令 -- autojump】

【Linux 常用shell 目录任意跳转命令 -- autojump】

【Linux 常用shell 目录任意跳转命令 -- autojump】

文章目录

autojump 使用方法

autojump 是一个类似于 cd 命令的工具,它可以快速定位到目录或者文件,其实现的基本原理是由于autojump维护了一个目录访问历史表,如果出现目录名同名的情况,autojump 会根据不同目录的访问频率来设置对应的权重,权重高的优先进入。

工具下载链如下:
git clone git@github.com:wting/autojump.git
在这里插入图片描述

用户可以按照下面命令进行安装:

  1. 工具下载
zhugong@ubuntu:~$ cd ~
zhugong@ubuntu:~$ git clone git@github.com:wting/autojump.git
Cloning into 'autojump'...
remote: Enumerating objects: 3289, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 3289 (delta 0), reused 4 (delta 0), pack-reused 3280
Receiving objects: 100% (3289/3289), 809.05 KiB | 873.00 KiB/s, done.
Resolving deltas: 100% (1985/1985), done.
  1. 安装
cd autojump
./install.py or ./uninstall.py
  1. 安装完成及 ~/.bashrc 配置:
Installing autojump to /home/zhugong/.autojump ...
creating directory: /home/zhugong/.autojump/bin
creating directory: /home/zhugong/.autojump/share/man/man1
creating directory: /home/zhugong/.autojump/etc/profile.d
creating directory: /home/zhugong/.autojump/share/autojump
copying file: ./bin/autojump -> /home/zhugong/.autojump/bin
copying file: ./bin/autojump_argparse.py -> /home/zhugong/.autojump/bin
copying file: ./bin/autojump_data.py -> /home/zhugong/.autojump/bin
copying file: ./bin/autojump_match.py -> /home/zhugong/.autojump/bin
copying file: ./bin/autojump_utils.py -> /home/zhugong/.autojump/bin
copying file: ./bin/icon.png -> /home/zhugong/.autojump/share/autojump
copying file: ./docs/autojump.1 -> /home/zhugong/.autojump/share/man/man1
creating directory: /home/zhugong/.autojump/etc/profile.d
creating directory: /home/zhugong/.autojump/share/autojump
creating directory: /home/zhugong/.autojump/functions
copying file: ./bin/autojump.sh -> /home/zhugong/.autojump/etc/profile.d
copying file: ./bin/autojump.bash -> /home/zhugong/.autojump/share/autojump
copying file: ./bin/autojump.fish -> /home/zhugong/.autojump/share/autojump
copying file: ./bin/autojump.zsh -> /home/zhugong/.autojump/share/autojump
copying file: ./bin/_j -> /home/zhugong/.autojump/functionsPlease manually add the following line(s) to ~/.bashrc:[[ -s /home/zhugong/.autojump/etc/profile.d/autojump.sh ]] && source /home/zhugong/.autojump/etc/profile.d/autojump.shPlease restart terminal(s) before running autojump.

使用方法
autojump 的使用很简单,通过 -h 可以看到其主要的功能,autojump 的别名是 j, 比如要进入 linux 目录,只需要 在 j 后面 输入前两个字符 li 然后再按 tab 键, 就会跳出相关的历史纪录(__xxx 的形式展现),

zhugong@ubuntu:~/linux/linux$ j li__
/home/zhugong/linux
zhugong@ubuntu:~/linux$ ls
linux
zhugong@ubuntu:~/linux$ 
zhugong@ubuntu:~/linux$ 
zhugong@ubuntu:~/linux$ pwd
/home/zhugong/linux