1"use strict";(self.webpackChunkrushjs_io=self.webpackChunkrushjs_io||[]).push([[296],{5552(e,t,r){r.d(t,{xA:()=>i,yg:()=>h});var n=r(829);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){o(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=n.createContext({}),c=function(e){var t=n.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):l(l({},t),e)),r},i=function(e){var t=c(e.components);return n.createElement(p.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},m=n.forwardRef(function(e,t){var r=e.components,o=e.mdxType,a=e.originalType,p=e.parentName,i=s(e,["components","mdxType","originalType","parentName"]),m=c(r),h=o,d=m["".concat(p,".").concat(h)]||m[h]||u[h]||a;return r?n.createElement(d,l(l({ref:t},i),{},{components:r})):n.createElement(d,l({ref:t},i))});function h(e,t){var r=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=r.length,l=new Array(a);l[0]=m;var s={};for(var p in t)hasOwnProperty.call(t,p)&&(s[p]=t[p]);s.originalType=e,s.mdxType="string"==typeof e?e:o,l[1]=s;for(var c=2;c<a;c++)l[c]=r[c];return n.createElement.apply(null,l)}return n.createElement.apply(null,r)}m.displayName="MDXCreateElement"},8651(e,t,r){r.r(t),r.d(t,{assets:()=>i,contentTitle:()=>p,default:()=>h,frontMatter:()=>s,metadata:()=>c,toc:()=>u});var n=r(6443),o=r(8338),a=(r(829),r(5552)),l=["components"],s={title:"\u914d\u7f6e tab \u8865\u5168"},p=void 0,c={unversionedId:"pages/developer/tab_completion",id:"pages/developer/tab_completion",title:"\u914d\u7f6e tab \u8865\u5168",description:"\u5728 5.34.0 \u7248\u672c\u4e2d\uff0cRush \u652f\u6301 tab \u8865\u5168\uff0c\u8fd9\u6837\u53ef\u4ee5\u8ba9\u7528\u6237\u6309\u4e0b TAB \u952e\u6765\u5feb\u901f\u8f93\u5165 shell \u547d\u4ee4\u3002\u4ee5\u4e0b\u5185\u5bb9\u53c2\u8003\u81ea",source:"@site/i18n/zh-cn/docusaurus-plugin-content-docs/current/pages/developer/tab_completion.md",sourceDirName:"pages/developer",slug:"/pages/developer/tab_completion",permalink:"/zh-cn/pages/developer/tab_completion",draft:!1,editUrl:"https://github.com/microsoft/rushstack-websites/tree/main/websites/rushjs.io/docs/pages/developer/tab_completion.md",tags:[],version:"current",frontMatter:{title:"\u914d\u7f6e tab \u8865\u5168"},sidebar:"docsSidebar",previous:{title:"\u5176\u4ed6\u6709\u7528\u7684\u6307\u4ee4",permalink:"/zh-cn/pages/developer/other_commands"},next:{title:"\u9009\u62e9\u90e8\u5206\u9879\u76ee",permalink:"/zh-cn/pages/developer/selecting_subsets"}},i={},u=[{value:"PowerShell",id:"powershell",level:2},{value:"Bash",id:"bash",level:2},{value:"Zsh",id:"zsh",level:2}],m={toc:u};function h(e){var t=e.components,r=(0,o.A)(e,l);return(0,a.yg)("wrapper",(0,n.A)({},m,r,{components:t,mdxType:"MDXLayout"}),(0,a.yg)("head",null,(0,a.yg)("link",{rel:"canonical",href:"https://rushstack.io/pages/current/pages/developer/tab_completion/"})),(0,a.yg)("p",null,"\u5728 5.34.0 \u7248\u672c\u4e2d\uff0cRush \u652f\u6301 tab \u8865\u5168\uff0c\u8fd9\u6837\u53ef\u4ee5\u8ba9\u7528\u6237\u6309\u4e0b TAB \u952e\u6765\u5feb\u901f\u8f93\u5165 shell \u547d\u4ee4\u3002\u4ee5\u4e0b\u5185\u5bb9\u53c2\u8003\u81ea\n",(0,a.yg)("a",{parentName:"p",href:"https://docs.microsoft.com/en-us
1/dotnet/core/tools/enable-tab-autocomplete"},".NET Core CLI \u7684 tab \u8865\u5168"),"\u3002"),(0,a.yg)("h2",{id:"powershell"},"PowerShell"),(0,a.yg)("p",null,"\u4e3a\u4e86\u5728 PowerShell \u4e2d\u5f00\u542f tab \u8865\u5168\uff0c\u9700\u8981\u521b\u5efa\u6216\u7f16\u8f91 ",(0,a.yg)("inlineCode",{parentName:"p"},"$PROFILE")," \u4e2d\u7684\u53d8\u91cf\uff0c\u66f4\u591a\u4fe1\u606f\u53ef\u4ee5\u53c2\u8003\uff1a",(0,a.yg)("a",{parentName:"p",href:"https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles#how-to-create-a-profile"},"\u5982\u4f55\u521b\u5efa profile")," \u548c ",(0,a.yg)("a",{parentName:"p",href:"https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles#profiles-and-execution-policy"},"Profile \u7684\u6267\u884c\u539f\u7406"),"."),(0,a.yg)("p",null,"\u5728\u4f60\u7684 profile \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-powershell"},"# \u9002\u7528\u4e8e Rush CLI \u7684 PowerShell \u53c2\u6570\u8865\u5168\u5de5\u5177\nRegister-ArgumentCompleter -Native -CommandName rush -ScriptBlock {\n param($commandName, $commandAst, $cursorPosition)\n [string]$value = $commandAst.ToString()\n # Handle input like `rush install; rush bui` + Tab\n [int]$position = [Math]::Min($cursorPosition, $value.Length)\n\n rush tab-complete --position $position --word \"$value\" | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n }\n")),(0,a.yg)("h2",{id:"bash"},"Bash"),(0,a.yg)("p",null,"\u4e3a\u4e86\u5728 Bash \u4e2d\u5f00\u542f\u81ea\u52a8\u8865\u5168\uff0c\u9700\u8981\u5728 ",(0,a.yg)("strong",{parentName:"p"},".bashrc")," \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},'# \u9002\u7528\u4e8e Rush CLI \u7684 bash \u53c2\u6570\u8865\u5168\u5de5\u5177\n\n_rush_bash_complete()\n{\n local word=${COMP_WORDS[COMP_CWORD]}\n\n local completions\n completions="$(rush tab-complete --position "${COMP_POINT}" --word "${COMP_LINE}" 2>/dev/null)"\n if [ $? -ne 0 ]; then\n completions=""\n fi\n\n COMPREPLY=( $(compgen -W "$completions" -- "$word") )\n}\n\ncomplete -f -F _rush_bash_complete rush\n')),(0,a.yg)("h2",{id:"zsh"},"Zsh"),(0,a.yg)("p",null,(0,a.yg)("a",{parentName:"p",href:"https://www.zsh.org/"},"Zsh")," \u7684\u73af\u5883\u53d8\u91cf\u4f1a\u7a0d\u6709\u4e0d\u540c\uff0c\u9700\u8981\u5728 ",(0,a.yg)("strong",{parentName:"p"},"~/.zshrc")," \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-zsh"},'(( ${+commands[rush]} )) && {\n _rush_completion() {\n compadd -- $(rush tab-complete --position ${CURSOR} --word "${BUFFER}" 2>>/dev/null)\n }\n compdef _rush_completion rush\n}\n')),(0,a.yg)("p",null,"\u5b83\u4f1a\u68c0\u67e5 rush \u547d\u4ee4\u662f\u5426\u5b58\u5728\uff0c\u56e0\u6b64\u8fd9\u6bb5\u4ee3\u7801\u9700\u8981\u6dfb\u52a0\u5728 PATH \u5df2\u7ecf\u8bbe\u7f6e\u597d\u4e4b\u540e\uff08\u6216\u8005\u5728 ",(0,a.yg)("a",{parentName:"p",href:"https://github.com/nvm-sh/nvm"},"nvm")," \u521d\u59cb\u5316\u4e4b\u540e\uff09\u3002\u6216\u8005\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u7b2c\u4e00\u884c\u7684 rush \u547d\u4ee4\u68c0\u67e5\u3002"))}h.isMDXComponent=!0}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.