mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 12:15:29 +00:00
feat: add Dotbot
This commit is contained in:
28
functions/fz.sh
Normal file
28
functions/fz.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
# Search z history with fzf
|
||||
|
||||
fz() {
|
||||
# Check if z is installed
|
||||
if ! command -v _z >/dev/null 2>&1; then
|
||||
echo "Error: z is not installed or not in PATH"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If arguments are provided, use z directly
|
||||
if [ $# -gt 0 ]; then
|
||||
_z "$*" && return
|
||||
fi
|
||||
|
||||
# Use fzf to select from z history
|
||||
local dir
|
||||
dir=$(_z -l 2>&1 | sed 's/^[0-9,.]* *//' |
|
||||
fzf --height 40% --nth 1.. --reverse --inline-info +s --tac --query "${*##-* }" \
|
||||
--preview 'ls -l {}' \
|
||||
--preview-window right:50% \
|
||||
--bind 'ctrl-/:change-preview-window(down|hidden|)' \
|
||||
--header 'Press CTRL-/ to toggle preview window')
|
||||
|
||||
# Change to the selected directory
|
||||
if [ -n "$dir" ]; then
|
||||
cd "$dir" || return 1
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user