2025-09-10 18:54:44 +05:30
|
|
|
### Simple Goto script written in cpp.
|
2025-09-10 18:59:31 +05:30
|
|
|
#### Usage:
|
|
|
|
|
goto [OPTION|LINK_NAME]
|
2025-09-10 18:58:53 +05:30
|
|
|
#### Options:
|
2025-09-10 18:57:53 +05:30
|
|
|
|
2025-09-10 18:54:44 +05:30
|
|
|
-h --help : Show this info
|
2025-09-10 18:57:53 +05:30
|
|
|
|
2025-09-10 18:54:44 +05:30
|
|
|
-c --create_link : Create a new link e.g: goto --create_link [LINK_NAME] [FROM_PATH]
|
2025-09-10 18:57:53 +05:30
|
|
|
|
2025-09-10 18:54:44 +05:30
|
|
|
-l --list : List all the existing links
|
2025-09-13 22:54:45 +05:30
|
|
|
|
|
|
|
|
-lo --list-only : List only the names of all the existing links
|
2025-09-10 18:57:53 +05:30
|
|
|
|
2025-09-10 18:54:44 +05:30
|
|
|
-d --delete_link : Delete an exisiting link e.g: goto -d [LINK_NAME]
|
2025-09-10 18:57:53 +05:30
|
|
|
|
|
|
|
|
-rf --delete_file : Delete the existing link file completely
|
|
|
|
|
|
2025-09-10 18:54:44 +05:30
|
|
|
[LINK_NAME] : Goes to an exisiting link e.g: goto [LINK_NAME]
|
2025-09-10 18:57:53 +05:30
|
|
|
|
2025-09-10 18:54:44 +05:30
|
|
|
[LINK_NAME] : Rules for creating [LINK_NAME] name must be BASH variable and must not start with "-"
|
2025-09-10 18:57:53 +05:30
|
|
|
|
2025-09-10 18:54:44 +05:30
|
|
|
[LINK_NAME] : [LINK_NAME] cannot be "last"
|
|
|
|
|
|
2025-09-13 22:53:13 +05:30
|
|
|
### To use add a function in shell like:
|
|
|
|
|
#### Bash
|
2025-09-10 18:54:44 +05:30
|
|
|
```bash
|
|
|
|
|
function goto() {
|
|
|
|
|
if [[ "$#" -eq 1 ]] && [[ "$1" != -* ]]; then
|
|
|
|
|
out=$(/home/ud/Scripts/goto $1 2>&1)
|
|
|
|
|
if [[ "$?" -eq "0" ]]; then
|
|
|
|
|
cd "$out"
|
|
|
|
|
else
|
|
|
|
|
echo $out
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
/home/ud/Scripts/goto $@
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
```
|
2025-09-13 22:53:13 +05:30
|
|
|
#### Fish
|
|
|
|
|
```fish
|
|
|
|
|
function goto
|
|
|
|
|
if test (count $argv) -eq 1
|
|
|
|
|
if not string match -rq -- '^-' "$argv[1]"
|
|
|
|
|
set out (/home/ud/Scripts/goto $argv[1] 2>&1 )
|
|
|
|
|
if test $status -eq 0
|
|
|
|
|
cd "$out"
|
|
|
|
|
else
|
|
|
|
|
echo $out
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
/home/ud/Scripts/goto $argv
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
/home/ud/Scripts/goto $argv
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
```
|
2025-09-10 18:54:44 +05:30
|
|
|
|
|
|
|
|
|