]> Sergey Matveev's repositories - nnn.git/commitdiff
PR #399: add autojump plugin
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 10 Dec 2019 16:59:15 +0000 (22:29 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 10 Dec 2019 17:00:35 +0000 (22:30 +0530)
plugins/README.md
plugins/autojump [new file with mode: 0755]

index 4bf724b1e0fc9d4dd1d6d00148df381c17313762..62270c0eedbedaec5fbf456038869e4672416356 100644 (file)
@@ -14,6 +14,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 
 | Plugin (a-z) | Description | Lang | Deps |
 | --- | --- | --- | --- |
+| autojump | Navigate to dir/path | sh | autojump |
 | boom | Play random music from dir | sh | [moc](http://moc.daper.net/) |
 | dups | List non-empty duplicate files in current dir | sh | find, md5sum,<br>sort uniq xargs |
 | chksum | Create and verify checksums | sh | md5sum,<br>sha256sum |
diff --git a/plugins/autojump b/plugins/autojump
new file mode 100755 (executable)
index 0000000..d158113
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env sh
+
+# Description: Navigate to directory using autojump
+#
+# Requires: autojump - https://github.com/wting/autojump
+#
+# Shell: POSIX compliant
+# Author: Marty Buchaus
+
+if which autojump >/dev/null 2>&1; then
+    printf "jump to: "
+    read -r dir
+    odir="$(autojump "$dir")"
+    printf "%s" "0$odir" > "$NNN_PIPE"
+else
+    exit 1
+fi