Unable to run programs with 0700 protection. When logging into Zsh

I have the following code that is supposed to run programs in Bash.

if [ "`uname`" = "Darwin" ]; then
   compctl -f -x 'p[2]' -s "`/bin/ls -d1 /Applications/*/*.app
/Application:/*.app | sed 's|^.*/\([^/]*\)\.app.*|\\1|;s/ /\\\\ /g'`"                 
-- open
   alias run='open -a' 
fi

      

However, it doesn't work at all in my Zsh. I cannot open any programs with it.

Another error it has is that it opens all programs. I only want to have runnable programs whose permissions are 700.

I know you can search these programs pretty well

 find -perm 700 -type f *.app

      

However, I couldn't get my find-work command to work for every file in the program. This suggests that there might be a better way to make programs run in the terminal.

How can you run programs in Zsh on Mac / Ubuntu?

0


a source to share


2 answers


How do you feel about aliases instead of completion? The aliases are still filled. Splitting along lines to make it easier to read ...

`print -l /Applications/**/MacOS/*(*f:700:) | 
grep -v "Contents.*Contents" | 
sed -e "s#\(.*/\)\([^./]*\)\(\.app\)\(.*\)#alias \2=\"\1\2\3\4\"#g"`

      

The former prints each match on its own line, the latter removes the application subpackages, and the latter generates an alias command. Delete the back exits to see and confirm the generated commands.



[Edit:] Executes the executable directly - if you prefer to use the open blah.app method, you can change the final part of the sed command:

#alias \2=\"open \1\2\3\"#

      

+2


a source


Oh, zsh. It always makes things interesting.

But there are some ways to make it easier to debug these things. The first thing I would like to do is move away from ls

, and use instead find

, since you want path names, not human-readable lists:



find . -executable -a -name \*.app

      

possibly....

+2


a source







All Articles