Files
dotfiles/television/cable/git-files.toml
T

36 lines
875 B
TOML

[metadata]
name = "git-files"
description = """
Files tracked in the current git repository, most recently modified first
(all files under the cwd outside a repo). Enter opens the selection in nvim;
bound to ctrl-e in fish, zsh and bash.
"""
requirements = ["git", "fd", "bat", "mtime-sort"]
[source]
command = [
{ name = "Tracked", run = '''
if top=$(git rev-parse --show-toplevel 2>/dev/null); then
git -c core.quotePath=false ls-files -- "$top"
else
fd -t f
fi | mtime-sort
''' },
{ name = "All", run = "fd -t f -H -E .git | mtime-sort" },
]
shell = "bash"
[preview]
command = "bat -n --color=always '{}'"
env = { BAT_THEME = "ansi" }
# ctrl-e (edit) is bound globally in config.toml.
[keybindings]
enter = "actions:edit"
[actions.edit]
description = "Opens the selected entries in nvim"
command = "nvim {} </dev/tty >/dev/tty"
shell = "bash"
mode = "execute"