How to indent AppleScript oneliner
up vote
1
down vote
favorite
I have an AppleScript oneliner that I would like to indent. But I wonder how to do this.
Here is the oneliner:
tell application "System Events" to tell appearance preferences to set dark mode to not dark mode
Here is how I tried to accomplish it:
tell application "System Events" to
tell appearance preferences to
set dark mode to not dark mode
end tell
end tell
Apperently this won't work.
What am I missing?
applescript
add a comment |
up vote
1
down vote
favorite
I have an AppleScript oneliner that I would like to indent. But I wonder how to do this.
Here is the oneliner:
tell application "System Events" to tell appearance preferences to set dark mode to not dark mode
Here is how I tried to accomplish it:
tell application "System Events" to
tell appearance preferences to
set dark mode to not dark mode
end tell
end tell
Apperently this won't work.
What am I missing?
applescript
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have an AppleScript oneliner that I would like to indent. But I wonder how to do this.
Here is the oneliner:
tell application "System Events" to tell appearance preferences to set dark mode to not dark mode
Here is how I tried to accomplish it:
tell application "System Events" to
tell appearance preferences to
set dark mode to not dark mode
end tell
end tell
Apperently this won't work.
What am I missing?
applescript
I have an AppleScript oneliner that I would like to indent. But I wonder how to do this.
Here is the oneliner:
tell application "System Events" to tell appearance preferences to set dark mode to not dark mode
Here is how I tried to accomplish it:
tell application "System Events" to
tell appearance preferences to
set dark mode to not dark mode
end tell
end tell
Apperently this won't work.
What am I missing?
applescript
applescript
asked Nov 8 at 14:18
Ugur
413415
413415
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
If you wish to keep your command as a "one-liner", but divide it over more than one line, then you need to make use of a line continuation character, which, in AppleScript, is denoted by ¬. This can be entered in Script Editor either by pressing ⌥Enter, or by pressing ⌥L.
Then you can split your one-liner like so:
tell application "System Events" to ¬
tell appearance preferences to ¬
set dark mode to not dark mode
You can experiment with placing the line continuation character in different positions to achieve different types of indentation, e.g.:
tell application "System Events" to tell ¬
appearance preferences to set ¬
dark mode to not dark mode
If you want to change your one-liner (referred to as a simple tell command) to what is called a compound tell command—one that ends with end tell—then you should omit the to after each tell you wish to compound:
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
Wow, excellent answer. Thanks a lot!
– Ugur
Nov 8 at 14:36
You're welcome. Thanks for the quick accept.
– CJK
Nov 8 at 14:36
2
I've always used ⌥L and didn't know about ⌥Enter, nice answer! +1
– user3439894
Nov 8 at 15:08
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
If you wish to keep your command as a "one-liner", but divide it over more than one line, then you need to make use of a line continuation character, which, in AppleScript, is denoted by ¬. This can be entered in Script Editor either by pressing ⌥Enter, or by pressing ⌥L.
Then you can split your one-liner like so:
tell application "System Events" to ¬
tell appearance preferences to ¬
set dark mode to not dark mode
You can experiment with placing the line continuation character in different positions to achieve different types of indentation, e.g.:
tell application "System Events" to tell ¬
appearance preferences to set ¬
dark mode to not dark mode
If you want to change your one-liner (referred to as a simple tell command) to what is called a compound tell command—one that ends with end tell—then you should omit the to after each tell you wish to compound:
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
Wow, excellent answer. Thanks a lot!
– Ugur
Nov 8 at 14:36
You're welcome. Thanks for the quick accept.
– CJK
Nov 8 at 14:36
2
I've always used ⌥L and didn't know about ⌥Enter, nice answer! +1
– user3439894
Nov 8 at 15:08
add a comment |
up vote
3
down vote
accepted
If you wish to keep your command as a "one-liner", but divide it over more than one line, then you need to make use of a line continuation character, which, in AppleScript, is denoted by ¬. This can be entered in Script Editor either by pressing ⌥Enter, or by pressing ⌥L.
Then you can split your one-liner like so:
tell application "System Events" to ¬
tell appearance preferences to ¬
set dark mode to not dark mode
You can experiment with placing the line continuation character in different positions to achieve different types of indentation, e.g.:
tell application "System Events" to tell ¬
appearance preferences to set ¬
dark mode to not dark mode
If you want to change your one-liner (referred to as a simple tell command) to what is called a compound tell command—one that ends with end tell—then you should omit the to after each tell you wish to compound:
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
Wow, excellent answer. Thanks a lot!
– Ugur
Nov 8 at 14:36
You're welcome. Thanks for the quick accept.
– CJK
Nov 8 at 14:36
2
I've always used ⌥L and didn't know about ⌥Enter, nice answer! +1
– user3439894
Nov 8 at 15:08
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
If you wish to keep your command as a "one-liner", but divide it over more than one line, then you need to make use of a line continuation character, which, in AppleScript, is denoted by ¬. This can be entered in Script Editor either by pressing ⌥Enter, or by pressing ⌥L.
Then you can split your one-liner like so:
tell application "System Events" to ¬
tell appearance preferences to ¬
set dark mode to not dark mode
You can experiment with placing the line continuation character in different positions to achieve different types of indentation, e.g.:
tell application "System Events" to tell ¬
appearance preferences to set ¬
dark mode to not dark mode
If you want to change your one-liner (referred to as a simple tell command) to what is called a compound tell command—one that ends with end tell—then you should omit the to after each tell you wish to compound:
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
If you wish to keep your command as a "one-liner", but divide it over more than one line, then you need to make use of a line continuation character, which, in AppleScript, is denoted by ¬. This can be entered in Script Editor either by pressing ⌥Enter, or by pressing ⌥L.
Then you can split your one-liner like so:
tell application "System Events" to ¬
tell appearance preferences to ¬
set dark mode to not dark mode
You can experiment with placing the line continuation character in different positions to achieve different types of indentation, e.g.:
tell application "System Events" to tell ¬
appearance preferences to set ¬
dark mode to not dark mode
If you want to change your one-liner (referred to as a simple tell command) to what is called a compound tell command—one that ends with end tell—then you should omit the to after each tell you wish to compound:
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
answered Nov 8 at 14:28
CJK
2,3221114
2,3221114
Wow, excellent answer. Thanks a lot!
– Ugur
Nov 8 at 14:36
You're welcome. Thanks for the quick accept.
– CJK
Nov 8 at 14:36
2
I've always used ⌥L and didn't know about ⌥Enter, nice answer! +1
– user3439894
Nov 8 at 15:08
add a comment |
Wow, excellent answer. Thanks a lot!
– Ugur
Nov 8 at 14:36
You're welcome. Thanks for the quick accept.
– CJK
Nov 8 at 14:36
2
I've always used ⌥L and didn't know about ⌥Enter, nice answer! +1
– user3439894
Nov 8 at 15:08
Wow, excellent answer. Thanks a lot!
– Ugur
Nov 8 at 14:36
Wow, excellent answer. Thanks a lot!
– Ugur
Nov 8 at 14:36
You're welcome. Thanks for the quick accept.
– CJK
Nov 8 at 14:36
You're welcome. Thanks for the quick accept.
– CJK
Nov 8 at 14:36
2
2
I've always used ⌥L and didn't know about ⌥Enter, nice answer! +1
– user3439894
Nov 8 at 15:08
I've always used ⌥L and didn't know about ⌥Enter, nice answer! +1
– user3439894
Nov 8 at 15:08
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209612%2fhow-to-indent-applescript-oneliner%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password