当前位置: 首页 > 工具软件 > Autojump > 使用案例 >

Linux中在zsh下如何安装autojump

姬雪松
2023-12-01

介绍

autojump is a faster way to navigate your filesystem. It works by maintaining a database of the directories you use the most from the command line.
Directories must be visited first before they can be jumped to.

关于 autojump 有以下几个站点:
https://github.com/wting/autojump
https://github.com/haoziyeung/autojump
https://gitee.com/gentlecp/autojump/
https://www.worldlink.com.cn/en/osdir/autojump.html

注:autojump 不仅可以用在 zsh 环境下,也可以在 bash 环境下使用。

安装

cd ~/.oh-my-zsh/custom/plugins/ 
git clone git://github.com/wting/autojump.git
cd autojump
./install.py 

Linux 系统下执行 ./install.py 可能会提示下面的信息:

/usr/bin/env: “python”: 没有那个文件或目录

点击查看如何解决?

解决了 python 的问题后,执行脚本文件 ./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 ~/.zshrc:
[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u

Please restart terminal(s) before running autojump.

如上所示,提示需要在文件 ~/.zshrc 手动添加如下命令语句:

[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u

保存修改后,在运行 autojump 之前需要重启终端。

注:我并没有在 ~/.zshrcplugins=() 中添加 autojump,也可以正常使用。

安装有风险,我的Linux安装后直接崩溃掉,不知道为什么?安装后可以正常使用,退出终端后再重新进入就出现严重异常,根本无法正常使用:

Last login: Wed Nov  3 23:43:21 on ttys000
ssh root@47.1.59.204
[~]$ ssh root@47.1.59.204
root@47.1.59.204's password:

Welcome to Alibaba Cloud Elastic Compute Service !

Activate the web console with: systemctl enable --now cockpit.socket

Last login: Wed Nov  3 23:39:26 2021 from 112.50.84.33
/root/.autojump/share/autojump/autojump.zsh:22: command not found: uname
/usr/libexec/grepconf.sh:行5: grep: 未找到命令
/usr/libexec/grepconf.sh:行5: grep: 未找到命令
/usr/libexec/grepconf.sh:行5: grep: 未找到命令
/root/.oh-my-zsh/oh-my-zsh.sh:56: command not found: mkdir
/root/.oh-my-zsh/oh-my-zsh.sh:118: command not found: rm
/root/.oh-my-zsh/oh-my-zsh.sh:127: compinit: function definition file not found
detect-clipboard:33: command not found: uname
/root/.oh-my-zsh/lib/cli.zsh:105: command not found: compdef
/root/.oh-my-zsh/lib/completion.zsh:78: bashcompinit: function definition file not found
/root/.oh-my-zsh/lib/directories.zsh:32: command not found: compdef
/root/.oh-my-zsh/lib/termsupport.zsh:109: add-zsh-hook: function definition file not found
/root/.oh-my-zsh/lib/termsupport.zsh:110: add-zsh-hook: function definition file not found
/root/.oh-my-zsh/lib/theme-and-appearance.zsh:2: colors: function definition file not found
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:23: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:105: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:135: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:138: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:142: is-at-least: function definition file not found
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:156: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:161: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:171: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:181: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:190: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:196: command not found: compdef
/root/.oh-my-zsh/plugins/git/git.plugin.zsh:283: is-at-least: function definition file not found
/root/.autojump/share/autojump/autojump.zsh:22: command not found: uname
/root/.zshrc:103: compinit: function definition file not found
➜  ~ chsh -s /bin/bash
zsh: command not found: chsh
 类似资料: