-
Notifications
You must be signed in to change notification settings - Fork 4
/
.bash_macosx
89 lines (73 loc) · 3.35 KB
/
.bash_macosx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#|------------------------------------------------------------------------------
#| bashfinder - control the finder with terminal
#|------------------------------------------------------------------------------
function ee {
osascript -e 'set cwd to do shell script "pwd"'\
-e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "set the target of window ${1-1} to (POSIX file cwd) as string"\
-e 'else' -e "open (POSIX file cwd) as string"\
-e 'end if' -e 'end tell';\
};\
# Check if a directory is passed to cd, eg: $ cd Desktop
# if no directory is specified typing cd changes dir to ~
function cdee() { if [ -z "$1" ]
then
cd ~; ee > /dev/null;
else
cd "$1"; ee > /dev/null;
fi
};
alias cd='cdee'
#|------------------------------------------------------------------------------
#| List view
#|------------------------------------------------------------------------------
# typing list at the prompt will change the current Finder window to list view
function list {
osascript -e 'set cwd to do shell script "pwd"'\
-e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "set the target of window ${1-1} to (POSIX file cwd) as string"\
-e "set the current view of the front Finder window to list view"\
-e 'else' -e "open (POSIX file cwd) as string"\
-e "set the current view of the front Finder window to list view"\
-e 'end if' -e 'end tell';\
};\
#|------------------------------------------------------------------------------
#| Icon view
#|------------------------------------------------------------------------------
# typing icon at the prompt will change the current Finder window to icon view
function icon {
osascript -e 'set cwd to do shell script "pwd"'\
-e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "set the target of window ${1-1} to (POSIX file cwd) as string"\
-e "set the current view of the front Finder window to icon view"\
-e 'else' -e "open (POSIX file cwd) as string"\
-e "set the current view of the front Finder window to icon view"\
-e 'end if' -e 'end tell';\
};\
#|------------------------------------------------------------------------------
#| Column view
#|------------------------------------------------------------------------------
# typing column at the prompt will change the current Finder window to column view
function column {
osascript -e 'set cwd to do shell script "pwd"'\
-e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "set the target of window ${1-1} to (POSIX file cwd) as string"\
-e "set the current view of the front Finder window to column view"\
-e 'else' -e "open (POSIX file cwd) as string"\
-e "set the current view of the front Finder window to column view"\
-e 'end if' -e 'end tell';\
};\
#|------------------------------------------------------------------------------
#| Change terminal directory to current directory open in the Finder
#|------------------------------------------------------------------------------
# cdff will change the terminal directory to current directory open in the Finder
function ff { osascript -e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "get POSIX path of (target of window ${1-1} as alias)"\
-e 'else' -e 'get POSIX path of (desktop as alias)'\
-e 'end if' -e 'end tell'; };\
function cdff { cd "`ff $@`"; };