Repository navigation
Open
Description
Introduce a dotfiles-bin-latest utility (zsh function + alias) for quickly opening the most recently modified executables from ~/.dotfiles/bin in Sublime Text.
The current implementation defaults to opening the top 5 files in a new Sublime window, safely handling filenames with spaces or special characters. It also includes -h/--help and allows the count to be configurable.
Future enhancements:
- Convert into a standalone script in
~/.dotfiles/binfor easier portability and reuse. - Add an interactive
fzfmode with previews and keybindings (Enterto edit,Ctrl-Oto open,Ctrl-Yto copy path,Ctrl-Pto toggle preview, etc.), similar to the gist picker UI.
Below is a draft prototype that I vibed together with ChatGPT (GPT-5):
/usr/bin/env zsh
# TODO: Consider making this a proper standalone script in ~/.dotfiles/bin
# TODO: Add aa fzf mode with previews and interactive bindings
# Reference for future fzf mode:
# --------------------------------------------------------------------
# local footer=$'Enter: Edit Ctrl-O: Open Ctrl-Y: Copy Path Ctrl-P: Preview'
#
# ls -1t "$HOME/.dotfiles/bin" \
# | ansifilter \
# | sed 's/\*$//' \
# | column -t \
# | fzf \
# --prompt 'dotfiles-bin> ' \
# --ghost 'Type to filter files' \
# --info=inline-right \
# --input-border \
# --footer "$footer" \
# --footer-border=line \
# --reverse \
# --with-nth '1..' \
# --accept-nth 1 \
# --bind 'enter:execute(subl --new-window ~/.dotfiles/bin/{1})' \
# --preview 'bat --style=plain --color=always ~/.dotfiles/bin/{1}' \
# --preview-window 'right,50%,border-left,wrap,hidden' \
# --bind 'ctrl-p:toggle-preview' \
# --bind 'ctrl-o:execute-silent(open ~/.dotfiles/bin/{1})' \
# --bind 'ctrl-y:execute-silent(
# printf %s "$HOME/.dotfiles/bin/{1}" | pbcopy
# )+transform-footer(echo Copied path to clipboard)+bg-transform-footer(
# sleep 1; printf %s "$footer"
# )' \
# --bind 'click-footer:transform:
# [[ $FZF_CLICK_FOOTER_WORD =~ Ctrl|Enter ]] && echo "trigger(${FZF_CLICK_FOOTER_WORD%:*})"
# '
# --------------------------------------------------------------------
# Open the latest files from ~/.dotfiles/bin in Sublime
# Usage:
# dotfiles-bin-latest [COUNT]
# dotfiles-bin-latest -h | --help
#
# Options:
# COUNT Number of latest files to open (default: 5)
# -h, --help Show this help message
_dotfiles-bin-latest() {
local script_name="${0##*/}"
local count=5
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
cat <<EOF
Usage: $script_name [COUNT]
Open the latest executables from ~/.dotfiles/bin in Sublime Text.
Options:
COUNT Number of latest files to open (default: 5)
-h, --help Show this help message
EOF
return 0
;;
*)
count="$1"
;;
esac
shift
done
ls -1t "$HOME/.dotfiles/bin" \
| ansifilter \
| sed 's/\*$//' \
| head -n "$count" \
| while IFS= read -r f; do
printf '%s\0' "$HOME/.dotfiles/bin/$f"
done \
| xargs -0 subl --new-window
}
alias dotfiles-bin-latest="_dotfiles-bin-latest"Metadata
Metadata
Assignees
Labels
No labels
Activity