Last active
January 19, 2017 19:47
-
-
Save jechol/2c4f6a4e8e58d4f6cd63c2a06e10df87 to your computer and use it in GitHub Desktop.
Commands useful for iOS dev.
This file contains hidden or 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
function sr | |
find . -regex '.*\.(swift|storyboard|xib|h|m)' -not -path './Pods/*' | xargs ag -0 -l $argv[1] | xargs perl -i.sr_bak -pe "s/$argv[1]/$argv[2]/g" | |
find . -regex '.*\.sr_bak' | xargs rm | |
end | |
function unowned | |
for func in observeNext flatMapLatest | |
sr "\.($func) \{ ([ (:),\w->]+) in" '.$1 { [unowned self] $2 in' | |
sr "\.($func) \{\n" '.$1 { [unowned self] in\n' | |
end | |
echo """ | |
This script only wor for observeNext and flatMapLatest. | |
You should check UIView.animate, etc youself. | |
""" | |
end | |
function weak-iboutlet | |
sr '\@IBOutlet(fileprivate|private|weak|var| )+' '\@IBOutlet weak var ' | |
sr '\@IBOutlet weak var (\w+: \[\w+\]!)' '\@IBOutlet var $1' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment