{"id":604,"date":"2022-09-21T10:28:16","date_gmt":"2022-09-21T02:28:16","guid":{"rendered":"https:\/\/memoryshadow.cn\/?p=604"},"modified":"2022-09-21T10:42:27","modified_gmt":"2022-09-21T02:42:27","slug":"provide-secondary-autocompletion-for-your-own-linux-programs","status":"publish","type":"post","link":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/","title":{"rendered":"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd"},"content":{"rendered":"<h1>\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd<\/h1>\n<div class='alert alert-info'><span class='alert-inner--text'>\u5982\u679c\u6709\u60f3\u6cd5\/\u5efa\u8bae\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u4e2d\u63d0\u51fa, \u4e00\u540c\u8fdb\u6b65, \u5171\u52c9<\/span><\/div>\n<p>\u5728 Linux \u4e2d, \u901a\u5e38\u53ef\u4ee5\u4f7f\u7528<code>Tab<\/code>\u952e\u5bf9\u5f53\u524d\u5df2\u7ecf\u8f93\u5165\u7684\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd.<\/p>\n<h2>\u5de5\u5177\u4ecb\u7ecd<\/h2>\n<ul>\n<li>bash: <code>complete<\/code>\u662fbash\u7684\u4e00\u4e2a\u5185\u5efa\u547d\u4ee4, \u901a\u8fc7\u5b83, \u6211\u4eec\u80fd\u4e3abash\u5efa\u7acb\u94a9\u5b50\u4ee5\u54cd\u5e94\u7528\u6237\u7684Tab\u4e8b\u4ef6.<\/li>\n<li>zsh: <code>compctl<\/code>\u662fzsh\u7684\u4e00\u4e2a\u5185\u5efa\u547d\u4ee4, \u901a\u8fc7\u5b83, \u6211\u4eec\u80fd\u4e3azsh\u5efa\u7acb\u94a9\u5b50\u4ee5\u54cd\u5e94\u7528\u6237\u7684Tab\u4e8b\u4ef6.<\/li>\n<\/ul>\n<h2>\u9884\u5148\u7684\u51c6\u5907, \u73af\u5883\u4e0e\u793a\u8303\u5de5\u5177\u7b49<\/h2>\n<p>\u56e0\u4e3a\u76ee\u6807\u59cb\u7ec8\u8981\u9488\u5bf9\u4e00\u4e2a\u5de5\u5177, \u6211\u5c31\u4ee5<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/github.com\/MemoryShadow\/minecraftctl\/\" title=\"\u70b9\u51fb\u524d\u5f80\">minecraftctl<\/a>\u4e3a\u793a\u4f8b, \u4e00\u6b65\u4e00\u6b65\u7684\u793a\u8303\u5982\u4f55\u64cd\u4f5c<\/p>\n<h2>\u5b9e\u73b0\u793a\u4f8b<\/h2>\n<h3>bash-complete<\/h3>\n<p>\u901a\u8fc7\u4f7f\u7528<code>complete<\/code>\u547d\u4ee4, \u53ef\u4ee5\u8ba9\u6211\u4eec\u4e3a\u4e00\u4e2a\u547d\u4ee4\u524d\u7f00\u7ed1\u5b9a\u4e0a\u4e00\u4e2a\u81ea\u52a8\u8865\u5168\u54cd\u5e94\u51fd\u6570:<\/p>\n<pre><code class=\"language-bash \">#!\/bin\/bash\n# ~\/.bashrc\n_minecraftctl() {\n  COMPREPLY=();\n  # <span class=\"katex math inline\">{COMP_WORDS[COMP_CWORD]} \u53ef\u4ee5\u83b7\u53d6\u5230\u7528\u6237\u7684\u8f93\u5165\n  local word=\"<\/span>{COMP_WORDS[COMP_CWORD]}\";\n  # \u8fd9\u91cc\u662f\u6709\u5173\u4e8eminecraftctl\u7684\u7279\u6b8a\u5b9e\u73b0, \u7a0d\u540e\u6211\u5c06\u4ee5\u53e6\u4e00\u4e2a\u4f8b\u5b50\u6765\u89e3\u91ca\u8fd9\u4e2a\u64cd\u4f5c\n  # \u8fd9\u91cc\u5c06\u4f1a\u4ea7\u51fa\u4e00\u4e2a\u5019\u9009\u8bcd\u5217\u8868, \u4ee5IFS\u4e3a\u5206\u5272\n  local completions=`find \/opt\/minecraftctl\/module\/ -name \"*.sh\" -exec basename {} \\; | grep -oe \"^[a-zA-Z]*\"`;\n  # \u5c06\u5019\u9009\u8bcd\u5217\u8868\u4e0e\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u8fdb\u884c\u6bd4\u5bf9, \u5339\u914d\u5230\u6700\u6709\u53ef\u80fd\u7684\u8bcd\n  COMPREPLY=(`compgen -W \"<span class=\"katex math inline\">{completions}\" -- \"<\/span>{word:-h}\"`)\n}\n# \u5c06 minecraftctl \u8fd9\u4e2a\u524d\u7f00\u7ed1\u5b9a\u5230 _minecraftctl \u8fd9\u4e2a\u51fd\u6570\ncomplete -f -F _minecraftctl minecraftctl\n<\/code><\/pre>\n<h3>zsh-compctl<\/h3>\n<p>\u901a\u8fc7\u4f7f\u7528<code>compctl<\/code>\u547d\u4ee4, \u53ef\u4ee5\u8ba9\u6211\u4eec\u4e3a\u4e00\u4e2a\u547d\u4ee4\u524d\u7f00\u7ed1\u5b9a\u4e0a\u4e00\u4e2a\u81ea\u52a8\u8865\u5168\u54cd\u5e94\u51fd\u6570:<\/p>\n<pre><code class=\"language-bash \">#!\/bin\/bash\n# ~\/.zshrc\n_minecraftctl() {\n  # <span class=\"katex math inline\">{1} \u53ef\u4ee5\u83b7\u53d6\u5230\u7528\u6237\u5bf9\u5e94\u4f4d\u7f6e\u7684\u8f93\u5165\n  local word=\"<\/span>1\";\n  # \u8fd9\u91cc\u662f\u6709\u5173\u4e8eminecraftctl\u7684\u7279\u6b8a\u5b9e\u73b0, \u7a0d\u540e\u6211\u5c06\u4ee5\u53e6\u4e00\u4e2a\u4f8b\u5b50\u6765\u89e3\u91ca\u8fd9\u4e2a\u64cd\u4f5c\n  # \u8fd9\u91cc\u5c06\u4f1a\u4ea7\u51fa\u4e00\u4e2a\u5019\u9009\u8bcd\u5217\u8868, \u4ee5\u6362\u884c\u7b26\u4e3a\u5206\u5272\n  local completions=`find \/opt\/minecraftctl\/module\/ -name \"*.sh\" -exec basename {} \\; | grep -oe \"^[a-zA-Z]*\"`;\n  # \u5c06\u5019\u9009\u8bcd\u5217\u8868\u4e0e\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u8fdb\u884c\u6bd4\u5bf9, \u5339\u914d\u5230\u6700\u6709\u53ef\u80fd\u7684\u8bcd\n  reply=(\"${(ps:\\n:)completions}\");\n}\n# \u5c06 minecraftctl \u8fd9\u4e2a\u524d\u7f00\u7ed1\u5b9a\u5230 _minecraftctl \u8fd9\u4e2a\u51fd\u6570\ncompctl -f -K _minecraftctl minecraftctl\n<\/code><\/pre>\n<h2>\u8bb2\u89e3\u4e0e\u793a\u4f8b<\/h2>\n<p>\u53c2\u8003\u4e0a\u65b9\u4e24\u4e2a\u811a\u672c, \u6211\u4eec\u4e0d\u96be\u53d1\u73b0, bash\u4e0ezsh\u7684\u5177\u4f53\u6d41\u7a0b\u533a\u522b\u5e76\u4e0d\u5927, \u90fd\u662f\u4e3a\u547d\u4ee4\u524d\u7f00\u7ed1\u5b9a\u94a9\u5b50\u51fd\u6570, \u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9, \u5bf9\u5df2\u6709\u7684\u5019\u9009\u5217\u8868\u8fdb\u884c\u5339\u914d\u540e\u8fd4\u56de\u7ed9\u7528\u6237.<\/p>\n<p>\u5728\u672c\u6587\u4e2d, \u6211\u4eec\u6765\u4e00\u6b65\u4e00\u6b65\u7684\u89e3\u6790\u8fd9\u4e2a\u6d41\u7a0b.<\/p>\n<h3>\u7b2c\u4e00\u6b65: \u6ce8\u518c\u94a9\u5b50<\/h3>\n<pre><code class=\"language-bash \"># bash\ncomplete -f -F _minecraftctl minecraftctl\n# zsh\ncompctl -f -K _minecraftctl minecraftctl\n<\/code><\/pre>\n<p>\u7531\u4e8e\u4e24\u4e2ashell\u4f7f\u7528\u7684\u5de5\u5177\u4e0d\u540c, \u53c2\u6570\u4e0d\u540c\u4e5f\u662f\u5f88\u6b63\u5e38\u7684\u4e8b\u60c5, \u8fd9\u4e24\u4e2a\u5de5\u5177\u4e2d\u6700\u91cd\u8981\u7684\u90e8\u5206\u5c31\u662f\u5c06<code>_minecraftctl<\/code>\u8fd9\u4e2a\u51fd\u6570\u6ce8\u518c\u4e3a\u4e86<code>minecraftctl<\/code>\u8fd9\u4e2a\u547d\u4ee4\u7684\u81ea\u52a8\u8865\u5168\u54cd\u5e94\u51fd\u6570(\u8fd9\u4e2a\u8fc7\u7a0b\u4e5f\u53eb\u505a\u6ce8\u518c\u94a9\u5b50), \u8fd9\u6837\u5b50\u5f53\u7528\u6237\u6309\u4e0bTab\u65f6\u5c31\u4f1a\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u4e86<\/p>\n<h3>\u7b2c\u4e8c\u6b65: \u8f93\u5165\u4e0e\u8f93\u51fa<\/h3>\n<p>\u6b64\u51fd\u6570\u6700\u5927\u7684\u529f\u80fd\u5c31\u662f\u5904\u7406\u8f93\u5165\u7684\u6570\u636e\u8fd4\u56de\u8f93\u51fa\u7684\u6570\u636e, \u4f46\u662f\u7531\u4e8e\u94a9\u5b50\u7684\u7279\u6b8a\u6027, \u8f93\u5165\u5e76\u4e0d\u4e00\u5b9a\u662f\u4ee5\u53c2\u6570\u7684\u5f62\u5f0f(zsh\u662f), \u8f93\u51fa\u4e5f\u4e0d\u662f\u4f20\u7edf\u7684return\u6216\u8005echo\u7684\u5f62\u5f0f, \u800c\u662f\u4ee5\u9884\u8bbe\u7684\u53d8\u91cf\u8fdb\u884c\u8fd4\u56de.<\/p>\n<h4>\u83b7\u53d6\u8f93\u5165<\/h4>\n<pre><code class=\"language-bash \"># fun _minecraftctl@bash\nlocal word=\"<span class=\"katex math inline\">{COMP_WORDS[COMP_CWORD]}\";\n# fun _minecraftctl@zsh\nlocal word=\"<\/span>1\";\n<\/code><\/pre>\n<p>\u8fd9\u4e00\u6b65\u4e2d, \u6211\u4eec\u53ef\u4ee5\u5728\u51fd\u6570 <code>_minecraftctl<\/code> \u4e2d\u83b7\u53d6\u5230\u7528\u6237\u5f53\u524d\u8f93\u5165\u5230\u4e00\u534a\u7684\u4e8c\u7ea7\u53c2\u6570, \u4f8b\u5982, \u7528\u6237\u5982\u679c\u8f93\u5165\u5230 <code>minecraftctl h<\/code> , \u90a3\u4e48 <code>${COMP_WORDS[COMP_CWORD]}<\/code> \u6216 <code>$1<\/code> \u83b7\u53d6\u5230\u7684\u5c31\u662f<code>h<\/code><\/p>\n<p>\u8fd9\u91cc\u7684 <code>$1<\/code> \u4e5f\u662f\u53ef\u4ee5\u6362\u6210 <code>$2<\/code> \u4e4b\u7c7b\u7684\u83b7\u53d6\u5176\u4ed6\u7ea7\u7684\u5185\u5bb9.<\/p>\n<p>\u800c <code>COMP_WORDS<\/code> \u8fd9\u4e2a\u53d8\u91cf\u5219\u662f\u4e00\u4e2a\u7279\u6b8a\u53d8\u91cf, \u5177\u4f53\u53ef\u53c2\u7167\u6587\u672b\u53c2\u8003\u6587\u7ae0 2<\/p>\n<h4>\u8fd4\u56de\u8f93\u51fa<\/h4>\n<pre><code class=\"language-bash \"># bash\nCOMPREPLY=(`compgen -W \"<span class=\"katex math inline\">{completions}\" -- \"<\/span>{word:-h}\"`)\n#zsh\nreply=(\"${(ps:\\n:)completions}\")\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e00\u6b65\u4e2d, \u4e24\u4e2ashell\u6709\u76f8\u5f53\u5927\u7684\u533a\u522b<\/p>\n<ul>\n<li>bash: \u8981\u6c42\u901a\u8fc7\u53d8\u91cf<code>COMPREPLY<\/code>\u8fd4\u56de<strong>\u4e00\u7ec4\u786e\u5207\u7684<\/strong>\u5019\u9009\u9879(\u4ee5<strong>\u6362\u884c\u7b26<\/strong>\u5206\u5272), \u968f\u7740\u7528\u6237\u6309Tab\u4f1a\u4f9d\u6b21\u9009\u62e9<\/li>\n<li>zsh: \u8981\u6c42\u901a\u8fc7\u53d8\u91cf<code>reply<\/code>\u8fd4\u56de<strong>\u6240\u6709<\/strong>\u5019\u9009\u9879(\u4ee5<strong>\u7a7a\u683c<\/strong>\u5206\u5272), \u4f1a\u6839\u636e\u7528\u6237\u7684\u8f93\u5165\u4f9d\u6b21\u663e\u793a\u5339\u914d\u5e76\u9009\u62e9<\/li>\n<\/ul>\n<p>\u5728\u8fd9\u91cc\u9644\u4e0a\u5bf9\u4e24\u4e2a\u547d\u4ee4\u7684\u7b80\u5355\u6ce8\u91ca, <code>compgen<\/code> \u662f\u4e00\u4e2a\u6bd4\u5bf9\u5de5\u5177, \u5b83\u4ece <code>completions<\/code> \u91cc\u627e\u5230\u6700\u6709\u53ef\u80fd\u548c <code>word<\/code> \u5339\u914d\u7684\u5185\u5bb9, \u4ee5\u6362\u884c\u7b26\u4f5c\u4e3a\u5206\u9694\u7b26\u5217\u51fa<\/p>\n<p>\u800c\u90a3\u53e5 <code>${(ps:\\n:)completions}<\/code> \u7684\u610f\u601d\u5462, \u5c31\u662f\u5427\u4e00\u4e2a\u4ee5\u6362\u884c\u7b26\u5206\u5272\u7684\u5b57\u7b26\u4e32\u8f6c\u4e3a\u4ee5\u7a7a\u683c\u5206\u5272\u7684\u5b57\u7b26\u4e32(\u5c31\u662f\u628a\\n\u6362\u6210\u7a7a\u683c)<\/p>\n<h3>\u7b2c\u4e09\u6b65: \u4e2d\u95f4\u5904\u7406<\/h3>\n<pre><code class=\"language-bash \">local completions=`find \/opt\/minecraftctl\/module\/ -name \"*.sh\" -exec basename {} \\; | grep -oe \"^[a-zA-Z]*\"`;\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u6211\u4eec\u83b7\u53d6\u4e00\u4e2a\u5019\u9009\u8bcd\u5217\u8868, \u7531\u4e8e\u8fd9\u4e2a\u5b9e\u73b0\u662fminecraftctl\u81ea\u5df1\u7684\u5b9e\u73b0, \u6211\u5728\u8fd9\u91cc\u5c55\u793a\u4e00\u4e0b\u4f1a\u663e\u793a\u7684\u5185\u5bb9:<\/p>\n<pre><code class=\"language-bash \">$ find \/opt\/minecraftctl\/module\/ -name \"*.sh\" -exec basename {} \\; | grep -oe \"^[a-zA-Z]*\"\nedit\njoin\nhelp\ninstall\nlisten\nbackup\nsay\nstop\nQQMsg\nview\nrestart\ndownload\nstart\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u662f\u53d6\u5f97\u4e00\u4e2a\u4ee5\u6362\u884c\u7b26\u4e3a\u5206\u5272\u7684\u5019\u9009\u8bcd\u5217\u8868<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u5b9e\u9645\u4e0a\u521b\u5efa\u6b64\u94a9\u5b50\u5e76\u4e0d\u96be, \u4e3b\u8981\u662f\u9700\u8981\u5543\u6587\u6863<\/p>\n<h2>\u53c2\u8003\u6587\u7ae0<\/h2>\n<ul>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/blog.jcoglan.com\/2013\/02\/12\/tab-completion-for-your-command-line-apps\/\" title=\"\u70b9\u51fb\u524d\u5f80\">Tab-completion for your command-line apps<\/a><\/li>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.cnblogs.com\/gmpy\/p\/13202562.html\" title=\"\u70b9\u51fb\u524d\u5f80\">Bash \u8865\u5168\u8be6\u89e3 <\/a><\/li>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/linux.die.net\/man\/1\/zshcompctl\" title=\"\u70b9\u51fb\u524d\u5f80\">zshcompctl(1) - Linux man page<\/a><\/li>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/837468220.gitbooks.io\/man_bash_chinese\/content\/readline5e9328_readline\/completing_bu_quan.html\" title=\"\u70b9\u51fb\u524d\u5f80\">Completing \u8865\u5168<\/a><\/li>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/zhuanlan.zhihu.com\/p\/57784678\" title=\"\u70b9\u51fb\u524d\u5f80\">Bash Shell \u5404\u79cd\u7279\u6b8a\u53d8\u91cf<\/a><\/li>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.cnblogs.com\/chengd\/p\/7803664.html\" title=\"\u70b9\u51fb\u524d\u5f80\">Bash Shell $\u52a0\u5404\u79cd\u62ec\u53f7\u7528\u6cd5<\/a><\/li>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/blog.51cto.com\/u_15067249\/4180630\" title=\"\u70b9\u51fb\u524d\u5f80\">Linux\u547d\u4ee4\u884c\u53c2\u6570\u4e2d\u201c-&#45;\u201d\uff08\u4e24\u4e2a\u51cf\u53f7\uff09\u53c2\u6570\u7684\u4f5c\u7528<\/a><\/li>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.cnblogs.com\/fnlingnzb-learner\/p\/10020697.html\" title=\"\u70b9\u51fb\u524d\u5f80\">Bash Shell \u5404\u79cd\u62ec\u53f7\u7528\u6cd5<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Linux \u4e2d, \u901a\u5e38\u53ef\u4ee5\u4f7f\u7528`Tab`\u952e\u5bf9\u5f53\u524d\u5df2\u7ecf\u8f93\u5165\u7684\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23,22],"tags":[],"class_list":["post-604","post","type-post","status-publish","format-standard","hentry","category-technology","category-operation-and-maintenance"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd - \u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9<\/title>\n<meta name=\"description\" content=\"...\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd - \u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9\" \/>\n<meta property=\"og:description\" content=\"...\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/\" \/>\n<meta property=\"og:site_name\" content=\"\u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-21T02:28:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-21T02:42:27+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/#\\\/schema\\\/person\\\/5eef0f7d66b0c15da64949e524c4c089\"},\"headline\":\"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd\",\"datePublished\":\"2022-09-21T02:28:16+00:00\",\"dateModified\":\"2022-09-21T02:42:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/\"},\"wordCount\":54,\"commentCount\":0,\"articleSection\":[\"\u6280\u672f\",\"\u8fd0\u7ef4\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/\",\"url\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/\",\"name\":\"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd - \u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/#website\"},\"datePublished\":\"2022-09-21T02:28:16+00:00\",\"dateModified\":\"2022-09-21T02:42:27+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/#\\\/schema\\\/person\\\/5eef0f7d66b0c15da64949e524c4c089\"},\"description\":\"...\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\\\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd...\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/2022\\\/09\\\/21\\\/provide-secondary-autocompletion-for-your-own-linux-programs\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/memoryshadow.cn\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/#website\",\"url\":\"https:\\\/\\\/memoryshadow.cn\\\/\",\"name\":\"\u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/memoryshadow.cn\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/memoryshadow.cn\\\/#\\\/schema\\\/person\\\/5eef0f7d66b0c15da64949e524c4c089\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/cravatar.cn\\\/avatar\\\/f774d16e5b08104e860fae80e2eb2e1d125978dbed7076f751c32852cf012477?s=96&r=g&d=404\",\"url\":\"https:\\\/\\\/cravatar.cn\\\/avatar\\\/f774d16e5b08104e860fae80e2eb2e1d125978dbed7076f751c32852cf012477?s=96&r=g&d=404\",\"contentUrl\":\"https:\\\/\\\/cravatar.cn\\\/avatar\\\/f774d16e5b08104e860fae80e2eb2e1d125978dbed7076f751c32852cf012477?s=96&r=g&d=404\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/blog.loft.games\"],\"url\":\"https:\\\/\\\/memoryshadow.cn\\\/index.php\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd - \u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9","description":"...\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd - \u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9","og_description":"...\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd...","og_url":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/","og_site_name":"\u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9","article_published_time":"2022-09-21T02:28:16+00:00","article_modified_time":"2022-09-21T02:42:27+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/#article","isPartOf":{"@id":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/"},"author":{"name":"admin","@id":"https:\/\/memoryshadow.cn\/#\/schema\/person\/5eef0f7d66b0c15da64949e524c4c089"},"headline":"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd","datePublished":"2022-09-21T02:28:16+00:00","dateModified":"2022-09-21T02:42:27+00:00","mainEntityOfPage":{"@id":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/"},"wordCount":54,"commentCount":0,"articleSection":["\u6280\u672f","\u8fd0\u7ef4"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/","url":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/","name":"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd - \u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9","isPartOf":{"@id":"https:\/\/memoryshadow.cn\/#website"},"datePublished":"2022-09-21T02:28:16+00:00","dateModified":"2022-09-21T02:42:27+00:00","author":{"@id":"https:\/\/memoryshadow.cn\/#\/schema\/person\/5eef0f7d66b0c15da64949e524c4c089"},"description":"...\u5185\u5bb9\u8fdb\u884c\u81ea\u52a8\u7684\u8865\u5168\u64cd\u4f5c, \u4f46\u662f\u8fd9\u4e2a\u64cd\u4f5c\u5bf9\u4e8e\u81ea\u5df1\u7684\u811a\u672c\u4e00\u822c\u53ea\u80fd\u62b5\u8fbe\u7b2c\u4e00\u7ea7\u8865\u5168, \u4e5f\u5c31\u662f\u8865\u5168\u5de5\u5177\u7684\u540d\u5b57, \u4e0d\u80fd\u8865\u5168\u81ea\u5df1\u811a\u672c\u7684\u7b2c\u4e8c\u7ea7\u53ca\u540e\u7eed\u7684\u53c2\u6570. \u8fd9\u4e2a\u529f\u80fd\u5b9e\u9645\u4e0a\u662f\u9700\u8981\u6211\u4eec\u81ea\u5df1\u6765\u5b9e\u73b0\u7684, \u672c\u6587\u5c06\u5f15\u5bfc\u60a8\u4f7f\u7528complete\/compctl\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd...","breadcrumb":{"@id":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/memoryshadow.cn\/index.php\/2022\/09\/21\/provide-secondary-autocompletion-for-your-own-linux-programs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/memoryshadow.cn\/"},{"@type":"ListItem","position":2,"name":"\u4e3a\u81ea\u5df1\u7684Linux\u7a0b\u5e8f\u63d0\u4f9b\u4e8c\u7ea7\u81ea\u52a8\u8865\u5168\u529f\u80fd"}]},{"@type":"WebSite","@id":"https:\/\/memoryshadow.cn\/#website","url":"https:\/\/memoryshadow.cn\/","name":"\u58a8\u516e\u67ab\u7684\u6280\u672f\u5c0f\u7ad9","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/memoryshadow.cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/memoryshadow.cn\/#\/schema\/person\/5eef0f7d66b0c15da64949e524c4c089","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/cravatar.cn\/avatar\/f774d16e5b08104e860fae80e2eb2e1d125978dbed7076f751c32852cf012477?s=96&r=g&d=404","url":"https:\/\/cravatar.cn\/avatar\/f774d16e5b08104e860fae80e2eb2e1d125978dbed7076f751c32852cf012477?s=96&r=g&d=404","contentUrl":"https:\/\/cravatar.cn\/avatar\/f774d16e5b08104e860fae80e2eb2e1d125978dbed7076f751c32852cf012477?s=96&r=g&d=404","caption":"admin"},"sameAs":["https:\/\/blog.loft.games"],"url":"https:\/\/memoryshadow.cn\/index.php\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/posts\/604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/comments?post=604"}],"version-history":[{"count":0,"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/posts\/604\/revisions"}],"wp:attachment":[{"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/media?parent=604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/categories?post=604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/memoryshadow.cn\/index.php\/wp-json\/wp\/v2\/tags?post=604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}