Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1# Disable files from being included in completions by default2complete --command bitcoin-cli --no-files4function __fish_bitcoin_cli_get_commands_helper5set --local cmd (commandline -oc)7# Don't return commands if '-help or -?' in commandline8if string match --quiet --regex -- '^-help$|^-\?$' $cmd9return10end12# Strip help cmd from token to avoid duplication errors13set --local cmd (string match --invert --regex -- '^help$' $cmd)14# Strip -stdin* options to avoid waiting for input while we fetch completions15# TODO: this appears to be broken when run as tab completion (requires ctrl+c to exit)16set --local cmd (string match --invert --regex -- '^-stdin.*$' $cmd)18# Match, format and return commands19for command in ($cmd help 2>&1 | string match --invert -r '^\=\=.*' | string match --invert -r '^\\s*$')20echo $command21end22end24function __fish_bitcoin_cli_get_commands25argparse 'nohelp' 'commandsonly' -- $argv26set --local commands28# Exclude description, exclude help29if set -q _flag_nohelp; and set -q _flag_commandsonly30set --append commands (__fish_bitcoin_cli_get_commands_helper | string replace -r ' .*$' '' | string match --invert -r 'help')31# Include description, exclude help32else if set -q _flag_nohelp33set --append commands (__fish_bitcoin_cli_get_commands_helper | string replace ' ' \t | string match --invert -r 'help')34# Exclude description, include help35else if set -q _flag_commandsonly36set --append commands (__fish_bitcoin_cli_get_commands_helper | string replace -r ' .*$' '')37# Include description, include help38else39set --append commands (__fish_bitcoin_cli_get_commands_helper | string replace ' ' \t)40end42if string match -q -r '^.*error.*$' $commands[1]43# RPC offline or RPC wallet not loaded44return45else46for command in $commands47echo $command48end49end50end53function __fish_bitcoin_cli_get_options54argparse 'nofiles' -- $argv55set --local cmd (commandline -oc)56# Don't return options if '-help or -?' in commandline57if string match --quiet --regex -- '^-help$|-\?$' $cmd58return59end60set --local options62if set -q _flag_nofiles63set --append options ($cmd -help 2>&1 | string match -r '^ -.*' | string replace -r ' -' '-' | string replace -r '=.*' '=' | string match --invert -r '^.*=$')64else65set --append options ($cmd -help 2>&1 | string match -r '^ -.*' | string replace -r ' -' '-' | string replace -r '=.*' '=' | string match -r '^.*=$')66end68for option in $options69echo $option70end71end73# Add options with file completion74# Don't offer after a command is given75complete \76--command bitcoin-cli \77--no-files \78--condition "not __fish_seen_subcommand_from (__fish_bitcoin_cli_get_commands --commandsonly)" \79--arguments "(__fish_bitcoin_cli_get_options)"80# Enable file completions only if the commandline now contains a `*.=` style option81complete --command bitcoin-cli \82--condition 'string match --regex -- ".*=" (commandline -pt)' \83--force-files85# Add options without file completion86# Don't offer after a command is given87complete \88--command bitcoin-cli \89--no-files \90--condition "not __fish_seen_subcommand_from (__fish_bitcoin_cli_get_commands --commandsonly)" \91--arguments "(__fish_bitcoin_cli_get_options --nofiles)"93# Add commands94# Permit command completions after `bitcoin-cli help` but not after other commands95complete \96--command bitcoin-cli \97--no-files \98--condition "not __fish_seen_subcommand_from (__fish_bitcoin_cli_get_commands --commandsonly --nohelp)" \99--arguments "(__fish_bitcoin_cli_get_commands)"
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.