Permalink
Browse files

init

  • Loading branch information...
reflog committed Jan 10, 2012
0 parents commit 1bc7b36878950413bd12dbbc9831a156cec2cb11
Showing with 51 additions and 0 deletions.
  1. +3 −0 Context.sublime-menu
  2. +22 −0 README.md
  3. +3 −0 Side Bar.sublime-menu
  4. +3 −0 Tab Context.sublime-menu
  5. +1 −0 package-metadata.json
  6. +19 −0 toggle_readonly.py
  7. BIN toggle_readonly.pyc
@@ -0,0 +1,3 @@
+[
+ { "command": "toggle_readonly", "caption": "Toggle Readonly", "id": "end" }
+]
@@ -0,0 +1,22 @@
+#Toggle file's read-only flag in Sublime Text 2
+
+Basic plugin for [Sublime Text 2][1] that adds a "Toggle Readonly" command to the
+context menu.
+
+##Install
+
+If your using the [Sublime Package Manger][2] hold down Ctrl+shift+p and type
+`Package Control: Install Package`. Then search for `toggle-readonly` and hit return.
+
+If your not using the package manager then `cd` into your Sublime packages directory. (On Linux this is ~/Sublime Text 2/Packages) Then run this command `git clone https://github.com/reflog/toggle-readonly`.
+
+Or you can download the package as zip file [][3] then copy it into your Sublime packages directory.
+
+##Usage
+
+To use the command right click on the file in the side bar or in the buffer area.
+
+
+ [1]: http://www.sublimetext.com/2
+ [2]: http://wbond.net/sublime_packages/package_control
+ [3]: https:///tip.zip
@@ -0,0 +1,3 @@
+[
+ { "command": "toggle_readonly", "caption": "Toggle Readonly" }
+]
@@ -0,0 +1,3 @@
+[
+ { "command": "toggle_readonly", "caption": "Toggle Readonly", "id": "end" }
+]
@@ -0,0 +1 @@
+{"url": "http://github.com/reflog/toggle-readonly/", "version": "1.0", "description": "Toggle file's readonly state from context menu."}
@@ -0,0 +1,19 @@
+import sublime, sublime_plugin, os, stat
+
+class ToggleReadonlyCommand(sublime_plugin.TextCommand):
+ def run(self, edit):
+ myFile = self.view.file_name()
+ fileAtt = os.stat(myFile)[0]
+ myPlatform = os.name
+
+ if (myPlatform == 'nt'):
+ if (not fileAtt & stat.S_IWRITE):
+ sublime.status_message("Making "+myFile+" writable")
+ os.chmod(myFile, stat.S_IWRITE)
+ else:
+ if (fileAtt & stat.UF_IMMUTABLE):
+ sublime.status_message("Making "+myFile+" mutable")
+ os.chflags(myFile, not stat.UF_IMMUTABLE)
+
+ def is_enabled(self):
+ return self.view.file_name() and len(self.view.file_name()) > 0
Binary file not shown.

0 comments on commit 1bc7b36

Please sign in to comment.