{"action":"created","issue":{"url":"https://api.github.com/repos/chrisallenlane/cheat/issues/207","labels_url":"https://api.github.com/repos/chrisallenlane/cheat/issues/207/labels{/name}","comments_url":"https://api.github.com/repos/chrisallenlane/cheat/issues/207/comments","events_url":"https://api.github.com/repos/chrisallenlane/cheat/issues/207/events","html_url":"https://github.com/chrisallenlane/cheat/issues/207","id":56336851,"number":207,"title":"Newly copied cheats lack write permissions","user":{"login":"renfredxh","id":3800339,"avatar_url":"https://avatars.githubusercontent.com/u/3800339?v=3","gravatar_id":"","url":"https://api.github.com/users/renfredxh","html_url":"https://github.com/renfredxh","followers_url":"https://api.github.com/users/renfredxh/followers","following_url":"https://api.github.com/users/renfredxh/following{/other_user}","gists_url":"https://api.github.com/users/renfredxh/gists{/gist_id}","starred_url":"https://api.github.com/users/renfredxh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renfredxh/subscriptions","organizations_url":"https://api.github.com/users/renfredxh/orgs","repos_url":"https://api.github.com/users/renfredxh/repos","events_url":"https://api.github.com/users/renfredxh/events{/privacy}","received_events_url":"https://api.github.com/users/renfredxh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-03T05:53:02Z","updated_at":"2015-02-11T00:48:54Z","closed_at":"2015-02-11T00:37:06Z","body":"So I started using cheat on my new system (OSX 10.10) and wanted to edit an existing cheat using `-e` but ran into an issue. Seems like when cheats are copied the `DEFAULT_CHEAT_DIR` the permissions remain read-only, so changes can't be saved. And when trying to edit them again cheat checks to see if the new file `is_writeable` which returns false so it tries to copy that file again but throws an error since the new cheat file already exists. \r\n\r\nStrangely this didn't happen when I was using cheat on linux so I'm not sure if it's something different with my setup or what, but either way maybe adding a quick call to `os.chmod` in `create_or_edit` after copying a new cheat to add write permissions would help. \r\n\r\nHere's an example of what I'm talking about:\r\n```console\r\n00:23:22-renfred@wartortle~$ ls -l ~/.dotfiles/link/.cheat\r\ntotal 24\r\n-rw-r--r--  1 renfred  staff   132 Jan 28 11:19 grails\r\n-rw-r--r--  1 renfred  staff   598 Feb  3 00:15 mysql\r\n-rw-r--r--  1 renfred  staff  1700 Feb  3 00:15 vim\r\n00:23:31-renfred@wartortle~$ cheat -e git\r\nThe git sheet is not editable. Do you want to copy it to your user cheatsheets directory before editing? Keep in mind that your sheet will always be used before system-wide one.\r\n[y/n] y\r\n# Editor opens up here in read-only mode\r\n00:23:50-renfred@wartortle~$ ls -l ~/.dotfiles/link/.cheat\r\ntotal 32\r\n-r--r--r--  1 renfred  staff  1909 Feb  3 00:23 git\r\n-rw-r--r--  1 renfred  staff   132 Jan 28 11:19 grails\r\n-rw-r--r--  1 renfred  staff   598 Feb  3 00:15 mysql\r\n-rw-r--r--  1 renfred  staff  1700 Feb  3 00:15 vim\r\n00:23:54-renfred@wartortle~$ cheat -e git\r\nThe git sheet is not editable. Do you want to copy it to your user cheatsheets directory before editing? Keep in mind that your sheet will always be used before system-wide one.\r\n[y/n] y\r\n# Editor opens up again, read-only mode\r\nTraceback (most recent call last):\r\n  File \"/usr/local/Cellar/cheat/2.1.3/libexec/bin/cheat\", line 53, in <module>\r\n    sheet.create_or_edit(options['<cheatsheet>'])\r\n  File \"/usr/local/Cellar/cheat/2.1.3/lib/python2.7/site-packages/cheat/sheet.py\", line 44, in create_or_edit\r\n    copy(path(sheet), os.path.join(sheets.default_path(), sheet))\r\n  File \"/usr/local/Cellar/cheat/2.1.3/lib/python2.7/site-packages/cheat/sheet.py\", line 14, in copy\r\n    shutil.copy(current_sheet_path, new_sheet_path)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py\", line 119, in copy\r\n    copyfile(src, dst)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py\", line 69, in copyfile\r\n    raise Error(\"`%s` and `%s` are the same file\" % (src, dst))\r\nshutil.Error: `/Users/renfred/.cheat/git` and `/Users/renfred/.cheat/git` are the same file\r\n00:24:03-renfred@wartortle~$ chmod +w ~/.dotfiles/link/.cheat/git\r\n00:24:23-renfred@wartortle~$ cheat -e git\r\n# Editor opens here and cheat can be edited normally\r\n```"},"comment":{"url":"https://api.github.com/repos/chrisallenlane/cheat/issues/comments/73816173","html_url":"https://github.com/chrisallenlane/cheat/issues/207#issuecomment-73816173","issue_url":"https://api.github.com/repos/chrisallenlane/cheat/issues/207","id":73816173,"user":{"login":"chrisallenlane","id":623723,"avatar_url":"https://avatars.githubusercontent.com/u/623723?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisallenlane","html_url":"https://github.com/chrisallenlane","followers_url":"https://api.github.com/users/chrisallenlane/followers","following_url":"https://api.github.com/users/chrisallenlane/following{/other_user}","gists_url":"https://api.github.com/users/chrisallenlane/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisallenlane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisallenlane/subscriptions","organizations_url":"https://api.github.com/users/chrisallenlane/orgs","repos_url":"https://api.github.com/users/chrisallenlane/repos","events_url":"https://api.github.com/users/chrisallenlane/events{/privacy}","received_events_url":"https://api.github.com/users/chrisallenlane/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T00:48:54Z","updated_at":"2015-02-11T00:48:54Z","body":"@renfredxh, thanks very much for the ticket. This issue should now be resolved in cheat version `2.1.5` :)"}}