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:
parent
a77a4ee652
commit
aaa843f1c5
1 changed files with 11 additions and 0 deletions
11
cool_oneliners/cdpath-implementation.nu
Normal file
11
cool_oneliners/cdpath-implementation.nu
Normal 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!\"} {}}",
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue