Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@innocarpe
Last active April 18, 2022 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save innocarpe/283f40ccc30ea28041ebd64a01bdf6de to your computer and use it in GitHub Desktop.
Save innocarpe/283f40ccc30ea28041ebd64a01bdf6de to your computer and use it in GitHub Desktop.
.zshrc (Public Purpose)
...
# Open a scheme on the iOS Simulator
# Usage:
# $ deeplink "URL"
# $ deeplink "DEVICE" "URL"
function deeplink() {
if [ $2 ]; then
local device=$1
local url=$2
xcrun simctl openurl $device $url
else
local url=$1
xcrun simctl openurl booted $url
fi
}
# This is for iOS Developer
# Remove 'DerivedData' contents
function rdd() {
bash -c "rm -rf ~/Library/Developer/Xcode/DerivedData/* >/dev/null"
}
# Opens a new finder tab
# Usage:
# finder # open $PWD
# finder . # open .
# finder $HOME # open $HOME
function finder() {
osascript -e "
set dirname to \"$1\"
if count of dirname is 0 then set dirname to \"$PWD\"
tell application \"Finder\" to activate
tell application \"System Events\"
tell process \"Finder\" to keystroke \"n\" using command down
end tell
tell application \"Finder\"
set target of front window to POSIX file dirname as alias
end tell
" &> /dev/null
}
# Convert a video to gif
# Usage:
# gif blahblah.mov
# original: https://gist.github.com/SlexAxton/4989674
# 'ffmpeg', 'imagemagick' is needed to use this.
gif() {
if [[ -n "$1" ]]; then
rm -r $1.gif.out
mkdir $1.gif.out
ffmpeg -i $1 -r 30 -vcodec png $1.gif.out/out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> $1.gif.out/out-static*.png GIF:- | gifsicle --colors 256 --loop --optimize=3 --delay 3 --multifile - > $1.gif
rm -r $1.gif.out
else
echo "proper usage: gif <input_movie.mov>. You DO need to include extension."
fi
}
# Combine several images to one
# Use this when I need to attach screenshots to Github PR
# Usage:
# $ conv a~c -> a1.png + a2.png + a3.png = output-a.png (with border)
# $ conv e~z -> e1.png + e2.png + e3.png = output-e.png (without border)
function conv() {
if [ "$#" -ne 1 ]; then
echo "Usage: "$0" <a~z>"
else
if [[ "$1" < "d" ]]; then
convert +append $1[1-3].png -bordercolor "#dedede" -border 1 output-$1.png
else
convert +append $1[1-3].png output-$1.png
fi
fi
}
@hakburi
Copy link

hakburi commented Jan 14, 2021

@innocarpe 우왕 너무 너무 편합니다!!! 감사히 잘쓰겠습니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment