diff --git a/.vuepress/config.js b/.vuepress/config.js index b7dec6d00b1..8f5170e1a89 100755 --- a/.vuepress/config.js +++ b/.vuepress/config.js @@ -6,6 +6,7 @@ import { shikiPlugin } from '@vuepress/plugin-shiki'; import { defaultTheme } from '@vuepress/theme-default'; import { sitemapPlugin } from '@vuepress/plugin-sitemap'; import { docsearchPlugin } from '@vuepress/plugin-docsearch'; +import { markdownIncludePlugin } from '@vuepress/plugin-markdown-include'; import { navbarDe, @@ -211,6 +212,7 @@ export default defineUserConfig({ plugins: [ // Note: gitPlugin, backToTopPlugin, mediumZoomPlugin, and copyCodePlugin // are already included in defaultTheme, so we don't need to add them here + markdownIncludePlugin({}), shikiPlugin({ themes: { light: 'dark-plus', diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8496cbd0d3b..371d79d31fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,6 +70,8 @@ ls | where type == file | sort-by -r size | first 5 The preferred form for consistency is `` ```nu ``. +If the snippet is a reusable block that readers might want to source directly and track over time, save it as a sibling `.nu` file and include it inside the fence with `` (see `cookbook/direnv.md` for an example). + ## Translation Guide Follow the steps above for each group of translations. diff --git a/cookbook/direnv.md b/cookbook/direnv.md index 9f8c44e1ca3..31373da6da8 100644 --- a/cookbook/direnv.md +++ b/cookbook/direnv.md @@ -27,21 +27,7 @@ The direnv configuration below requires Nushell 0.104 or later. ::: ```nu -use std/config * - -# Initialize the PWD hook as an empty list if it doesn't exist -$env.config.hooks.env_change.PWD = $env.config.hooks.env_change.PWD? | default [] - -$env.config.hooks.env_change.PWD ++= [{|| - if (which direnv | is-empty) { - # If direnv isn't installed, do nothing - return - } - - direnv export json | from json | default {} | load-env - # If direnv changes the PATH, it will become a string and we need to re-convert it to a list - $env.PATH = do (env-conversions).path.from_string $env.PATH -}] + ``` As with other configuration changes, this can be made permanent by adding it to your startup [configuration](/book/configuration.md). diff --git a/cookbook/direnv.nu b/cookbook/direnv.nu new file mode 100644 index 00000000000..174cc07af52 --- /dev/null +++ b/cookbook/direnv.nu @@ -0,0 +1,15 @@ +use std/config * + +# Initialize the PWD hook as an empty list if it doesn't exist +$env.config.hooks.env_change.PWD = $env.config.hooks.env_change.PWD? | default [] + +$env.config.hooks.env_change.PWD ++= [{|| + if (which direnv | is-empty) { + # If direnv isn't installed, do nothing + return + } + + direnv export json | from json | default {} | load-env + # If direnv changes the PATH, it will become a string and we need to re-convert it to a list + $env.PATH = do (env-conversions).path.from_string $env.PATH +}] diff --git a/cookbook/ssh_agent.md b/cookbook/ssh_agent.md index 4dedb7fb24d..2d3dbf82d5d 100644 --- a/cookbook/ssh_agent.md +++ b/cookbook/ssh_agent.md @@ -26,30 +26,7 @@ See the workarounds. You can work around this behavior by checking if a ssh-agent is already running on your user, and start one if none is: ```nu -do --env { - let ssh_agent_file = ( - $nu.temp-dir | path join $"ssh-agent-(whoami).nuon" - ) - - if ($ssh_agent_file | path exists) { - let ssh_agent_env = open ($ssh_agent_file) - if ($"/proc/($ssh_agent_env.SSH_AGENT_PID)" | path exists) { - load-env $ssh_agent_env - return - } else { - rm $ssh_agent_file - } - } - - let ssh_agent_env = ^ssh-agent -c - | lines - | first 2 - | parse "setenv {name} {value};" - | transpose --header-row - | into record - load-env $ssh_agent_env - $ssh_agent_env | save --force $ssh_agent_file -} + ``` ### [Keychain](https://www.funtoo.org/Funtoo:Keychain) diff --git a/cookbook/ssh_agent_workaround.nu b/cookbook/ssh_agent_workaround.nu new file mode 100644 index 00000000000..a390bb8e232 --- /dev/null +++ b/cookbook/ssh_agent_workaround.nu @@ -0,0 +1,24 @@ +do --env { + let ssh_agent_file = ( + $nu.temp-dir | path join $"ssh-agent-(whoami).nuon" + ) + + if ($ssh_agent_file | path exists) { + let ssh_agent_env = open ($ssh_agent_file) + if ($"/proc/($ssh_agent_env.SSH_AGENT_PID)" | path exists) { + load-env $ssh_agent_env + return + } else { + rm $ssh_agent_file + } + } + + let ssh_agent_env = ^ssh-agent -c + | lines + | first 2 + | parse "setenv {name} {value};" + | transpose --header-row + | into record + load-env $ssh_agent_env + $ssh_agent_env | save --force $ssh_agent_file +} diff --git a/package-lock.json b/package-lock.json index b892c0ea740..3b7a4854a75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@vuepress/bundler-vite": "2.0.0-rc.26", "@vuepress/plugin-docsearch": "2.0.0-rc.118", "@vuepress/plugin-feed": "2.0.0-rc.118", + "@vuepress/plugin-markdown-include": "^2.0.0-rc.118", "@vuepress/plugin-shiki": "2.0.0-rc.118", "@vuepress/plugin-sitemap": "2.0.0-rc.118", "@vuepress/theme-default": "2.0.0-rc.118", @@ -1125,6 +1126,47 @@ } } }, + "node_modules/@mdit/plugin-include": { + "version": "0.22.4", + "resolved": "https://registry.npmjs.org/@mdit/plugin-include/-/plugin-include-0.22.4.tgz", + "integrity": "sha512-nMzPD+Jc15DVRHewjE4wa7+XswM5Un6ku+OtWocmrcvgCfZO0NjGLf3dmnv9DoTVhTglZvBb9cPYGLTJkEmbzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@mdit/helper": "0.22.2", + "@types/markdown-it": "^14.1.2", + "upath": "^2.0.1" + }, + "peerDependencies": { + "markdown-it": "^14.1.0" + }, + "peerDependenciesMeta": { + "markdown-it": { + "optional": true + } + } + }, + "node_modules/@mdit/plugin-include/node_modules/@mdit/helper": { + "version": "0.22.2", + "resolved": "https://registry.npmjs.org/@mdit/helper/-/helper-0.22.2.tgz", + "integrity": "sha512-i0mmN0S/BwR7zAKs9TnT9knmMVq3WGDJ3wO9PiETs0vUAwtcXIq5J0k8GAtGgKKTb7WTQuc19yt8uVQGVYfr2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/markdown-it": "^14.1.2" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "markdown-it": "^14.1.0" + }, + "peerDependenciesMeta": { + "markdown-it": { + "optional": true + } + } + }, "node_modules/@mdit/plugin-tab": { "version": "0.22.3", "resolved": "https://registry.npmjs.org/@mdit/plugin-tab/-/plugin-tab-0.22.3.tgz", @@ -2556,6 +2598,21 @@ "vuepress": "2.0.0-rc.26" } }, + "node_modules/@vuepress/plugin-markdown-include": { + "version": "2.0.0-rc.118", + "resolved": "https://registry.npmjs.org/@vuepress/plugin-markdown-include/-/plugin-markdown-include-2.0.0-rc.118.tgz", + "integrity": "sha512-YGd5mTMRYJQUoq/+pEU+736+fMOG3oQQB5juX+rlsup/w89B7Crk4o/jdJIvncMzoEWGkX1yaWNmAyZdk+AEAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@mdit/plugin-include": "^0.22.2", + "@types/markdown-it": "^14.1.2", + "@vuepress/helper": "2.0.0-rc.118" + }, + "peerDependencies": { + "vuepress": "2.0.0-rc.26" + } + }, "node_modules/@vuepress/plugin-markdown-tab": { "version": "2.0.0-rc.118", "resolved": "https://registry.npmjs.org/@vuepress/plugin-markdown-tab/-/plugin-markdown-tab-2.0.0-rc.118.tgz", diff --git a/package.json b/package.json index b5965b0f68e..3f27c402c74 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@vuepress/bundler-vite": "2.0.0-rc.26", "@vuepress/plugin-docsearch": "2.0.0-rc.118", "@vuepress/plugin-feed": "2.0.0-rc.118", + "@vuepress/plugin-markdown-include": "2.0.0-rc.118", "@vuepress/plugin-shiki": "2.0.0-rc.118", "@vuepress/plugin-sitemap": "2.0.0-rc.118", "@vuepress/theme-default": "2.0.0-rc.118",