# bash completion for gphoto2(1) -*- shell-script -*- proc _gphoto2 { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s -n : || return matchstr $prev { --debug-logfile { _filedir return 0 } --hook-script { _filedir return 0 } --filename { _filedir return 0 } -u|--upload-file { _filedir return 0 } --port { global COMPREPLY := '( '$(compgen -W "$( $1 --list-ports 2>/dev/null | \ awk 'NR>3 { print $1 }' )" -- "$cur") ) __ltrim_colon_completions $cur return 0 } --camera { var IFS = '$'\n'' global COMPREPLY := '( '$(compgen -W "$( $1 --list-cameras 2>/dev/null | \ awk -F'"' 'NR>2 { print $2 }' )" -- "$cur") ) return 0 } --get-config|--set-config|--set-config-index|--set-config-value { global COMPREPLY := '( '$(compgen -W "$( $1 --list-config 2>/dev/null \ )" -- "$cur") ) return 0 } } $split && return if [[ "$cur" == -* ]] { global COMPREPLY := '( '$( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return 0 } } && complete -F _gphoto2 gphoto2 # ex: ts=4 sw=4 et filetype=sh (CommandList children: [ (AndOr children: [ (FuncDef name: _gphoto2 body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs:(LhsName name:cur) op:Equal spids:[13]) (assign_pair lhs:(LhsName name:prev) op:Equal spids:[15]) (assign_pair lhs:(LhsName name:words) op:Equal spids:[17]) (assign_pair lhs:(LhsName name:cword) op:Equal spids:[19]) (assign_pair lhs:(LhsName name:split) op:Equal spids:[21]) ] spids: [11] ) (AndOr children: [ (C {(_init_completion)} {(-s)} {(-n)} {(Lit_Other ":")}) (ControlFlow token:) ] op_id: Op_DPipe ) (Case to_match: {($ VSub_Name "$prev")} arms: [ (case_arm pat_list: [{(--debug-logfile)}] action: [ (C {(_filedir)}) (ControlFlow token: arg_word: {(0)} ) ] spids: [45 46 57 -1] ) (case_arm pat_list: [{(--hook-script)}] action: [ (C {(_filedir)}) (ControlFlow token: arg_word: {(0)} ) ] spids: [60 61 72 -1] ) (case_arm pat_list: [{(--filename)}] action: [ (C {(_filedir)}) (ControlFlow token: arg_word: {(0)} ) ] spids: [75 76 87 -1] ) (case_arm pat_list: [{(-u)} {(--upload-file)}] action: [ (C {(_filedir)}) (ControlFlow token: arg_word: {(0)} ) ] spids: [90 93 104 -1] ) (case_arm pat_list: [{(--port)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(compgen)} {(-W)} { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (SimpleCommand words: [ {($ VSub_Number "$1")} {(--list-ports)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [126] ) ] ) (C {(awk)} {(SQ <"NR>3 { print $1 }">)} ) ] negated: False ) ] ) left_token: spids: [120 139] ) ) } {(--)} {(DQ ($ VSub_Name "$cur"))} ) ] ) left_token: spids: [114 147] ) } ] ) } spids: [111] ) ] spids: [111] ) (C {(__ltrim_colon_completions)} {(DQ ($ VSub_Name "$cur"))}) (ControlFlow token: arg_word: {(0)} ) ] spids: [107 108 164 -1] ) (case_arm pat_list: [{(--camera)}] action: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:IFS) op: Equal rhs: {(SQ )} spids: [173] ) ] spids: [171] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(compgen)} {(-W)} { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (SimpleCommand words: [ {($ VSub_Number "$1")} {(--list-cameras)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [194] ) ] ) (C {(awk)} {(-F) (SQ <"\"">)} {(SQ <"NR>2 { print $2 }">)} ) ] negated: False ) ] ) left_token: spids: [188 212] ) ) } {(--)} {(DQ ($ VSub_Name "$cur"))} ) ] ) left_token: spids: [182 220] ) } ] ) } spids: [179] ) ] spids: [179] ) (ControlFlow token: arg_word: {(0)} ) ] spids: [167 168 230 -1] ) (case_arm pat_list: [ {(--get-config)} {(--set-config)} {(--set-config-index)} {(--set-config-value)} ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(compgen)} {(-W)} { (DQ (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [ {($ VSub_Number "$1")} {(--list-config)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [258] ) ] ) ] ) left_token: spids: [252 263] ) ) } {(--)} {(DQ ($ VSub_Name "$cur"))} ) ] ) left_token: spids: [246 271] ) } ] ) } spids: [243] ) ] spids: [243] ) (ControlFlow token: arg_word: {(0)} ) ] spids: [233 240 281 -1] ) ] spids: [38 42 284] ) (AndOr children: [ (C {($ VSub_Name "$split")}) (ControlFlow token:) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$cur"))} right: {(-) (Lit_Other "*")} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(compgen)} {(-W)} {(SQ <"$( _parse_help \"$1\" )">)} {(--)} {(DQ ($ VSub_Name "$cur"))} ) ] ) left_token: spids: [318 334] ) } ] ) } spids: [315] ) ] spids: [315] ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$COMPREPLY")} right: {(Lit_Other "*") (BoolBinary_GlobEqual "=")} ) ) (C {(compopt)} {(-o)} {(nospace)}) ] op_id: Op_DAmp ) (ControlFlow token: arg_word: {(0)} ) ] spids: [-1 312] ) ] spids: [-1 364] ) ] spids: [8] ) spids: [4 7] ) (C {(complete)} {(-F)} {(_gphoto2)} {(gphoto2)}) ] op_id: Op_DAmp ) ] )