Skip to content

Instantly share code, notes, and snippets.

@ldavidh
Last active November 11, 2024 20:35
Show Gist options
  • Save ldavidh/3f378bbf00621d23b07f3de42a0012a4 to your computer and use it in GitHub Desktop.
Save ldavidh/3f378bbf00621d23b07f3de42a0012a4 to your computer and use it in GitHub Desktop.
alternate sel script
#cd into directory in Finder's front window
function cdf() {
finderPath=`osascript -e 'try
tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error
tell application "Finder" to set source_folder to insertion location as alias
end try
return POSIX path of source_folder as string'`
cd "$finderPath"
}
#run ls for directory in Finder's front window
function lsf() {
finderPath=`osascript -e 'try
tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error
tell application "Finder" to set source_folder to insertion location as alias
end try
return POSIX path of source_folder as string'`
# echo "$finderPath"
# echo "-------------------------------------------------------"
ls "$finderPath"
}
function sel() {
workingD=$PWD
applescript='set theFiles to {}'
while read LINE; do
aLine=${LINE}
if [ ! -z "$aLine" -a "$aLine" != "" ]; then
filez="${workingD}/${aLine}"
applescript+="
try
set aFile to POSIX file \"$filez\"
set testFile to aFile as alias
if testFile is not missing value then
set end of theFiles to aFile
end if
(* on error errMsg
display dialog errMsg
*)
end try"
fi
done
applescript+='
if (count of theFiles) > 0 then
tell application "Finder"
select theFiles
activate
end tell
end if
return'
echo "$applescript" | osascript -
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment