mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
61 lines
1.7 KiB
TOML
61 lines
1.7 KiB
TOML
[metadata]
|
|
name = "ghq-repos"
|
|
description = """
|
|
ghq repositories (plus the chezmoi source tree) and Obsidian vaults, newest
|
|
git activity first. Enter prints the directory; the gho shell function (ctrl-o
|
|
in fish, zsh and bash) cds into it.
|
|
"""
|
|
requirements = ["ghq", "fd", "onefetch", "mtime-sort"]
|
|
|
|
# Entries are "<name>\t<absolute path>": the name is what you fuzzy-match, the
|
|
# path is what enter prints. ctrl-s cycles repos → vaults.
|
|
[source]
|
|
command = [
|
|
{ name = "Repos", run = '''
|
|
root=$(ghq root)
|
|
{
|
|
ghq list | awk -v r="$root" '{ print $0 "\t" r "/" $0 }'
|
|
# chezmoi's source is a github.com/prdlk/dotfiles checkout outside ghq root.
|
|
c=$HOME/.local/share/chezmoi
|
|
[ -d "$c/.git" ] && printf 'github.com/prdlk/dotfiles\t%s\n' "$c"
|
|
} | mtime-sort --repo
|
|
''' },
|
|
{ name = "Vaults", run = '''
|
|
v=$HOME/Documents/Obsidian
|
|
fd -H -t d -d 3 '^\.obsidian$' "$v" -x dirname |
|
|
awk -v r="$v/" '{ print substr($0, length(r) + 1) "\t" $0 }' |
|
|
mtime-sort
|
|
''' },
|
|
]
|
|
shell = "bash"
|
|
display = "{split:\\t:0}"
|
|
output = "{split:\\t:1}"
|
|
|
|
[preview]
|
|
command = '''
|
|
d='{split:\t:1}'
|
|
if [ -e "$d/.git" ]; then
|
|
onefetch --no-art "$d" 2>&1
|
|
else
|
|
eza --tree --level 2 --color=always "$d" 2>/dev/null || ls -la "$d"
|
|
fi
|
|
'''
|
|
shell = "bash"
|
|
|
|
# ctrl-e (edit) is bound globally in config.toml.
|
|
[keybindings]
|
|
ctrl-b = "actions:browse"
|
|
|
|
[actions.edit]
|
|
description = "Open the repository in nvim"
|
|
# /dev/tty: the gho wrapper captures tv's stdout to read the picked path.
|
|
command = "cd '{split:\\t:1}' && nvim . </dev/tty >/dev/tty"
|
|
shell = "bash"
|
|
mode = "execute"
|
|
|
|
[actions.browse]
|
|
description = "Open the repository's web page (gop)"
|
|
command = "cd '{split:\\t:1}' && gop >/dev/null 2>&1"
|
|
shell = "bash"
|
|
mode = "fork"
|