Skip to content

Commit 55b141f

Browse files
committed
[zsh] mscripts: include executatble symlinks in list
1 parent fdf9b63 commit 55b141f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

zsh/.config/zsh/functions

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,22 @@ m() {
9696

9797
script="$1"
9898
[ -n "$1" ] && shift
99-
mscript="$(find .mscripts/ -type f -executable | tail -n+2 | xargs -n1 basename | fzf --query "$script" -1)"
99+
100+
# Need the funky find command below as we want to find all files or symlinks
101+
# \( ... \) groups expressions for logical precedence (escaped for the shell);
102+
# -type f: regular files; -type l: symlinks; -o: OR; -perm /111: any executable bit set
103+
mscript="$(find .mscripts \( -type f -o -type l \) -perm /111 |
104+
tail -n+2 | xargs -n1 basename |
105+
fzf --query "$script" -1)"
100106

101107
if [ -z "$mscript" ]; then
102108
echo "No mscript available for $script"
103-
cd "$prev_dir" >/dev/null
109+
cd "$prev_dir" >/dev/null || return 1
104110
return 1
105111
fi
106112

107113
eval .mscripts/"$mscript" $*
108-
cd "$prev_dir" >/dev/null
114+
cd "$prev_dir" >/dev/null || return 1
109115
}
110116

111117
mm() {

0 commit comments

Comments
 (0)