bash-completion

bash autocompletion: add description for possible completions

爷,独闯天下 提交于 2019-12-09 04:20:11
问题 Is it possible to make bash auto-completion look like in Cisco IOS shell? I mean to add short descriptions for each completion, like this: telnet 10.10.10. (TAB Pressed) 10.10.10.10 - routerA 10.10.10.11 - routerB where 10.10.10.10 and 10.10.10.11 are possible completions and routerA & routerB just descriptions (not to be executed). I know that bash can complete commands with "complete -W", but is it able to print descriptions for them? 回答1: I have a solution to this that does not require

Is it possible to display some help message when showing autocomplete candidates?

自古美人都是妖i 提交于 2019-12-06 09:40:50
Some commands have many -x ( x can be any English letter) options and it's some times difficult to remember all of their meanings. I can use bash's compgen -W '-a -b -c' to show possible options and I'm wondering if it's possible to also show some help message. Like this: bash# foo -<TAB><TAB> -a: This is option a -b: This is option b -C: This is option c bash# I ever did something similar to map some of curl 's single char options (like -x ) to GNU style --long-option s. This is how it works: [STEP 101] # cat curl function _compgen_curl() { local cmd=$1 cur=$2 pre=$3 local -a options=( \ '' -

cmdArgs bash completion

筅森魡賤 提交于 2019-12-06 01:56:20
问题 The cmdArgs package for Haskell provide command option parsing. based on this page from the docs http://hackage.haskell.org/packages/archive/cmdargs/0.10.3/doc/html/System-Console-CmdArgs-Explicit.html#g:4 and its source http://hackage.haskell.org/packages/archive/cmdargs/0.10.3/doc/html/src/System-Console-CmdArgs-Explicit-Complete.html#Complete It seem able to support bash completion, but I was not able to made it work with the Implicit version of the parser. http://hackage.haskell.org

Git completion and PS1 not working: “__git_ps1: command not found” on “sudo -s” or “sudo su” on Ubuntu 12.04

做~自己de王妃 提交于 2019-12-05 01:58:31
I installed git and git-flow completion adding these line to .bashrc of root and a normal_user on a Ubuntu 12.04 machine: source /etc/git-completion.bash source /etc/git-flow-completion.bash GIT_PS1_SHOWUPSTREAM="verbose" GIT_PS1_SHOWDIRTYSTATE=true PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ ' When I log as root or normal_user git completion works. However if I use "sudo -s" or "sudo su" git completion is not working and I continually get "__git_ps1: command not found" each time I press return. I tried to remove the "source" commands and use "apt

Bash completion: compgen a wordlist as if they were paths - Only suggest up until next slash

╄→尐↘猪︶ㄣ 提交于 2019-12-04 23:58:51
问题 I'm working on a bash completion script for a dot file management utility. The tool has a command dots diff [filename] that will show the difference between the installed dot file and the source dot file. It also has a command dots files which lists the paths of all managed dot files (relative to the source directory). I would like to complete the diff command with the output of the files command. Here's an example of the files output X11/xkb/symbols/evan-custom X11/xorg.conf.d/10-dual

bash tab completion with spaces

冷暖自知 提交于 2019-12-04 12:49:15
问题 I'm having a problem with bash-completion when the possible options may contain spaces. Let's say I want a function which echoes the first argument: function test1() { echo $1 } I generate a list of possible completion options (some have spaces, some not), but I don't manage to handle spaces correctly. function pink() { # my real-world example generates a similar string using awk and other commands echo "nick\ mason syd-barrett david_gilmour roger\ waters richard\ wright" } function _test() {

cmdArgs bash completion

谁说我不能喝 提交于 2019-12-04 05:23:23
The cmdArgs package for Haskell provide command option parsing. based on this page from the docs http://hackage.haskell.org/packages/archive/cmdargs/0.10.3/doc/html/System-Console-CmdArgs-Explicit.html#g:4 and its source http://hackage.haskell.org/packages/archive/cmdargs/0.10.3/doc/html/src/System-Console-CmdArgs-Explicit-Complete.html#Complete It seem able to support bash completion, but I was not able to made it work with the Implicit version of the parser. http://hackage.haskell.org/packages/archive/cmdargs/0.10.3/doc/html/System-Console-CmdArgs-Implicit.html Does any one have any example

在 Kubernetes 上运行 PostgreSQL

一笑奈何 提交于 2019-12-04 02:26:45
导读 创建统一管理的,具备灵活性的云原生生产部署来部署一个个性化的数据库即服务(DBaaS)。 通过在 Kubernetes 上运行 PostgreSQL 数据库,你能创建统一管理的,具备灵活性的云原生生产部署应用来部署一个个性化的数据库即服务为你的特定需求进行量身定制。 对于 Kubernetes,使用 Operator 允许你提供额外的上下文去管理有状态应用。当使用像PostgreSQL 这样开源的数据库去执行包括配置、扩展、高可用和用户管理时,Operator 也很有帮助。 让我们来探索如何在 Kubernetes 上启动并运行 PostgreSQL。 安装 PostgreSQL Operator 将 PostgreSQL 和 Kubernetes 结合使用的第一步是安装一个 Operator。在针对 Linux 系统的Crunchy 的快速启动 脚本 的帮助下,你可以在任意基于 Kubernetes 的环境下启动和运行开源的Crunchy PostgreSQL Operator。 快速启动 脚本 有一些必要前提: Wget 工具已安装。 kubectl 工具已安装。 在你的 Kubernetes 中已经定义了一个 StorageClass。 拥有集群权限的可访问 Kubernetes 的用户账号,以安装 Operator 的 RBAC 规则。 一个 PostgreSQL

Unit Test for Bash completion script

三世轮回 提交于 2019-12-03 12:55:08
I would like to write a Unit Test for a (rather complex) Bash completion script, preferrably with Python - just something that gets the values of a Bash completion programmatically. The test should look like this: def test_completion(): # trigger_completion should return what a user should get on triggering # Bash completion like this: 'pbt createkvm<TAB>' assert trigger_completion('pbt createkvm') == "module1 module2 module3" How can I simulate Bash completion programmatically to check the completion values inside a testsuite for my tool? Say you have a bash-completion script in a file called

Customize tab completion in shell

放肆的年华 提交于 2019-12-03 10:29:10
This may be have a better name than "custom tab completion", but here's the scenario: Typically when I'm at the command line and I enter a command, followed with {TAB} twice, I get a list of all files and subdirectories in the current directory. For example: [user@host tmp]$ cat <TAB><TAB> chromatron2.exe Fedora-16-i686-Live-Desktop.iso isolate.py favicon.ico foo.exe James_Gosling_Interview.mp3 However, I noticed at least one program somehow filters this list: wine . Consider: [user@host tmp]$ wine <TAB><TAB> chromatron2.exe foo.exe It effectively filters the results to *.exe . Thinking it