CLIカレンダーアプリケーションのkhalコマンドを使う

はじめに

CLIでカレンダー操作ができるkhalを使ってみる。

環境

MacOS Sonoma 14.5
Homebrew 4.3.4

khalのインストール

brew install khal
ログ
brew install khal
==> Downloading https://formulae.brew.sh/api/formula.jws.json

==> Downloading https://formulae.brew.sh/api/cask.jws.json

==> Downloading https://ghcr.io/v2/homebrew/core/khal/manifests/0.11.3-1
###################################################################################################################################################### 100.0%
==> Fetching khal
==> Downloading https://ghcr.io/v2/homebrew/core/khal/blobs/sha256:287062cef51ae2527f3419df8dac967cfac2a14a4ece4865f0c1213b550e46c4
###################################################################################################################################################### 100.0%
==> Pouring khal--0.11.3.sonoma.bottle.1.tar.gz
🍺  /usr/local/Cellar/khal/0.11.3: 1,021 files, 4.6MB
==> Running `brew cleanup khal`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

使ってみる

khal --help
ヘルプ
khal --help
Usage: khal [OPTIONS] COMMAND [ARGS]...

Options:
  -v, --verbosity LVL    Either CRITICAL, ERROR, WARNING, INFO or DEBUG
  -l, --logfile LOGFILE  The logfile to use [defaults to stdout]
  -c, --config PATH      The config file to use.
  --color / --no-color   Use colored/uncolored output. Default is to only
                         enable colors when not part of a pipe.
  --version              Show the version and exit.
  --help                 Show this message and exit.

Commands:
  at              Print all events at a specific datetime (defaults to now).
  calendar        Print calendar with agenda.
  configure       Helper for initial configuration of khal.
  edit            Interactively edit (or delete) events matching the...
  import          Import events from an .ics file (or stdin).
  interactive     Interactive UI.
  list            List all events between a start (default: today) and...
  new             Create a new event from arguments.
  printcalendars  List all calendars.
  printformats    Print a date in all formats.
  printics        Print an ics file (or read from stdin) without...
  search          Search for events matching SEARCH_STRING.

設定

khal configure
詳細
khal configure
What ordering of year, month, date do you want to use?
[0] year-month-day (today: 2024-06-11)
[1] day/month/year (today: 11/06/2024)
[2] month/day/year (today: 06/11/2024)
[3] Custom
Please choose one of the above options: 0
Date format: %Y-%m-%d (today as an example: 2024-06-11)

What timeformat do you want to use?
[0] 24 hour clock (recommended)
[1] 12 hour clock
Please choose one of the above options [0]: 0
Time format: %H:%M (current time as an example: 08:14)

[0] Create a new calendar on this computer
[1] Use a calendar already on this computer (vdir format)
[2] Sync a calendar from the internet (CalDAV format, requires vdirsyncer)
Please choose one of the above options: 0
Created new vdir at /Users/horibahiroto/.local/share/khal/calendars/private

Which calendar do you want as a default calendar?
(The default calendar is used when no calendar is specified.)
Configured calendars: private
Please type one of the above options (private) [private]: 
Do you want to write the config to ~/.config/khal/config? (Choosing `No` will abort) [Y/n]: y
created directory ~/.config/khal
Successfully wrote configuration to ~/.config/khal/config

カレンダーの閲覧

khal calendar
   月  火  水  木  金  土  日      No events
 6 27 28 29 30 31  1  2     
    3  4  5  6  7  8  9     
   10 11 12 13 14 15 16     
   17 18 19 20 21 22 23     
   24 25 26 27 28 29 30     
 7  1  2  3  4  5  6  7     
    8  9 10 11 12 13 14     
   15 16 17 18 19 20 21     
   22 23 24 25 26 27 28     
 8 29 30 31  1  2  3  4     
    5  6  7  8  9 10 11     
   12 13 14 15 16 17 18     
   19 20 21 22 23 24 25     
 9 26 27 28 29 30 31  1     

カレンダーの操作

khal interactive

カレンダーを対話形式で操作できる。

おわりに

カレンダー操作のアプリを見つけたので使ってみた。
CLIでできるのは面白いが使う機会は少なそうだ。

Hugo で構築されています。
テーマ StackJimmy によって設計されています。