git clone <a href="git://github.com/AndyA/htop-osx.git" >git://github.com/AndyA/htop-osx.git</a> cd htop git checkout -b osx origin/osx ./autogen.sh ./configure make sudo make install
Tag Archive for osx
Install htop on OSX Leopard
Terminal – Turn On or Off Hidden Files
#Turn On Hidden Files in Terminal - - - - - defaults write com.apple.finder AppleShowAllFiles -bool true #Turn Off Hidden Files in Terminal - - - - - defaults write com.apple.finder AppleShowAllFiles -bool false
OSX – enable disable spotlight indexing
// disable spotlight indexing sudo mdutil -i off // enable spotlight indexing sudo mdutil -i on // delete existing spotlight indexes sudo mdutil -E // some other options: -s = display status, -v = verbose
Open a manpage in Preview.app
# Open a manpage in Preview, which can be saved to PDF
pman()
{
man -t "${1}" | open -f -a /Applications/Preview.app
}
Automated Screen-Capture
while [ 1 ]; do /usr/sbin/screencapture -T0 ~/Desktop/screen-`date +%F-%H-%M-%S`.png sleep 15 done
OSX Keyboard Shortcuts
Screen Capture to disk: ⌘ ⇧ 3 Screen to jpeg file on desktop ⌘ ⇧ 4 + Drag: Selection to jpeg file on desktop ⌘ ⇧ 4 + Spacebar: Window (click camera) to jpeg file Screen Capture to clipboard: ⌘ ⇧ 3 + Ctrl: Screen to clipboard ⌘ ⇧ 4 + Drag + Ctrl: Selection to clipboard ⌘ ⇧ 4 + Spacebar + Ctrl Window (Camera effect) Dock /Switch Applications ⌘ ⌥ D Show/Hide Dock ⌘ Tab Switch applications ⌘ ` Switch between document Windows in current application ⌥ Dock Switch application, hide previous one ⌘ Dock Switch application, hide all others Ctrl ⌥ ⌘ * Toggle Monochrome Hi Visibility ⌘ +drag will prevent dock icons from moving out of the way (useful for when dragging stuff to trash) Apple Finder ⌥ + Drag Explicit COPY (will copy even if destation is on same volume) ⌘ + Drag Explicit MOVE (will move even if destation is on different volume) ⌘ ⌥ + Drag Make alias in new location ⌘ D Duplicate ⌘ L Make Alias ⌘ R Show original ⌘ O Open item ⌘ ↓ Open item ⌘ S Save ⌘ ⇧ S Save as ⌘ N New Finder window ⌘ ⇧ N New Folder ⌘ Q Close Application ⌘ W Close Window ⌘ ⌥ W Close all Windows ⌘ I Get Info ⌘ ⌥ I Super Get Info (change whatever you click on) ⌘ P Print ⌘ T Add to Favorites ⌘ Delete Move to Trash ⌘ E Eject ⌘ F Find ⌘ ~ Cycle finder windows (including desktop) Tab Highlight next item ⌘ + double-click folder icon will open in new window ⌘ + ↑ Move up one directory ⌘ + [ go back ⌘ + ] go forward ⌘ ⇧ A Open Applications Folder ⌘ ⇧ U Open Applications/Utilities/ Folder ⌘ ⇧ H Open Home Folder ⌘ ⇧ K Go to network ⌘ K Connect to server ⌘ ⇧ G Go to folder... (type full path) ⌘ ⇧ ⌫ Empty Trash (Finder Menu ) ⌘ ⇧ ⌥ ⌫ Empty Trash without dialog Finder-Hide App: ⌘ H Hide Finder ⌘ ⌥ H Hide Others Hide all other apps*: ⌥ ⌘ + click on dock icon ⌥ ⌘ + click inside app window Hide all other apps that are in front*: ⌥ + click dock icon (of running app) ⌥ + click inside app window *Some older (pre-intel) apps may struggle with these Terminal ⌘ left/right arrow Switch windows ⌘ 1 Switch to 1st terminal window ⌘ 2, ⌘ 3... Switch to 2nd, 3rd window Editing Text (email, TextEdit etc) ⌥ ↠Move one word left ⌥ → Move one word right ⌘ ↠Beginning of line ⌘ → End of line Scroll one page up (cursor retains position) Scroll one page down (cursor retains position) ⌥ Move one page up (reposition cursor) ⌥ Move one page down ⌘ ↑ or Scroll to beginning of document ⌘ ↓ or Scroll to end of document Add shift key ⇧ to the above to also SELECT the text. ⌥ ⌫ Delete word ⌥ Del Delete next word ⌥ Scrollbar Jump to exact scrollbar location ⌥ Scrollbar arrows Scroll page at a time (page up/down) ⌥ Volume up/down Open Sound preferences ⌥ Brightness up/down Open Display preferences Shutdown/Logoff: POWER Sleep now POWER Hold for 10 seconds (force shut down) Ctrl Eject Restart, Sleep, Shutdown dialog box ⌘ Ctrl Eject Quit all applications and restart ⌘ ⌥+ctrl+eject Graceful Shutdown ⌘ ⌥ Eject Sleep now ⌘ ⌥ + Esc Force Quit ⌘ + .(period) Stop a process ⌘ Ctrl+power Immediate restart (dangerous, only if system is frozen) Log out: ⌘ ⇧ Q Log out (Apple Menu) ⌘ ⇧ ⌥ Q Log out immediately (Apple Menu) During Startup: Shift Safe Boot mode - Press shift asap AFTER the startup chime ⌘ V Start up in Verbose mode. ⌘ S Start up in Single-User mode (command line) X Force OS X startup ⌘ ⌥ ⇧ ⌫ Bypass primary startup volume (will seek DVD or external disk) C Start up from a CD that has a system folder D Start up from first partition N Attempt to start up from a network server(NetBoot) R Force PowerBook screen reset T Start up in FireWire Target Disk mode ⌘ ⌥ P R PRAM Reset - Hold down Cmd-Option-R with your left hand, then press POWER to start up and immediately press P with your right hand. See KB 2238 At the prompt you can type: reset-nvram and/or reset-all ⌘ ⌥ O F Open Firmware ⌘ E Eject CD (press during/after startup chime) mouse Eject CD (hold mouse button down during startup)
Flush DNS cache in OS X 10.5.X
dscacheutil -flushcache
Install PHP + GD on Mac OS X Leopard
# Adapted from Sheldons instuctions # <a href="http://macoshelp.blogspot.com/2008/02/adding-gd-library-for-mac-os-x-leopard.html" >http://macoshelp.blogspot.com/2008/02/adding-gd-library-for-mac-os-x-leopard.html</a> # Comment out "LoadModule php5_module libexec/apache2/libphp5.so" # in httpd.conf tp prevent the default PHP installation from loading cd /private/etc/apache2 bbedit httpd.conf # Download and install a compiled version of PHP + GD cd /usr/local sudo curl -O <a href="http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz" >http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz</a> sudo tar -xzf php5-*-beta.tar.gz sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf # optionally remove compressed file rm php5-5.2.5-6-beta.tar.gz # restart Apache sudo apachectl restart
kill build_hd_index
sudo chmod 000 /System/Library/ CoreServices/RemoteManagement/ ARDAgent.app/Contents/Support/build_hd_index
# /…/_/sex2hms == Format seconds into
#!/bin/sh
##############################################################################
# /.../_/sex2hms == Format seconds into "xx week(s) xx day(s) hh:mm:ss" #
#----------------------------------------------------------------------------#
#.........william.o.yates...spamware.at.tru2life.net...tru2life.info.........#
#----------------------------------------------------------------------------#
# and YES, sex2hms coulda, maybe shoulda be called sex2wdhms, but oh well... #
#----------------------------------------------------------------------------#
# original (for bash): <a href="http://codesnippets.joyent.com/tag/bash/3#post1936" >http://codesnippets.joyent.com/tag/bash/3#post1936</a> #
# #
# #!/bin/sh #
# #Convert seconds to h:m:s format #
# #
# [ -z ${1} ] && echo "Usage: $(basename $0) <seconds>" && exit||secs=${1} #
# _hms() #
# { #
# local S=${1} #
# ((h=S/3600)) #
# ((m=S%3600/60)) #
# ((s=S%60)) #
# printf "%dh:%dm:%ds
" $h $m $s #
# } #
# #
# _hms ${secs} #
# #
#----------------------------------------------------------------------------#
# #
# 1 second = 1 second = "S=$(expr ( ${SEX} % 60 ))" #
# 60 seconds = 1 minute = "M=$(expr ( ${SEX} % 3600 / 60 ))" #
# 3,600 seconds = 1 hour = "H=$(expr ( ${SEX} % 86400 / 3600 ))" #
# 86,400 seconds = 1 day = "D=$(expr ( ${SEX} % 604800 / 86400 ))" #
# 604,800 seconds = 1 week = "W=$(expr ( ${SEX} / 604800 ))" #
# #
# Following are beyond scope of this script, but jus4giggles... #
# #
# 2,419,200 seconds = 1 month28 = "[ ${SEX} -gt 2419200 ] && calc_month"... #
# 2,505,600 seconds = 1 month29 = "[ ${SEX} -gt 2505600 ] && calc_month"... #
# 2,592,000 seconds = 1 month30 = "[ ${SEX} -gt 2592000 ] && calc_month"... #
# 2,678,400 seconds = 1 month31 = "[ ${SEX} -gt 2678400 ] && calc_month"... #
# 31,536,000 seconds = 1 year365 = "[ ${SEX} -gt 31536000 ] && calc_year"... #
# 31,622,400 seconds = 1 year366 = "[ ${SEX} -gt 31622400 ] && calc_year"... #
# #
#----------------------------------------------------------------------------#
# #
# a heavy duty hand calculation for what correct answers should be: #
# #
# 999,999 / 604,800 = 1.6534375 == ( W=1 ) #
# #
# 1 * 604,800 = 604,800 == ( 1 week in seconds )(doh... <img src='http://www.snippetsmania.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> #
# #
# 999,999 - 604,800 = 395,199 == ( SEX - 1W ) #
# #
# 395,199 / 86,400 = 4.5740625 == ( D=4 ) #
# #
# 4 * 86,400 = 345,600 == ( 4 days in seconds ) #
# #
# 395,199 - 345,600 = 49,599 == ( SEX - 1W - 4D ) #
# #
# 49,599 / 3,600 = 13.7775 == ( H=13 ) #
# #
# 13 * 3,600 = 46,800 == ( 13 hours in seconds ) #
# #
# 49,599 - 46,800 = 2,799 == ( SEX - 1W - 4D - 13H ) #
# #
# 2,799 / 60 = 46.65 == ( M=46 ) #
# #
# 46 * 60 = 2,760 == ( SEX - 1W - 4D - 13H - 46M ) #
# #
# 2,799 - 2,760 = 39 == ( S=39 ) #
# #
# So, (finally!) with the following sex2hms runs, the answers are: #
# (with your directory prefixed from where you run it from) #
# #
# /.../_/sex2hms: 9 seconds = 00 week 00 day 00:00:09 #
# /.../_/sex2hms: 99 seconds = 00 week 00 day 00:01:39 #
# /.../_/sex2hms: 999 seconds = 00 week 00 day 00:16:39 #
# /.../_/sex2hms: 9999 seconds = 00 week 00 day 02:46:39 #
# /.../_/sex2hms: 99999 seconds = 00 week 01 day 03:46:39 #
# /.../_/sex2hms: 999999 seconds = 01 week 04 days 13:46:39 #
# /.../_/sex2hms: 9999999 seconds = 16 weeks 03 days 17:46:39 #
# /.../_/sex2hms: 99999999 seconds = 165 weeks 02 days 09:46:39 #
# /.../_/sex2hms: 999999999 seconds = 1653 weeks 03 days 01:46:39 #
#----------------------------------------------------------------------------#
#.........william.o.yates...spamware.at.tru2life.net...tru2life.info.........#
#============================================================================#
#-----------------------------------------------------------------------------
# hms() == convert seconds into hours:minutes:seconds (hh:mm:ss) format
#-----------------------------------------------------------------------------
hms()
{
local SEX=${1};
local HOUR=3600; local DAY=86400; local WEEK=604800;
local DAZE="day"; local WEKZ="week";
W=$(expr ( ${SEX} / ${WEEK} ))
D=$(expr ( ${SEX} % ${WEEK} / ${DAY} ))
H=$(expr ( ${SEX} % ${DAY} / ${HOUR} ))
M=$(expr ( ${SEX} % ${HOUR} / 60 ))
S=$(expr ( ${SEX} % 60 ))
[ ${D} -gt 1 ] && DAZE="days"
[ ${W} -gt 1 ] && WEKZ="weeks"
#===========================================================================
# printf format [arguments ...]
# '%s'=string, '%d'=decimal_number, '%02d'=0_padded_2_digit_decimal_number
# character_escape_sequences: 'v'=vertical_tab, ' '=tab, '
'=newline
#---------------------------------------------------------------------------
#-------------------SEX-----------W--WEKZ--D--DAZE--H----M----S-------------
printf "v ${0}: %d seconds = %02d %s %02d %s %02d:%02d:%02dv
"
${SEX} ${W} ${WEKZ} ${D} ${DAZE} ${H} ${M} ${S}
echo -e "v SEX=${SEX}, W=${W}, WEKZ=${WEKZ}, D=${D}, DAZE=${DAZE},
H=${H}, M=${M}, S=${S} v"
}
#=============================================================================
# [ -z STRING ] == True if the length of STRING is zero.
#-----------------------------------------------------------------------------
[ -z ${1} ]&&echo -e "
Usage: $(basename ${0}) <seconds>
"&&exit||hms ${1}
##############################################################################