1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

Create autojump.nu (#265)

This commit is contained in:
Tobias Salzmann 2022-07-21 13:24:51 +02:00 committed by GitHub
parent 38b9cc48ca
commit ea6069a2ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

31
filesystem/autojump.nu Normal file
View file

@ -0,0 +1,31 @@
# This file configures autojump (https://github.com/wting/autojump) for nushell
#
# Dependencies
# * autojump
#
# Installation
# 1. store in ~/.config/nushell/autojump.nu
# 2. add to your config.nu: `source .config/nushell/autojump.nu`
#
# Usage
# Run `j` to jump arround
def autojump_add_to_database [dir] {
let-env AUTOJUMP_SOURCED = 1
autojump --add $dir
}
def-env j [dir] {
let-env AUTOJUMP_SOURCED = 1
cd (autojump $dir)
}
let-env config = ($env.config | upsert hooks.env_change.PWD {|config|
let val = ($config | get -i hooks.env_change.PWD)
if $val == $nothing {
$val | append {|before, after| autojump_add_to_database $after }
} else {
[
{|before, after| autojump_add_to_database $after }
]
}
})