diff --git a/config_management/README.md b/config_management/README.md new file mode 100644 index 0000000..10137bb --- /dev/null +++ b/config_management/README.md @@ -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) +``` diff --git a/config_management/separate_startup/config.toml b/config_management/separate_startup/config.toml new file mode 100644 index 0000000..ace014e --- /dev/null +++ b/config_management/separate_startup/config.toml @@ -0,0 +1 @@ +startup = ["source startup.nu"] \ No newline at end of file diff --git a/config_management/separate_startup/startup.nu b/config_management/separate_startup/startup.nu new file mode 100644 index 0000000..ccf272e --- /dev/null +++ b/config_management/separate_startup/startup.nu @@ -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) } \ No newline at end of file