mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 12:15:29 +00:00
I tried Nix, but it had too many downsides so I removed it. 1. Didn't like that all files are immutable and simple config changes need a complete rebuild. 2. Setting up a new Mac didn't work as smoothly as promised. Not worth the effort. 3. It sucked a lot to always have to type in the password twice on each darwin-rebuild 4. It solves problems I never had.
29 lines
800 B
Bash
29 lines
800 B
Bash
# 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
|
|
}
|