~gpanders/wk

5ea9f9606b6e88ce1fe118bed6e2302748ce4ab0 — Greg Anders 3 months ago c0e190f
Update 'show' command aliases in completion files
4 files changed, 8 insertions(+), 8 deletions(-)

M completions/bash/zet
M completions/fish/zet.fish
M src/cmd/open.zig
M src/cmd/show.zig
M completions/bash/zet => completions/bash/zet +2 -2
@@ 5,7 5,7 @@ _zet () {

    local cur commands
    cur="${COMP_WORDS[COMP_CWORD]}"
    commands="backlinks show open list search sync new tags help preview"
    commands="backlinks show open list sync new tags help preview"

    if [ "$COMP_CWORD" -eq 1 ]; then
        while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$commands" -- "$cur")


@@ 20,7 20,7 @@ _zet () {
    zettels=$(compgen -f "$ZETTEL_DIR/" | sed -E -e 's/.*\///g' -e '/^[0-9]{14}/!d' -e 's/\..*$//')

    case "${COMP_WORDS[1]}" in
        bl|backlinks|sh|show|o|open|p|pre|prev|preview)
        bl|backlinks|s|sh|show|o|open|p|pre|prev|preview)
            # compgen only returns prefix-matches, but we want to return
            # matches anywhere in the substring, so use grep to generate the
            # results

M completions/fish/zet.fish => completions/fish/zet.fish +1 -1
@@ 17,7 17,7 @@ function __fish_complete_zettel_tags
end

complete -k -x -c zet -n '__fish_seen_subcommand_from bl backlinks' -a '(__fish_complete_zettels)'
complete -k -x -c zet -n '__fish_seen_subcommand_from sh show' -a '(__fish_complete_zettels)'
complete -k -x -c zet -n '__fish_seen_subcommand_from s sh show' -a '(__fish_complete_zettels)'
complete -k -x -c zet -n '__fish_seen_subcommand_from o open' -a '(__fish_complete_zettels)'
complete -k -x -c zet -n '__fish_seen_subcommand_from p pre prev preview' -a '(__fish_complete_zettels)'
complete -k -x -c zet -n '__fish_seen_subcommand_from t tag tags' -a '(__fish_complete_zettel_tags)'

M src/cmd/open.zig => src/cmd/open.zig +2 -2
@@ 13,8 13,8 @@ const commit = @import("../util.zig").commit;
pub const cmd = Command{
    .name = "open",
    .aliases = &[_][]const u8{"o"},
    .usage = "o|open [NOTE [NOTE ...]]",
    .desc = "Open the given notes in your $EDITOR.",
    .usage = "o|open [PATTERN [PATTERN ...]]",
    .desc = "Open notes matching any of the supplied PATTERNs in your editor. With no argument, start your editor in ZETTEL_DIR.",
    .run = run,
};


M src/cmd/show.zig => src/cmd/show.zig +3 -3
@@ 10,9 10,9 @@ const getZettels = @import("../zettel.zig").getZettels;

pub const cmd = Command{
    .name = "show",
    .aliases = &[_][]const u8{"s"},
    .usage = "s|show <NOTE> [NOTE ...]",
    .desc = "Display contents of notes to stdout.",
    .aliases = &[_][]const u8{ "s", "sh" },
    .usage = "s|show <PATTERN> [PATTERN ...]",
    .desc = "Display contents of notes containing PATTERN.",
    .run = run,
};