Skip to content

Instantly share code, notes, and snippets.

@porqz
Last active February 13, 2020 12:10
Show Gist options
  • Save porqz/8153736 to your computer and use it in GitHub Desktop.
Save porqz/8153736 to your computer and use it in GitHub Desktop.
Some useful shell commands (including macOS specialized)
# Current weather and forecast
curl http://wttr.in/
# ASCII Star Wars
nc towel.blinkenlights.nl 23
# or
telnet towel.blinkenlights.nl
# Turn off Mac’s startup sound
sudo nvram SystemAudioVolume=%80
# Create DMG
hdiutil create -srcfolder ./Source\ Directory -fs HFS+ -volname "Some DMG" ./Destinating\ Image\ File.dmg -ov
# Recursively find and remove all SCSS files in current directory
find . -name "*.scss" -exec rm -f {} \;
# Hide directory
chflags hidden /path/to/directory
# Show directory
chflags nohidden /path/to/directory
# Create file with size
mkfile 1g foo.bar
# Download some file with curl
curl -O https://get.videolan.org/vlc/3.0.3/macosx/vlc-3.0.3.dmg
# Defaults
## Disallow HelpViewer window be always on the top of other windows
defaults write com.apple.helpviewer DevMode -bool true
## Switch to the single application mode
defaults write com.apple.dock single-app -bool true; killall Dock
## Make widgets unpinned from Dashboard — just drag a widget (you should relogin after running the command)
defaults write com.apple.dashboard devmode YES
## Make Quick Look preview window text selectable
defaults write com.apple.finder QLEnableTextSelection -bool TRUE; killall Finder
## Show hidden files in Finder
defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder
## Do not sleep when press power button
defaults write com.apple.loginwindow PowerButtonSleepsSystem -bool no
## Disable shadows of screenshots
defaults write com.apple.screencapture disable-shadow -bool TRUE && killall SystemUIServer
## Enable shadows of screenshots
defaults write com.apple.screencapture disable-shadow -bool FALSE && killall SystemUIServer
## Change default screenshots directory
defaults write com.apple.screencapture location /path/to/directory && killall SystemUIServer
## Change dock show/hide animation duration (in seconds)
defaults write com.apple.dock autohide-time-modifier -float 0.5 && killall Dock
## Add note to login screen
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Your message here"
## Remove note from login screen
sudo defaults delete /Library/Preferences/com.apple.loginwindow
## Force enable AptX codec using via bluetooth
sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
## Enable sound when connects a power
defaults write com.apple.PowerChime ChimeOnAllHardware -bool TRUE; open /System/Library/CoreServices/PowerChime.app &
## Disable sound when connects a power
defaults write com.apple.PowerChime ChimeOnAllHardware -bool FALSE; killall PowerChime
# Git:
## Edit last commit
git commit --amend
## Show some lost (by user) files
git show $(git fsck --no-reflog | awk '/dangling commit/ {print $3}')
# FFMPEG
## Converts MP4-video to GIF (common palette)
ffmpeg -i in.mp4 -filter_complex "[0:v] fps=12,split [a][b];[a] palettegen [p];[b][p] paletteuse" out.gif
## Converts MP4-video to GIF (individual palette for each frame)
ffmpeg -i in.mp4 -filter_complex "[0:v] fps=12,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" out.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment