From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19535 invoked from network); 23 Feb 2023 07:42:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Feb 2023 07:42:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1677138165; b=f577KwO+gRg8x3wNgPIDxg+xKg9NqTKCJAxQO1Sw7rbrzHBrPPpr+eMhKT8quHBy8boIRA3voF TSIG7fmnU9E1WTjlQNe9w62PZ+hwqrnT3Qwqkk12OVzwWnHuhSd0NI413bYT1R88HEBsskNAgE OuralJQ0g3rk/9iWyOn/iezkGpme61y0gHzsLaLLMYGMDXgM6v/9qOgEsr5XyBNlwjqc2HYGbX 7ds0H0wcbG2Nyohobg6eBbAiDsHTe+Vryp6nrRXWSGB6rBuEX9BG1XFd+MNVrTraU65nrcCkdw FJS/vkR37CmXSL3ucqGnPP69UpiEo6yWTHTWE5xb0LsYvA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pj1-f42.google.com) smtp.remote-ip=209.85.216.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1677138165; bh=FnHmSveWH7i7sb9xvOC5EYazNkmSSAbBGRuXQZUd1eY=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:DKIM-Signature: DKIM-Signature; b=Faknak6XAK97wi4oWJXMakQhbcC+68aAW3TfwXr7lIAjliqqMba4C5OW+NS+96/W1eMNTajbql a/lk1CH5UKKj4OQ7Q48c6GU/i9uTU8uKKo0Q+AVu/R3+AwRiWUHVH5A0ADv3lTFIjJ8MX9/8ov MJEbD0eGCHtS4I/axnqV+ZHY84z0RcvhNpk7DMfZgsYls385qU2sJgF0uoI6ekeAUfNV8cbB2B vcoQ/OqPLfGcBep6GbgQxHqPaG++ZiauuufA/jDtMod99bpZYaqawLWqcKFtq4Yf0zjq6xSo2w y29N1RkzLRzFxgeutH8rDCan2UIBgf8uZytdbsLw703Cvg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=sAHEDiOwVxOfcL78eRheWGX5uJfPluwZWoWSwhzla+A=; b=EtwpS3NPW3vTSgZvDVC5b9wI3d NvZkp1jcRimiB+dXK+YB4QxW3UceETRwlXOWq3rPW8IOxSqUzmrvbpgBHgg9qWt9H9696/cnU7t8C hHuvmUCj8yRBIgPGlgamVmmMT0Q11FTunmGQJfWFCxVj05F4v8BR7BFhTlyi/HVZ1+p/5Ja34sXQP 4pR+5Wp7itW232HLTQK4tbD+GD3H0BgdK9HcniZCTGiI1WTYoMpbtjC46d0ci8KeXwYTPSt2a9qub PWc2xhKlJhHo7U7j1iwr0rKyVt/sQrQMOc1AxRlCBUL6krdrvs8mXYtQQPgbOwyiZjI+V5cyA/fCX Zug3//dQ==; Received: by zero.zsh.org with local id 1pV6FY-000JTK-US; Thu, 23 Feb 2023 07:42:45 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pj1-f42.google.com) smtp.remote-ip=209.85.216.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pj1-f42.google.com ([209.85.216.42]:40485) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pV6Cl-000IVC-7D; Thu, 23 Feb 2023 07:39:52 +0000 Received: by mail-pj1-f42.google.com with SMTP id nw10-20020a17090b254a00b00233d7314c1cso11800472pjb.5 for ; Wed, 22 Feb 2023 23:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sAHEDiOwVxOfcL78eRheWGX5uJfPluwZWoWSwhzla+A=; b=M88Xg9rhJbm7v/06WiesypJ80SC+Kx8dw/h4eiYal9Z7jYxInDSSttP5YqixaaCpyR qUL/Npe/mvRmZjEwhkpLt1jMD4+4tzR1QhsoGvDIkCD/SVmwkBcyggzfLxA4YCQrD7yr XAl5UNgvUQ5IWYbHrICciXh9csBdf6Q9S0Rn/ZuBT88uVB77PhkwCwD5wwzc6S/iYZxU 8vY5XVYQllK9tn+T0cdZnm2/B1yxehoji+boMYxA4i+MjTHGqYa96zIqYGj87mlrMtqr a5LbsN/rBLJgqwXk63JTIsKNkllPMq8svtqKre/iSqWVrXCVAo4LC3l1WOaGESOrkUVv pHIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sAHEDiOwVxOfcL78eRheWGX5uJfPluwZWoWSwhzla+A=; b=j8dIrkI5c+gZL2u7lUyIAP/yU6nWpDrgilQRlBSZBNm+jOxnUJV+ujABzSmGUJ4MJn BJ3vTux/wVfRNHI9/2e4bHZklMEwRcY64eImwqLXNq3EJHUXSql3jjihIlFvDK/KtfFV S9JR60iodD3hPZ2GLOEoMMGl3neGQW2PP04RvcjRyyY6ewuZkKHI/Bxe5sNOFWJ35CFi FObnTyqwr5NhxMgQ+BbULp0xf++dgsd0o7hniXgXQ4cAEtzyYpxjXOim2o4QeDyspdJy AGhUCtT5LBpW9jspNmKWA7UIfP+F79vOmbgGaE8Y8JfWyUPglHeDwa+XRezaKpPEmUj5 Q12g== X-Gm-Message-State: AO0yUKUr0RdAPfIUzoZpAP9FoX27PPutlWapdBQrenzYVsTEGqOQafP+ SaxKjMpo8EMNX2lHloo+Wsw0W9nrCD8= X-Google-Smtp-Source: AK7set92Etp7ztVrVbghtBZ45R4SCazvj/HImSjgH9IEDCUldyYUovw8l7x0qpdku0JWMFRySz8yjg== X-Received: by 2002:a17:902:d48b:b0:19b:107b:6989 with SMTP id c11-20020a170902d48b00b0019b107b6989mr12782811plg.37.1677137989728; Wed, 22 Feb 2023 23:39:49 -0800 (PST) Received: from localhost.localdomain (49.212.151.152.v6.sakura.ne.jp. [2403:3a00:202:1112:49:212:151:152]) by smtp.gmail.com with ESMTPSA id x9-20020a170902820900b0019c33775574sm6547570pln.198.2023.02.22.23.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 23:39:49 -0800 (PST) From: Shohei YOSHIDA To: zsh-workers@zsh.org Cc: Shohei YOSHIDA Subject: [PATCH 1/1] Update cal/ncal completion Date: Thu, 23 Feb 2023 16:39:35 +0900 Message-Id: <20230223073935.600749-2-syohex@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230223073935.600749-1-syohex@gmail.com> References: <20230223073935.600749-1-syohex@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 51473 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: - Support util-linux and bsdmainutils cal on Linux - Support each BSD's implementations --- Completion/Unix/Command/_cal | 129 +++++++++++++++++++++++++++++++---- 1 file changed, 116 insertions(+), 13 deletions(-) diff --git a/Completion/Unix/Command/_cal b/Completion/Unix/Command/_cal index 82bb98b5f..b92e8153f 100644 --- a/Completion/Unix/Command/_cal +++ b/Completion/Unix/Command/_cal @@ -1,28 +1,131 @@ #compdef cal ncal -local args +local -a args +args=() case $service in cal) - args=( - '-3[three in a row]' - '-m[Monday as first day of the week]' - ) + # check util-linux's cal or bsdmainutils's cal + if $service --version 1>/dev/null 2>/dev/null ; then + args+=( + '(-1 --one)'{-1,--one}'[show only a single month]' + '(-3 --three)'{-3,--three}'[show three months spanning the date]' + '(-n --months)'{-n,--months=}"[show num months starting with date's month]:month" + '(-S --span)'{-S,--span}'[span the date when displaying multiple month]' + '(-s --sunday)'{-s,--sunday}'[Sunday as first day of week]' + '(-m --monday)'{-m,--monday}'[Monday as first day of week]' + '(-j --julian)'{-j,--julian}'[use day-of-year for all calendars]' + '--reform=[Gregorian reform date]:val:(1752 gregorian iso julian)' + '--iso[alias for --reform=iso]' + '(-y --year)'{-y,--year}'[show the whole year]' + '(-Y --twelve)'{-Y,--twelve}'[show the next twelve months]' + '(-w --week)'{-w,--week=-}'[show US or ISO-8601 week numbers]::num' + '(-v --vertical)'{-v,--vertical}'[show day vertically instead of line]' + '(-c --columns)'{-c,--columns=}'[amount of columns to use]:width' + '--color=-[colorize messages]:when:(auto always never)' + '(- *)'{-h,--help}'[display help]' + '(- *)'{-V,--version}'[display version]' + ) + else + case $OSTYPE in + (linux*|openbsd*|freebsd*|netbsd*|darwin*|dragonfly*) + args+=( + '-j[display Julian days]' + ) + ;| + (linux*|freebsd*|netbsd*|darwin*|dragonfly*) + args+=( + '-3[display the previous, current and next month surrounding today]' + '-A[months to add after]:months' + '-B[months to add before]:months' + ) + ;| + (freebsd*|netbsd*|darwin*|dragonfly*) + args+=( + '-h[turns off highlighting of today]' + ) + ;| + (netbsd*|openbsd*) + args+=( + '-y[display a calendar for the current year]' + ) + ;| + (linux*|freebsd*|darwin*|dragonfly*) + args+=( + '-m[display the specified month]:month' + '-y[display a calendar for the specified year]:year' + '-C[switch to cal mode]' + '-d[use yyyy-mm as the current date]:yyyy-mm' + ) + ;| + (freebsd*|darwin*|dragonfly*) + args+=( + '-N[switch to ncal mode]' + ) + ;| + (linux*) + args+=( + '-1[display only the current month]' + ) + ;| + (openbsd*) + args+=( + '-m[display weeks starting on Monday instead of Sunday]' + '-w[display week numbers in the month display]' + ) + ;| + (netbsd*) + args+=( + '-C[display context months before and after the specified month]:months' + '-d[specifies the day of the week on which the calendar should start]:day_of_week' + '-h[highlight the current day]' + '-R[selects an alternate Gregorian reform point from the default of September 3rd, 1752]:reform-sp' + '-r[display the month in which the Gregorian Reform adjustment was applied]' + ) + ;; + esac + fi ;; ncal) args=( - '-J[display Julian calendar]' - '-e[display date of western Easter]' - '-o[display date of orthodox Easter]' - '-p[assume as by ncal]' - '-s[country code]' - '-w[print number of the week below each column]' + '-h[turns off highlighting of today]' + '-J[display Julian Calendar]' + '-e[display date of Easter]' + '-j[display Julian days]' + '-o[display date of Orthodox Easter]' + '-m[display the specified month]:month' + '-p[print the country codes and switching days from Julian to Gregorian Calendar]' + '-s[assume the switch from Julian to Gregorian Calendar at the date associated with the country_code]:country_code' + '-w[print the number of the week below each week column]' + '-y[display a calendar for the specified year]:year' + '-3[display the previous, current and next month surrounding today]' + '-A[months to add after]:months' + '-B[months to add before]:months' + '-C[switch to cal mode]' + '-d[use yyyy-mm as the current date]:yyyy-mm' + '-H[use yyyy-mm-dd as the current date]:yyyy-mm-dd' + '-M[weeks start on Monday]' + '-S[weeks start on Sunday]' + '-W[first week of the year has at least number days]:number' + '-b[use oldstyle format for ncal output]' ) + + case $OSTYPE in + (linux*) + args+=( + '-b[use oldstyle format for ncal output]' + '-1[display only the current month]' + ) + ;; + (*) + args+=( + '-N[switch to ncal mode]' + ) + ;; + esac ;; esac _arguments "${args[@]}" \ - '-j[display Julian days]' \ - '-y[display a calendar for the current year]' \ '::month' \ ':year' -- 2.37.2