Last active
September 14, 2023 14:28
-
-
Save ttscoff/38b1f32a685e308b83e5 to your computer and use it in GitHub Desktop.
Create a new Sublime Text workspace with 4 vertical columns and starter note buffers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# new_podcast.rb | |
# Create a new Sublime Text workspace with 4 vertical columns and starter note buffers | |
# Brett Terpstra 2014 | |
# Free to use and modify (WTF license) | |
# Usage: new_podcast.rb episode_title | |
require 'fileutils' | |
# By default new workspaces are created in subdirs off the current directory | |
# modify project_root to always have them built in a specific location, (e.g. project_root = "~/Dropbox/Podcasts") | |
project_root = "." | |
if ARGV.length != 1 | |
puts "Usage: #{File.basename(__FILE__)} episode_title" | |
Process.exit 1 | |
end | |
title = ARGV[0] | |
workspace =<<EOW | |
{ | |
"buffers": | |
[ | |
{ | |
"contents": "1. Future Topics\\n-------------\\n\\n- ", | |
"settings": | |
{ | |
"buffer_size": 44, | |
"line_ending": "Unix" | |
} | |
}, | |
{ | |
"contents": "2. Current Topics\\n--------------\\n\\n- ", | |
"settings": | |
{ | |
"buffer_size": 33, | |
"line_ending": "Unix" | |
} | |
}, | |
{ | |
"contents": "3. Links\\n-----\\n\\n- ", | |
"settings": | |
{ | |
"buffer_size": 15, | |
"line_ending": "Unix" | |
} | |
}, | |
{ | |
"contents": "4. Scratchpad\\n----------\\n\\n- ", | |
"settings": | |
{ | |
"buffer_size": 25, | |
"line_ending": "Unix" | |
} | |
} | |
], | |
"groups": | |
[ | |
{ | |
"selected": 0, | |
"sheets": | |
[ | |
{ | |
"buffer": 0, | |
"semi_transient": false, | |
"settings": | |
{ | |
"buffer_size": 44, | |
"regions": | |
{ | |
"bookmarks": | |
{ | |
"flags": 144, | |
"icon": "bookmark", | |
"regions": | |
[ | |
[ | |
44, | |
44 | |
] | |
], | |
"scope": "bookmarks" | |
}, | |
"mark": | |
{ | |
"flags": 144, | |
"icon": "dot", | |
"regions": | |
[ | |
[ | |
44, | |
44 | |
] | |
], | |
"scope": "mark" | |
} | |
}, | |
"selection": | |
[ | |
[ | |
44, | |
44 | |
] | |
], | |
"settings": | |
{ | |
"auto_complete_triggers": | |
[ | |
{ | |
"characters": "<", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
} | |
], | |
"function_name_status_row": 5, | |
"is_xml": false, | |
"syntax": "Packages/MarkdownEditing/Markdown.tmLanguage" | |
}, | |
"translation.x": 0.0, | |
"translation.y": 0.0, | |
"zoom_level": 1.0 | |
}, | |
"stack_index": 3, | |
"type": "text" | |
} | |
] | |
}, | |
{ | |
"selected": 0, | |
"sheets": | |
[ | |
{ | |
"buffer": 1, | |
"semi_transient": false, | |
"settings": | |
{ | |
"buffer_size": 33, | |
"regions": | |
{ | |
}, | |
"selection": | |
[ | |
[ | |
33, | |
33 | |
] | |
], | |
"settings": | |
{ | |
"auto_complete_triggers": | |
[ | |
{ | |
"characters": "<", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
} | |
], | |
"function_name_status_row": 3, | |
"is_xml": false, | |
"syntax": "Packages/MarkdownEditing/Markdown.tmLanguage" | |
}, | |
"translation.x": 0.0, | |
"translation.y": 0.0, | |
"zoom_level": 1.0 | |
}, | |
"stack_index": 1, | |
"type": "text" | |
} | |
] | |
}, | |
{ | |
"selected": 0, | |
"sheets": | |
[ | |
{ | |
"buffer": 2, | |
"semi_transient": false, | |
"settings": | |
{ | |
"buffer_size": 15, | |
"regions": | |
{ | |
}, | |
"selection": | |
[ | |
[ | |
15, | |
15 | |
] | |
], | |
"settings": | |
{ | |
"auto_complete_triggers": | |
[ | |
{ | |
"characters": "<", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
} | |
], | |
"function_name_status_row": 3, | |
"is_xml": false, | |
"syntax": "Packages/MarkdownEditing/Markdown.tmLanguage" | |
}, | |
"translation.x": 0.0, | |
"translation.y": 0.0, | |
"zoom_level": 1.0 | |
}, | |
"stack_index": 2, | |
"type": "text" | |
} | |
] | |
}, | |
{ | |
"selected": 0, | |
"sheets": | |
[ | |
{ | |
"buffer": 3, | |
"semi_transient": false, | |
"settings": | |
{ | |
"buffer_size": 25, | |
"regions": | |
{ | |
}, | |
"selection": | |
[ | |
[ | |
25, | |
25 | |
] | |
], | |
"settings": | |
{ | |
"auto_complete_triggers": | |
[ | |
{ | |
"characters": "<", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
}, | |
{ | |
"characters": ".#", | |
"selector": "text.html" | |
} | |
], | |
"function_name_status_row": 3, | |
"is_xml": false, | |
"syntax": "Packages/MarkdownEditing/Markdown.tmLanguage" | |
}, | |
"translation.x": 0.0, | |
"translation.y": 0.0, | |
"zoom_level": 1.0 | |
}, | |
"stack_index": 0, | |
"type": "text" | |
} | |
] | |
} | |
], | |
"layout": | |
{ | |
"cells": | |
[ | |
[ | |
0, | |
0, | |
1, | |
1 | |
], | |
[ | |
1, | |
0, | |
2, | |
1 | |
], | |
[ | |
2, | |
0, | |
3, | |
1 | |
], | |
[ | |
3, | |
0, | |
4, | |
1 | |
] | |
], | |
"cols": | |
[ | |
0.0, | |
0.25, | |
0.5, | |
0.75, | |
1.0 | |
], | |
"rows": | |
[ | |
0.0, | |
1.0 | |
] | |
}, | |
"menu_visible": true, | |
"project": "#{title}.sublime-project", | |
"settings": | |
{ | |
}, | |
"show_minimap": false, | |
"show_open_files": false, | |
"show_tabs": false, | |
"side_bar_visible": false, | |
"side_bar_width": 218.0, | |
"status_bar_visible": false, | |
"template_settings": | |
{ | |
} | |
} | |
EOW | |
project =<<EOP | |
{ | |
} | |
EOP | |
project_folder = File.join(File.expand_path(project_root), title) | |
FileUtils.mkdir_p(project_folder) | |
File.open(File.join(project_folder, title + ".sublime-workspace"), 'w') do |f| | |
f.puts workspace | |
end | |
File.open(File.join(project_folder, title + ".sublime-project"), 'w') do |f| | |
f.puts project | |
end | |
puts "New project created at #{project_folder}" | |
%x{subl "#{File.join(project_folder, title + ".sublime-workspace")}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment