public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 07/10] bash-completion: sys-utils
Date: Fri, 5 Apr 2013 16:44:53 +0200	[thread overview]
Message-ID: <20130405144453.GL14350@x2.net.home> (raw)
In-Reply-To: <1364422072-23552-8-git-send-email-kerolasa@iki.fi>

On Wed, Mar 27, 2013 at 10:07:49PM +0000, Sami Kerola wrote:
> diff --git a/shell-completion/swapon b/shell-completion/swapon
> new file mode 100644
> index 0000000..83e7e24
> --- /dev/null
> +++ b/shell-completion/swapon
> @@ -0,0 +1,48 @@
> +_swapon_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--priority')
> +			# Priority range is -1 to 32767.  Perhaps these
> +			# few are enough.
> +			COMPREPLY=( $(compgen -W "$(echo {-1..9} 32767)" -- $cur) )
> +			return 0
> +			;;
> +		'--show')
> +			# FIXME: how to append to a string with compgen?
> +			local OUTPUT
> +			OUTPUT="NAME TYPE SIZE USED PRIO"
> +			compopt -o nospace
> +			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
> +			return 0
> +			;;

What about to -L <label> and -U <uuid>? For example:

  lsblk -nrp -o FSTYPE,UUID | awk '$1 ~ /swap/ { print $2 }'

returns all swaps UUIDs

> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-a --all
> +				-d --discard
> +				-e --ifexists
> +				-f --fixpgsz
> +				-p --priority
> +				-s --summary
> +				   --show
> +				   --noheadings
> +				   --raw
> +				   --bytes
> +				-v --verbose
> +				-h --help
> +				-V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	# FIXME: compgen will split SPEC= from '=' point.  The append
> +	# comma separated value problem is very similar.
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}

 Would be better to offer list of block devices where is swap header?

   lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }'

 rather than list of files? I think that swap to files is unusual.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  parent reply	other threads:[~2013-04-05 14:45 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
2013-03-28 11:22   ` Sami Kerola
2013-03-29  9:42     ` Karel Zak
2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
2013-03-28  1:42   ` Dave Reisner
2013-04-01 15:54     ` Sami Kerola
2013-03-28  9:54   ` Karel Zak
2013-04-01 17:00     ` Sami Kerola
2013-03-27 22:07 ` [PATCH 03/10] bash-completion: fdisks Sami Kerola
2013-03-28 10:01   ` Karel Zak
2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
2013-03-28  1:42   ` Dave Reisner
2013-04-01 16:05     ` Sami Kerola
2013-03-28 10:05   ` Karel Zak
2013-04-01 16:06     ` Sami Kerola
2013-03-27 22:07 ` [PATCH 05/10] bash-completion: misc-utils Sami Kerola
2013-03-28  1:42   ` Dave Reisner
2013-04-01 16:52     ` Sami Kerola
2013-03-27 22:07 ` [PATCH 06/10] bash-completion: schedutils Sami Kerola
2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
2013-03-29 16:33   ` Karel Zak
2013-04-01 16:32     ` Sami Kerola
2013-04-05 14:44   ` Karel Zak [this message]
2013-03-27 22:07 ` [PATCH 08/10] bash-completion: term-utils Sami Kerola
2013-03-28 10:06   ` Karel Zak
2013-03-27 22:07 ` [PATCH 09/10] bash-completion: text-utils Sami Kerola
2013-03-27 22:07 ` [PATCH 10/10] bash-completion: add completion files to Makefile.am Sami Kerola
2013-03-28  1:42 ` [PATCH 00/10] [pull] bash-completion Dave Reisner
2013-03-28  9:37 ` Karel Zak
2013-03-31 23:49   ` Sami Kerola
2013-04-01 15:44   ` Sami Kerola
2013-04-05 14:11 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130405144453.GL14350@x2.net.home \
    --to=kzak@redhat.com \
    --cc=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox