From 3784245e7ed3e254cfd0c313f74d881d2113e25d Mon Sep 17 00:00:00 2001 From: ^x3ro Date: Wed, 21 Jul 2021 09:40:42 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20Config=20with=20separate?= =?UTF-8?q?=20startup=20script=20and=20edit=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_management/README.md | 33 +++++++++++++++++++ .../separate_startup/config.toml | 1 + config_management/separate_startup/startup.nu | 8 +++++ 3 files changed, 42 insertions(+) create mode 100644 config_management/README.md create mode 100644 config_management/separate_startup/config.toml create mode 100644 config_management/separate_startup/startup.nu 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