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

Merge pull request #75 from x3rAx/pr-separate-startup

📦 NEW: Config with separate startup script and edit commands
This commit is contained in:
Darren Schroeder 2021-07-21 07:09:48 -05:00 committed by GitHub
commit 5a4027defe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,33 @@
# Separate Startup Script
This config sources a separate startup script so that you can edit a `nu` script
instead of fiddling around with the `toml` config.
Additionally it provides some new commands:
- `config edit`: Opens the `config.toml` in a new editor (depending on the `EDITOR` env variable)
- `startup edit`: Opens the `startup.nu` in a new editor (depending on the `EDITOR` env variable)
- `startup path`: Like `config path` provides the path to the `startup.nu` file
## The `... edit` command
Both `config edit` and `startup edit` accept the flag `--editor` (or `-e`) that
lets you define a different editor. To open the config in
[VSCode](https://github.com/microsoft/vscode) VScode for example do:
```
config edit -e code
startup edit -e code
```
## The `... path` command
Like `config path` the command `startup path` provides the path to the
`startup.nu` file. This can be used e.g. to open both, the `config.toml` and the
`startup.nu` in an editor of your choice:
```
vim (config path) (startup path)
```

View file

@ -0,0 +1 @@
startup = ["source startup.nu"]

View file

@ -0,0 +1,8 @@
def "config edit" [
--editor (-e): string # Use a different editor (default is `$nu.env.EDITOR`)
] { let editor = (if $editor != "" { $editor } { $nu.env.EDITOR }); ^$editor (config path) }
def "startup" [] { help startup }
def "startup path" [] { config path | path dirname | append startup.nu | path join }
def "startup edit" [
--editor (-e): string # Use a different editor (default is `$nu.env.EDITOR`)
] { let editor = (if $editor != "" { $editor } { $nu.env.EDITOR }); ^$editor (startup path) }