• Stars
    star
    231
  • Rank 172,587 (Top 4 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast drop-in replacement of autojump written in Rust

autojump-rs Crates.io version Crates.io downloads Crates.io license GitHub branch checks state

A port of the wildly popular helper application autojump to Rust.

License

As this project is technically a fork, the license is the same as autojump, which is GPL, either version 3 or any later version. See LICENSE for details.

Install

We have prebuilt binaries available for a while now, thanks to the trust project!

The package is a drop-in replacement of autojump. Assuming autojump is already installed, or at least the shell script part of it has been properly set up, and you have in $PATH ~/.cargo/bin before the system binary locations, all you have to do is to put a binary of your choice architecture in your PATH, overriding the original autojump script.

You may have to issue hash -r for the shell to forget previous location of autojump, if you don't want to re-exec your shell.

(Manually cloning the repository and building is okay, of course.)

Features

Why do a port when the original version works? Primarily for two reasons:

  • The author is really tired of autojump breakage inside Python virtualenvs, and
  • Rust is simply awesome for CLI applications, with its performance and (code) slickness!

Indeed, being written in a compiled language, autojump-rs is very light on modern hardware. As the program itself is very short-running, the overhead of setting up and tearing down a whole Python VM could be overwhelming, especially on less capable hardware. With autojump-rs this latency is greatly reduced. Typical running time is like this on the author's Core i7-2670QM laptop, with a directory database of 1014 entries:

$ time ./autojump/bin/autojump au
/home/xenon/src/autojump-rs
./autojump/bin/autojump au  0.09s user 0.01s system 99% cpu 0.103 total

$ time ./autojump-rs/target/release/autojump au
/home/xenon/src/autojump-rs
./autojump-rs/target/release/autojump au  0.00s user 0.00s system 87% cpu 0.007 total

The time savings are more pronounced on less powerful hardware, where every cycle shaved off counts. The running time on a 1.4GHz Loongson 3A3000 is about 10ms, for example, which is very close to the x86 figures despite the clock frequency difference.

And, of course, the program no longer interacts with Python in any way, so the virtualenv-related crashes are no more. Say goodbye to the dreaded ImportError's showing every $PS1 in a virtualenv with the system-default Python!

# bye and you won't be missed!
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/autojump", line 43, in <module>
    from autojump_data import dictify
ImportError: No module named autojump_data

Compatibility

All of the command line flags and arguments are now implemented, and behave exactly like the original. Being a drop-in replacement, all other shell features like tab completion should work too. (Except jc and jco; see below.)

As for the text database, the on-disk format should be identical. (Actually there is a little difference in the representation of floats, but it doesn't matter.) However, as the author is developing and using this on Linux, other platforms may need a little more love, although all the libraries used are lovingly cross-platform. (Patches are welcome, of course!)

The Windows batch files shipped with the original autojump has Python hard-coded into them, and obviously that won't work with autojump-rs. Use the batch files in the windows directory instead; just replacing the original files and putting autojump.exe along with them should work. (Thanks @tomv564 for the Windows testing!)

That said, there're some IMO very minor deviations from the original Python implementation. These are:

  • Argument handling and help messages.

    Original autojump uses Python's argparse to parse its arguments. There is a Rust port of it, but it's nowhere as popular as the docopt.rs library, as is shown in crates.io statistics and GitHub activities. So it's necessary to re-arrange the help messages at least, as the docopt family of argument parsers mandate a specific style for them. However this shouldn't be any problem, just that it's different. Again, who looks at the usage screen all the day? XD

  • Different algorithm chosen for fuzzy matching.

    The Python version uses the difflib.SequenceMatcher algorithm for its fuzzy matches. Since it's quite a bit of complexity, I chose to leverage the strsim library instead. The Jaro-Winkler distance is computed between every filename and the last part of query needles respectively, and results are filtered based on that.

  • jc may jump outside current directory.

    Exact reason may be different filtering logic involved, but I'm not very sure about this one. The behavior is also observed on original autojump, but the frequency seems to be lower, and both implementations actually don't check if the target is below current directory. However I only use plain j mostly, so if you're heavily reliant on jc and its friends please open an issue!

Future plans

Now that platform support is mostly considered okay, next steps would be more refactoring and bug fixing. The jc behavior differences are observed on original autojump too, in that you could jump outside $(pwd), but the actual directory jumped to is different; this needs further investigation. Hell I even want to write a fasd backend too, but I don't presently have that much free time. Anyway, contributions and bug reports are welcome!

More Repositories

1

go-workwx

a sensible WeCom (企业微信, Wechat Work, Work Weixin) SDK for Go
Go
560
star
2

JNUthesis

江南大学学位论文 XⱻLᴬTᴇX 宏包
TeX
44
star
3

android_device_meizu_arale

Device tree for Meizu MX4 (common part + Ubuntu Edition)
C
33
star
4

larva

PoC LoongArch - RISC-V emulator
Rust
28
star
5

weiyu

微雨 -- "light rain", yet another Python Web framework
Python
26
star
6

loongson-overlay

Support overlay for Gentoo/Loongson users
Shell
20
star
7

xen0n.github.io

Source to my blog
CSS
13
star
8

local_manifests_arale

Local manifests for Meizu MX4 (both Ubuntu and ordinary editions)
8
star
9

android_mediatek_lenovo

mediatek directory for Lenovo devices
C++
8
star
10

maidata-rs

[WIP] Rust library for working with maidata.txt files from the simai community
Rust
8
star
11

sendfile.rs

A platform sendfile wrapper for Rust
Rust
5
star
12

jsunidecode

A simple JavaScript port of the Python transliteration library "unidecode".
JavaScript
5
star
13

protobuf-gogogo

[WIP] Attempt to implement gogo/protobuf on top of APIv2
Go
5
star
14

shengloong

昇龍 -- upgrades LoongArch sysroot in-place to new glibc symbol version
C
4
star
15

howto-foss-web-devel-zh-cn

(in Chinese) 自由/开源技术Web开发教程
4
star
16

goubao

狗宝——帮你整理文档的好同事
Go
3
star
17

dotfiles

my dotfiles backup
Emacs Lisp
3
star
18

brickbot

一个用来润滑日常搬砖过程中团队协作的简单 bot
Go
3
star
19

gosmopolitan

Report certain i18n/l10n anti-patterns in your Go codebase
Go
3
star
20

rustc-l10n

Experimental project to bring l10n to rustc
Rust
2
star
21

rust-jnisupport

(NAME CHANGE NEEDED) Easy-to-use JNI wrapper macros for Rust
2
star
22

touchmon

Simple inotify-based filesystem observer
Python
2
star
23

simplecolor-themes

Theme(s) comprised of Simple Colors, that's it
2
star
24

pyopen189

Unofficial Python client for open.189.cn (天翼开放平台)
Python
2
star
25

cirrocumulus

卷积云 -- 江南听雨网应用部署平台
Python
2
star
26

qn-changelog-rs

Rust port of https://github.com/sorcerer-ma/changelog
Rust
2
star
27

android_device_meizu_mx4

Device tree for Meizu MX4 (non-Ubuntu editions)
Makefile
2
star
28

docker-pandora-express

(UNOFFICIAL) Dockerized Qiniu Pandora 2.0
Shell
2
star
29

r2-loongarch

Radare2/Rizin plugins for LoongArch
C
2
star
30

open189-rs

A Rust client for the open.189.cn (天翼开放平台) API
Rust
2
star
31

android_vendor_meizu_arale

Vendor tree for Meizu MX4 Ubuntu Edition
Shell
2
star
32

gentoo-loongson-patches

Loongson patches for Gentoo; clone into your /etc/portage/patches to use
1
star
33

xen0n

1
star
34

loongson-portage-conf

Portage configuration for Loongson-based boxes
1
star
35

android_device_zte_p635-common

Common device tree for ZTE Blade A1
C
1
star
36

gingerprawn

A highly extensible client specifically made for students in Jiangnan University
Python
1
star
37

maidata.vim

Vim syntax highlighting for maidata.txt files
Vim Script
1
star
38

acmed-dns-helper-dnspod

Helper for ACMEd to handle DNS challenges with DNSPod
Rust
1
star
39

monkeywrapper

2015 Unique Hack Day project
Java
1
star
40

android_hardware_mediatek

android hardware support for MTK
C++
1
star
41

android_device_zte_p635b32

Device tree for ZTE Blade A1 (C880A variant)
Makefile
1
star
42

android_device_lenovo_a808t

Lenovo A808t
C
1
star
43

qiniu-rs

[WIP] Rust SDK for Qiniu
Rust
1
star
44

cloud-provider-shim

[WIP] a Kubernetes cloud provider shim enabling non-Golang implementations
Go
1
star
45

android_vendor_zte_p635b32

Vendor tree for ZTE Blade A1 (C880A variant)
Shell
1
star
46

glibc-patches

my fork of Gentoo's glibc-patches
Shell
1
star