Skip to content

Commit cfcd0cd

Browse files
committed
Implement fasd_cd
1 parent 43a9990 commit cfcd0cd

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

fasd.fish

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
function init --on-event init_fasd
2+
# Detect fasd
23
if not available fasd
34
echo "🍒 Please install 'fasd' first!"
4-
else
5-
function -e fish_preexec _run_fasd
6-
fasd --proc (fasd --sanitize "$argv") > "/dev/null" 2>&1
7-
end
5+
return
6+
end
87

9-
function j
10-
cd (fasd -d -e 'printf %s' "$argv")
8+
#
9+
# Fish hooks
10+
#
11+
function -e fish_preexec _run_fasd
12+
fasd --proc (fasd --sanitize "$argv") > "/dev/null" 2>&1
13+
end
14+
15+
function fasd_cd -d 'Function to execute built-in cd'
16+
# if no $argv, identical with `fasd`
17+
set -l N (count $argv ^ /dev/null)
18+
if [ "$N" -le 1 ]
19+
fasd "$argv"
20+
else
21+
set -l ret (fasd -e 'printf %s' $argv)
22+
[ -z "$ret" ]; and return
23+
[ -d "$ret" ]; and cd "$ret"; or printf "%s\n" $ret
1124
end
1225
end
26+
27+
alias a='fasd -a'
28+
alias s='fasd -si'
29+
alias sd='fasd -sid'
30+
alias sf='fasd -sif'
31+
alias d='fasd -d'
32+
alias f='fasd -f'
33+
alias z='fasd_cd -d'
34+
alias zz='fasd_cd -di'
1335
end

0 commit comments

Comments
 (0)