My last post was about manually creating and organizing commands in Apple Remote Desktop with the help of Xcode to edit a plist file.
This post is about using Ruby to do the heavy and ugly lifting of editing the nested UnixCommandTask.plist file. If you’ve ever saved a command the file exist. If it’s not there, click on the “Unix” tab in ARD and save a test command so the file is automatically created. You can find the file at:
~/Library/Containers/com.apple.RemoteDesktop/Data/Library/Application Support/Remote Desktop/Presets/UnixCommandTask.plist
There’s a couple of scripts on my github that help to make the process easier and I hope to cover the overview and basic usage here.
ARDplist.rb is the main file that contains the class and methods, and ARDplist_usage.rb contains examples. You can uncomment commands in “ARDplist_usage.rb” and run them, or create another file for your commands and require ARDplist, see the ReadMe file.
Create A New Folder And Command:
Creating a new foler or command is the most tedious part. There’s a syntax that has to be followed.
Example Code:
#sets a folder named "Admin Commands", with a command named "list of users"
newcommand = ARD::Command.new(
"Admin Commands",#folder name
"list of users", #command name
true, #see output in ARD after command runs
"ls -1 /Users/",#command to run
"root", # user to run command as
1) #select user to run command as radio button, must be set to 1 if you want to run as another user
#executes the above information to actually create the folder and command
ARD.create_command(newcommand)
This creates the example below:
If you want to add a command to that folder, run the code again but make sure the folder name is the same.
This isn’t too bad if you’re creating a simple command like “ls” but gets a little unsightly if you want to add 6 lines of code. So for the folder and command creation part, I also made a little app with Pashua to give the user a gui. The example code below will make the exact same folder and command as the code example above. The advantage here is you can just paste your code into the “script” field as is, line breaks and all.

Listing Options:
Once you have folders and commands you can manage and organize them with by using the “ARDplist.rb” file. Just require it in your ruby file and use the command below to see options.
#if ARDplist.rb was in the same directory as your file
#otherwise change the path after require to where ARDplist is
require './ARDplist'
#list of options for use
puts ARD.options
The output will look like this:
- create_command
- create_folder
- create_spacer
- delete_command
- delete_folder
- folder_index
- list_folders
- move_folder
- options
- rename_command
- rename_folder
Moving, Renaming, and Deleting:
I’ll cover some quick and basic examples of the options above.
list_folders:
If this is your commands, you can run “ARD.list_folders” to return existing folders and single commands. Beware that the first 4 folders are Apples and do not report back.

puts ARD.list_folders
#output is a list of folders or single commands that exist
ls
folder1
folder2
folder_index:
Tells you what physical position a folder is in, remember that the first 4 folders don’t count. From the screenshot above, you can see that “folder1” is in the second spot, which in programming language is 1, since counting starts at 0.
puts ARD.folder_index("folder1")
#output below
1
move_folder:
If you want to move “folder1” to position 0

#move position of existing folder. arguments are (original_position, new_position)
ARD.move_folder(1, 0)
create_spacer:
Create a visual line break to separate commands.

#creates a visual space by using ---------------
#argument is the physical location you want the spacer
ARD.create_spacer(1)
rename_folder:
If you want to rename a folder .. example change “folder1” to “folder0”

#rename an existing folder. arguments are (oldname, newname)
ARD.rename_folder("folder1", "folder0")
rename_command:
Rename a command inside a folder. Example, change “command1” to “command2”

Before

After
#Rename a command, arguments are ("folder_name", "orignialcommandname", "newcommandname")
ARD.rename_command("folder1", "command1", "command2")
delete_command:
To delete a command inside a folder.

#Delete a command, arguments ("folder_name", "command_name")
ARD.delete_command("folder1", "command2")
delete_folder:
To delete an entire folder. This is the same as using the build in “Edit Templates List” and removing a command in ARD.

#delete an existing folder, arguments are ("foldername")
ARD.delete_folder("folder1")