mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
Create autojump.nu (#265)
This commit is contained in:
parent
38b9cc48ca
commit
ea6069a2ab
1 changed files with 31 additions and 0 deletions
31
filesystem/autojump.nu
Normal file
31
filesystem/autojump.nu
Normal 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 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue