From 4bec7cba544d7fc2496b049ce0ab380eb2a6109d Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Fri, 22 May 2026 12:27:46 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"support=20extracting=20nu=20code=20sn?= =?UTF-8?q?ippets=20into=20standalone=20.nu=20files=20for=20bet=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d283b103dd43bb5e0b19357901fc9bfcab6be50a. --- .vuepress/config.js | 2 -- CONTRIBUTING.md | 2 -- cookbook/direnv.md | 16 ++++++++- cookbook/direnv.nu | 15 --------- cookbook/ssh_agent.md | 25 +++++++++++++- cookbook/ssh_agent_workaround.nu | 24 -------------- package-lock.json | 57 -------------------------------- package.json | 1 - 8 files changed, 39 insertions(+), 103 deletions(-) delete mode 100644 cookbook/direnv.nu delete mode 100644 cookbook/ssh_agent_workaround.nu diff --git a/.vuepress/config.js b/.vuepress/config.js index fc935767ff0..bb256454d1c 100755 --- a/.vuepress/config.js +++ b/.vuepress/config.js @@ -6,7 +6,6 @@ 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, @@ -221,7 +220,6 @@ 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 371d79d31fd..8496cbd0d3b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,8 +70,6 @@ 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 31373da6da8..9f8c44e1ca3 100644 --- a/cookbook/direnv.md +++ b/cookbook/direnv.md @@ -27,7 +27,21 @@ 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 deleted file mode 100644 index 174cc07af52..00000000000 --- a/cookbook/direnv.nu +++ /dev/null @@ -1,15 +0,0 @@ -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 2d3dbf82d5d..4dedb7fb24d 100644 --- a/cookbook/ssh_agent.md +++ b/cookbook/ssh_agent.md @@ -26,7 +26,30 @@ 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 deleted file mode 100644 index a390bb8e232..00000000000 --- a/cookbook/ssh_agent_workaround.nu +++ /dev/null @@ -1,24 +0,0 @@ -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 7983a8222c6..2c8552ca5d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@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", @@ -1127,47 +1126,6 @@ } } }, - "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", @@ -2599,21 +2557,6 @@ "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 75bd671c782..550bfb1d230 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "@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",