Skip to content

Commit

Permalink
small tweaks/updates
Browse files Browse the repository at this point in the history
add directory traversal stuff
  • Loading branch information
yuhonas committed Jul 14, 2024
1 parent eea492a commit d3820f4
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions roles/dotfiles/files/Mackup/.oh-my-zsh/custom/custom.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ _tldr() {
zle -N _tldr

# custom keybindings for fast directory exploration
bindkey -s "^[l" "ls -al^J" # alt-l shortcut to listing a directory
bindkey -s "^[r" "ranger^J" # alt-r shortcut to file explorer
# custom keybinding for tldr help on the current command
bindkey "^[H" _tldr
Expand Down Expand Up @@ -100,20 +99,6 @@ if (( $+commands[kitty] )); then
alias d="kitty +kitten diff"
fi

# if we have todo.sh installed
# let's add some handy aliases
# https://github.com/todotxt/todo.txt-cli/wiki/Tips-and-Tricks
if (( $+commands[todo.sh] )); then
export TODOTXT_DEFAULT_ACTION=ls
export TODO_ACTIONS_DIR=$HOME/.config/todo/actions.d
alias t='todo.sh'
fi

# attempt to open up with emacs in daemon mode
# fallback to emacs if it's not running
# https://www.emacswiki.org/emacs/EmacsAsDaemon
# alias todo="emacsclient --alternate-editor emacs $HOME/TODO.org"

# fbr - checkout branch specified or provide a list of all git branches
# including remotes for selection
#
Expand Down Expand Up @@ -163,3 +148,38 @@ if (( $+commands[thefuck] )); then
fi


# Define the function to traverse the directory stack
function fzf_cd_stack() {
local dir
dir=$(dirs -v | fzf --height 40% --reverse --prompt="Dir Stack> ") && zle -I
if [[ -n $dir ]]; then
# Extract the directory path and change to it
local target_dir
target_dir=$(echo $dir | awk '{print $2}')
eval "cd $target_dir"
fi
zle reset-prompt
}

# zle -N fzf_cd_stack_widget fzf_cd_stack

# Bind the widget to Ctrl+G
# bindkey '^G' fzf_cd_stack_widget

fasd-fzf-cd-editor() {
item="$(fasd -Rl "$1" | fzf -1 -0 --no-sort +m)"
if [[ -d ${item} ]]; then
cd "${item}"
elif [[ -f ${item} ]]; then
($EDITOR "${item}" </dev/tty)
else
return 1
fi
zle accept-line
}

# zle -N fasd-fzf-cd-editor

# Bind the widget to Ctrl+E
# bindkey '^e' fasd-fzf-cd-editor

0 comments on commit d3820f4

Please sign in to comment.