Table of Contents
Install autojump" >Install autojump
Use autojump" >Use autojump
Home System Tutorial LINUX too strong! This command line tool can quickly and automatically jump to the Linux file directory

too strong! This command line tool can quickly and automatically jump to the Linux file directory

Feb 13, 2024 pm 07:33 PM
linux linux tutorial linux system linux command shell script embeddedlinux Getting started with linux linux learning

In the Linux terminal, sometimes it may be troublesome to jump to the directory. You need to enter a long command path to enter the specified directory.

autojump is a command line tool that can quickly and automatically jump to a file directory. It saves records of the most used directories from the command line to the database, so before using it, you must first access the directory and then jump to the desired directory.

太强了!这款命令行工具可以在 Linux 文件目录快速自动跳转

It will add different weights according to the frequency of accessing the directory. The more frequently the directory is accessed, the higher the weight, the higher the ranking, and the simpler the jump command.

autojump can be installed on Linux, OS

Install autojump

To install autojump, you need to prepare a Python v2.6 or Python v3.3 environment.

This is a CentOS 7.5 environment. Python2 is installed by default. If your operating system does not have a Python environment, I have prepared a script for installing Python3. You only need to place the two tar packages and the script in the same one. directory, execute the script to install.

sh python3_install.sh
Copy after login

Decompress the downloaded autojump compressed package from GitHub

unzip autojump-master.zip
Copy after login

Then you can install or uninstall

cd autojump-master
./install.py 或 ./uninstall.py
Copy after login

Since Shell startup under Linux will automatically read the ~/.bashrc file, during the installation process, if the following problems occur, you need to manually add the following lines to ~/.bashrc in the file.

vim ~/.bashrc

[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
Copy after login

After the addition is completed, execute the command: source ~/.bashrc to take effect.

After the installation is complete, execute the command: autojump --version or j -v to check the autojump version.

# autojump --version
autojump v22.5.3
Copy after login

Use autojump

How to use autojump:

autojump [-h] [-a DIRECTORY] [-i [WEIGHT]] [-d [WEIGHT]] [--complete]
                [--purge] [-s] [-v]
                [DIRECTORY [DIRECTORY ...]]
Copy after login

Optional parameters for autojump:

  • -h: Display help information and exit
  • -a DIRECTORY: add path
  • -i [WEIGHT]: Increase the weight of the current directory
  • -d [WEIGHT]: Reduce the weight of the current directory
  • –complete: for tab completion
  • –purge: Delete paths that do not exist in the database
  • -s: Display database entries and their weights
  • -v: Display version information

j is the abbreviation of the autojump command. Any place where autojump can be used can be replaced by the j command.

Usage 1: Jump to the directory containing the autojump string

# j autojump
/root/autojump-master
Copy after login

Usage 2: When the directory of a certain string contains multiple subdirectories with different names, there is no need to jump to the directory in the first way of inputting the string. You can use jc subdirectory namecan jump to subdirectory

# jc bin
/root/autojump-master/bin
Copy after login

Usage 3:Open the file manager containing a certain string directory

# jo music
Copy after login

Usage 4: Open the subdirectory file manager containing a certain string directory

# jco images
Copy after login

Usage 3 and 4 allow you to open a file manager from the command line instead of jumping to a directory. This prerequisite must be a Linux desktop environment installed, such as GNOME, KDE, etc. If the server is connected through a third-party terminal connection tool, it will be unavailable when used.

Usage 5: If two directories contain the same string

20.0:    /opt/one/first
22.4:    /opt/two/first
Copy after login

那么j fi会跳转到权重最大的目录

# j fi
/opt/two/first
Copy after login

也可以通过j o fi跳转到权重相对较小的目录

# j o fi
/opt/one/first
Copy after login

当如果忘记目录的全名或手误输错,可按 Tab 键自动识别补全,同时也会自动添加下划线。

# j ptython__1__/opt/python 
/opt/python
Copy after login

在跳转过程中出现不能跳转的情况,需要在安装好 autojump 之后确认是否访问过指定的目录或执行命令:j -s查看数据库中历史访问过的目录。

同时,j -s也是可以用来查看权重。当权重越高,说明目录使用的越频繁。

查看每个文件夹的权重和全部文件夹计算得出的总权重的统计数据,文件夹的权重代表在这个文件夹中所花的总时间,文件夹权重为该列表中目录的数字。

# j -s
10.0:    /mnt/Packages
14.1:    /opt/two
14.1:    /opt/one
22.4:    /opt/python
24.5:    /root/.local/share/autojump
24.5:    /opt
24.5:    /opt/two/first
26.5:    /opt/one/first
28.3:    /mnt
41.2:    /root/autojump-master
43.6:    /root/autojump-master/bin
________________________________________

273:     total weight
11:     number of entries
22.36:     current directory weight

data:     /root/.local/share/autojump/autojump.txt
Copy after login

autojump 存储运行日志及错误日志存放至~/.local/share/autojump/,切记不要重写这些文件,否则将会失去所有的统计状态结果。

# ls -l ~/.local/share/autojump/
-rw-------. 1 root root 305 3月  16 16:14 autojump.txt
-rw-------. 1 root root  27 3月  16 11:16 autojump.txt.bak
Copy after login

运用了 autojump 上述使用方法之外,目前有发现如下三点:

1、autojump 只能跳转到已经用cd进入过的目录,无法跳转到没有用cd进入过的目录。即使用 cd 进入过一个特定的目录才会被记录到 autojump 的数据库中,才可以使用 autojump 进行跳转。

2、自动跳转不支持-开头的目录。

3、在 BASH Shell 中,autojump 是通过修改$PROMPT_COMMAND环境变量跟踪目录的行为,所以建议不要重写$PROMPT_COMMAND环境变量。若需要添加其他的命令到现$PROMPT_COMMAND环境变量中,需添加到$PROMPT_COMMAND环境变量的最后。

The above is the detailed content of too strong! This command line tool can quickly and automatically jump to the Linux file directory. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to start apache How to start apache Apr 13, 2025 pm 01:06 PM

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

What to do if the apache80 port is occupied What to do if the apache80 port is occupied Apr 13, 2025 pm 01:24 PM

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

How to monitor Nginx SSL performance on Debian How to monitor Nginx SSL performance on Debian Apr 12, 2025 pm 10:18 PM

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

How to set up a recycling bin in Debian system How to set up a recycling bin in Debian system Apr 12, 2025 pm 10:51 PM

This article introduces two methods of configuring a recycling bin in a Debian system: a graphical interface and a command line. Method 1: Use the Nautilus graphical interface to open the file manager: Find and start the Nautilus file manager (usually called "File") in the desktop or application menu. Find the Recycle Bin: Look for the Recycle Bin folder in the left navigation bar. If it is not found, try clicking "Other Location" or "Computer" to search. Configure Recycle Bin properties: Right-click "Recycle Bin" and select "Properties". In the Properties window, you can adjust the following settings: Maximum Size: Limit the disk space available in the Recycle Bin. Retention time: Set the preservation before the file is automatically deleted in the recycling bin

How to optimize the performance of debian readdir How to optimize the performance of debian readdir Apr 13, 2025 am 08:48 AM

In Debian systems, readdir system calls are used to read directory contents. If its performance is not good, try the following optimization strategy: Simplify the number of directory files: Split large directories into multiple small directories as much as possible, reducing the number of items processed per readdir call. Enable directory content caching: build a cache mechanism, update the cache regularly or when directory content changes, and reduce frequent calls to readdir. Memory caches (such as Memcached or Redis) or local caches (such as files or databases) can be considered. Adopt efficient data structure: If you implement directory traversal by yourself, select more efficient data structures (such as hash tables instead of linear search) to store and access directory information

How to restart the apache server How to restart the apache server Apr 13, 2025 pm 01:12 PM

To restart the Apache server, follow these steps: Linux/macOS: Run sudo systemctl restart apache2. Windows: Run net stop Apache2.4 and then net start Apache2.4. Run netstat -a | findstr 80 to check the server status.

How debian readdir integrates with other tools How debian readdir integrates with other tools Apr 13, 2025 am 09:42 AM

The readdir function in the Debian system is a system call used to read directory contents and is often used in C programming. This article will explain how to integrate readdir with other tools to enhance its functionality. Method 1: Combining C language program and pipeline First, write a C program to call the readdir function and output the result: #include#include#include#includeintmain(intargc,char*argv[]){DIR*dir;structdirent*entry;if(argc!=2){

How to solve the problem that apache cannot be started How to solve the problem that apache cannot be started Apr 13, 2025 pm 01:21 PM

Apache cannot start because the following reasons may be: Configuration file syntax error. Conflict with other application ports. Permissions issue. Out of memory. Process deadlock. Daemon failure. SELinux permissions issues. Firewall problem. Software conflict.

See all articles