mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-27 16:17:22 +00:00
* including tutorial for bash autocomplete - included the Bash Autocomplete in sidebar.yml - created a new file called Bash-Autocomplete.md with a tutorial to include a bash autocomplete. This tutorial was based on: - https://github.com/urfave/cli/blob/master/docs/v1/manual.md#enabling - https://github.com/urfave/cli/blob/master/docs/v2/manual.md#powershell-support * Update docs/_interface/Bash-Autocomplete.md - From "Creates" to "Create" in Windows tutorial Co-authored-by: ligi <ligi@ligi.de> * Update docs/_interface/Bash-Autocomplete.md - From "Creates" to "Create" in Linux/MacOS tutorial Co-authored-by: ligi <ligi@ligi.de> * (_layouts): redirect to first element in documentation - Problem: The sidebar was redirecting to the wrong element in the list when we click on that. It was occuring because the logic inside of sidebar.html to build the list-group-item was carry about the frontdoc.url instead of the first element by itself. - Solution: We are sorting the collection.docs and then build the list-group-item with the right element in the list. Co-authored-by: ligi <ligi@ligi.de>
2 KiB
2 KiB
| title | sort_key |
|---|---|
| Bash Autocomplete | C |
You can enable autocompletion in geth just running a bash script (Linux/MacOS) or a powershell script (Windows).
Linux/MacOS
-
Create a bash script file with the content below and save as
geth-autocompletionanywhere in your computer (i.e./bin/geth-autocompletion):#! /bin/bash : ${PROG:=$(basename ${BASH_SOURCE})} _cli_bash_autocomplete() { if [[ "${COMP_WORDS[0]}" != "source" ]]; then local cur opts base COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" if [[ "$cur" == "-"* ]]; then opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) else opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) fi COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 fi } complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG unset PROG -
Open and edit your startup script depending on the terminal in use (i.e.
~/.bashrcor~/.zshrc). -
Includes this command in the final of your startup script:
# i.e. PROG=geth source /bin/geth-autocompletion PROG=geth source /path/to/autocomplete/geth-autocompletion-script
Windows
-
Create a powershell script file with the content below and save as
geth.ps1anywhere in your computer.$fn = $($MyInvocation.MyCommand.Name) $name = $fn -replace "(.*)\.ps1$", '$1' Register-ArgumentCompleter -Native -CommandName $name -ScriptBlock { param($commandName, $wordToComplete, $cursorPosition) $other = "$wordToComplete --generate-bash-completion" Invoke-Expression $other | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) } } -
Open the PowerShell profile (
code $profileornotepad $profile) and add the line:& path/to/autocomplete/geth.ps1