Skip to content

Commit d3820f4

Browse files
committedJul 14, 2024·
small tweaks/updates
add directory traversal stuff
1 parent eea492a commit d3820f4

File tree

1 file changed

+35
-15
lines changed
  • roles/dotfiles/files/Mackup/.oh-my-zsh/custom

1 file changed

+35
-15
lines changed
 

‎roles/dotfiles/files/Mackup/.oh-my-zsh/custom/custom.zsh

+35-15
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ _tldr() {
4545
zle -N _tldr
4646

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

103-
# if we have todo.sh installed
104-
# let's add some handy aliases
105-
# https://github.com/todotxt/todo.txt-cli/wiki/Tips-and-Tricks
106-
if (( $+commands[todo.sh] )); then
107-
export TODOTXT_DEFAULT_ACTION=ls
108-
export TODO_ACTIONS_DIR=$HOME/.config/todo/actions.d
109-
alias t='todo.sh'
110-
fi
111-
112-
# attempt to open up with emacs in daemon mode
113-
# fallback to emacs if it's not running
114-
# https://www.emacswiki.org/emacs/EmacsAsDaemon
115-
# alias todo="emacsclient --alternate-editor emacs $HOME/TODO.org"
116-
117102
# fbr - checkout branch specified or provide a list of all git branches
118103
# including remotes for selection
119104
#
@@ -163,3 +148,38 @@ if (( $+commands[thefuck] )); then
163148
fi
164149

165150

151+
# Define the function to traverse the directory stack
152+
function fzf_cd_stack() {
153+
local dir
154+
dir=$(dirs -v | fzf --height 40% --reverse --prompt="Dir Stack> ") && zle -I
155+
if [[ -n $dir ]]; then
156+
# Extract the directory path and change to it
157+
local target_dir
158+
target_dir=$(echo $dir | awk '{print $2}')
159+
eval "cd $target_dir"
160+
fi
161+
zle reset-prompt
162+
}
163+
164+
# zle -N fzf_cd_stack_widget fzf_cd_stack
165+
166+
# Bind the widget to Ctrl+G
167+
# bindkey '^G' fzf_cd_stack_widget
168+
169+
fasd-fzf-cd-editor() {
170+
item="$(fasd -Rl "$1" | fzf -1 -0 --no-sort +m)"
171+
if [[ -d ${item} ]]; then
172+
cd "${item}"
173+
elif [[ -f ${item} ]]; then
174+
($EDITOR "${item}" </dev/tty)
175+
else
176+
return 1
177+
fi
178+
zle accept-line
179+
}
180+
181+
# zle -N fasd-fzf-cd-editor
182+
183+
# Bind the widget to Ctrl+E
184+
# bindkey '^e' fasd-fzf-cd-editor
185+

0 commit comments

Comments
 (0)
Please sign in to comment.