Skip to content

Commit

Permalink
cleaned up some whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Powers committed Aug 7, 2015
1 parent e8826a6 commit e7d2456
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions data/bash-completion/s4cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,58 @@ _s4cmd ()
prevprev=${COMP_WORDS[COMP_CWORD-2]}
_init_completion || return

#echo -e "\nCurrent: $cur : Prev: $prev : Words: $words : Cword: $cword : Command: $command\n"
if [[ $cword -eq 1 ]]; then
#command
COMPREPLY=( $( compgen -W 'ls put get cp mv sync del du' -- "$cur" ) )
COMPREPLY=($( compgen -W 'ls put get cp mv sync del du' -- "$cur" ))
COMPREPLY=("${COMPREPLY[@]/%/ }")
elif [[ $cword -ge 2 ]]; then
params=${COMP_WORDS[@]:2}
if [ "$prevprev" == "s3" ]
then
#get initial bucket names
if [[ $cur =~ ^\/\/$ ]]; then
buckets=`s4cmd ls 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"`
COMPREPLY=( $( compgen -W "$buckets" -- "$cur" ) )
buckets=($(s4cmd ls 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"))
COMPREPLY=($(compgen -W "$buckets" -- "$cur"))
return 0

#help get buckets full names
elif [[ $cur =~ ^\/\/[^\/]*$ ]]; then
buckets=`s4cmd ls 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"`
COMPREPLY=( $( compgen -W "$buckets" -- "$cur" ) )
buckets=($(s4cmd ls 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"))
COMPREPLY=($(compgen -W "$buckets" -- "$cur"))
return 0

#get contents of dir
elif [[ $cur =~ ^\/\/.*\/$ ]]; then
buckets=`s4cmd ls s3:$cur 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"`
COMPREPLY=( $( compgen -W "$buckets" -- "$cur" ) )
buckets=($(s4cmd ls s3:$cur 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"))
COMPREPLY=($(compgen -W "$buckets" -- "$cur"))
return 0

#help get buckets contents
elif [[ $cur =~ ^\/\/.*\/.*$ ]]; then
checkdir=`dirname "$cur"`
buckets=`s4cmd ls s3:$checkdir 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"`
COMPREPLY=( $( compgen -W "$buckets" -- "$cur" ) )
checkdir=($(dirname "$cur"))
buckets=($(s4cmd ls s3:$checkdir 2>/dev/null | grep -Eo "s3://.*" | grep -Eo "//.*"))
COMPREPLY=($(compgen -W "$buckets" -- "$cur"))
return 0
fi
fi
case "$command" in
ls)
COMPREPLY=( $( compgen -W "--recursive --show-directory" -- "$cur" ) )
COMPREPLY=($(compgen -W "--recursive --show-directory" -- "$cur"))
COMPREPLY=("${COMPREPLY[@]/%/ }")
return 0
;;
put|get|sync|cp|mv)
COMPREPLY=( $( compgen -W "--recursive --sync-check --force --dry-run" -- "$cur" ) )
COMPREPLY=($(compgen -W "--recursive --sync-check --force --dry-run" -- "$cur"))
COMPREPLY=("${COMPREPLY[@]/%/ }")
return 0
;;
del)
COMPREPLY=( $( compgen -W "--recursive --dry-run" -- "$cur" ) )
COMPREPLY=($(compgen -W "--recursive --dry-run" -- "$cur"))
COMPREPLY=("${COMPREPLY[@]/%/ }")
return 0
;;
du)
COMPREPLY=( $( compgen -W "--recursive" -- "$cur" ) )
COMPREPLY=($(compgen -W "--recursive" -- "$cur"))
COMPREPLY=("${COMPREPLY[@]/%/ }")
return 0
;;
Expand Down

0 comments on commit e7d2456

Please sign in to comment.