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:
commit
5a4027defe
3 changed files with 42 additions and 0 deletions
33
config_management/separate_startup/README.md
Normal file
33
config_management/separate_startup/README.md
Normal 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)
|
||||
```
|
1
config_management/separate_startup/config.toml
Normal file
1
config_management/separate_startup/config.toml
Normal file
|
@ -0,0 +1 @@
|
|||
startup = ["source startup.nu"]
|
8
config_management/separate_startup/startup.nu
Normal file
8
config_management/separate_startup/startup.nu
Normal 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) }
|
Loading…
Add table
Add a link
Reference in a new issue