napoleonwils0n / bashfinder Goto Github PK
View Code? Open in Web Editor NEWControl the Mac Finder from the Terminal
Control the Mac Finder from the Terminal
$ source .bash_profile
$ cd
[Process completed]
mv .bash_profile ~/.bash_profile
But I have things in ~/.bash_profile that I like.
I was working on a fork but in the end I get what amounts to a new project tree, so I'll leave this with you. I strongly recommend adding the OSX_FINDER_FOCUS option like I show there, and also prefixing function names with __ (this is a convention you will see elsewhere). It also would be better if, like other small bash scripts, this one only included the important functions, and left it to the user to provide alias mappings to them.
__osx_win() {
if [[ -z "$1" ]]; then
local dir="$HOME"
else
local dir="$1"
fi
\cd "$dir" && __osx_open > /dev/null
}
__osx_open() { __osx_finder; }
__osx_column() { __osx_finder column; }
__osx_icon() { __osx_finder icon; }
__osx_list() { __osx_finder list; }
__osx_mirror() {
cd "$(__osx_cwd)"
}
__osx_view() {
__osx_finder "set the current view of the front Finder window to $1 view"
}
__osx_finder() {
osascript -e 'set cwd to do shell script "pwd"' \
-e 'tell application "Finder"' \
-e 'if (1 <= (count Finder windows)) then' \
-e 'set the target of window 1 to (POSIX file cwd) as string' \
-e "$1" \
-e 'else' \
-e 'open (POSIX file cwd) as string' \
-e "$1" \
-e 'end if' -e 'end tell'
if [[ "$?" && -n "$OSX_FINDER_FOCUS" ]]; then
open -a Finder
fi
}
__osx_cwd() {
osascript -e 'tell application "Finder"' \
-e 'if (1 <= (count Finder windows)) then' \
-e 'get POSIX path of (target of window 1 as alias)' \
-e 'else' \
-e 'get POSIX path of (desktop as alias)' \
-e 'end if' \
-e 'end tell'
}
alias ee=__osx_open
alias cd=__osx_win
alias cdff=__osx_mirror
alias list=__osx_list
alias icon=__osx_icon
alias column=__osx_column
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.