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

Create cdpath-implementation.nu

If anyone knows how to write it more clearly and the script (instead of the config one) way — feel free to correct it
This commit is contained in:
Kamil 2021-08-01 00:40:56 +00:00 committed by GitHub
parent a77a4ee652
commit aaa843f1c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,11 @@
#!/usr/bin/nu
#I actually use it as a part of my startup, so I'm not really sure how to pack it, yet I'd like to contribute
#NOTE: it does *not* work with 0 arguments. To get $cd functionality, use $cd. To use cdpath, use $c
#Written by skelly37
startup = [
"let cdpath = [. /place/your /cdpath/here]",
"def c [dir] { let wd = (pwd); for element in $cdpath {if (pwd) == $wd {cd $element; for directory in (ls -d -a */ | get name) {if $dir == $directory {cd $dir} {}}; if (pwd) == $element {cd $wd} {}} {}}; if (pwd) == $wd {cd $wd; echo \"No such path!\"} {}}",
]