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

Documented

I have just noticed I had not documented the script well. Now it is the final version of my idea, I guess.
This commit is contained in:
Kamil 2021-08-01 09:28:53 +00:00 committed by GitHub
parent 4e4ea71612
commit 9f648e7f04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,23 @@
#!/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
# I actually use it as a part of my startup, so I am not really sure how to pack it, yet I wouldd like to contribute
#-------------------------------------------------------------------------------------------------------------------------------
#
# How to use?
#-------------------------------------------------
#1) Add desired paths to the cdpath variable
#2) Use in your shell: $c [directory]
#2.5) You *have to* use an argument. If you wish to simply $cd, use $cd command.
#3) If the path exists, you will cd into the first match found (the command is iterating over the list in the correct order,
# i.e. first element is being iterated overin the first place)
#3.5) But if path does not exist, you will receive a proper echo.
#-----------------------------------------------------------------------------------------------------------------------------------
#
#Written by skelly37
#------------------------
startup = [
"let cdpath = [. /data /data/it /data/games]",
"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 -a | select name type | each { if $it.type == Dir {echo $it.name} {} } ) {if $dir == $directory {cd $dir} {}}; if (pwd) == $element {cd $wd} {}} {}}; if (pwd) == $wd {cd $wd; echo \"No such path!\"} {}}",
]