January 23rd, 2012
Op mijn netwerk zijn verschillende schijven beschikbaar. Het is vervelend om elke keer als ik mijzelf weer aanmeld op mijn netwerk elke keer opnieuw de schijven te mounten die ik nodig heb. OSX heeft daar een handige oplossing voor: ‘Automounter’.
‘Automounter’ mount de schijf op het moment dat je er naar vraagt. Mijn muziek staat bijvoorbeeld op mijn netwerkschijf /KoekoekMedia en mijn video’s op /KoekoekCinema. Op het moment dat iTunes opstart en opzoek gaat naar die map zal deze map automatisch worden gemount.
Je vind de instellingen in /etc/auto_master. Onderaan dit bestand is te zien dat ik een bestand /etc/auto_afp heb gemaakt voor mijn netwerk schijven.
#
# Automounter master map
#
# edited by b.nelissen
# 09 May 2011
#
# The master map contains a list of directories to be controlled by
# autofs and their associated direct map or indirect maps.
# http://images.apple.com/business/docs/Autofs.pdf
# mountpoint map -options
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
# Koekoek AFP mount
# The first item, ?/-?, is a special mount point that tells autofs to use the mount point specified inside the mount map file (auto_utilities). Since the filename auto_utilities does not start with a forward slash, autofs will look for it in /etc.
# apply changes:
# sudo automount -vc
/auto_afp auto_afp
Het bestand /etc/auto_afp ziet er als volgt uit.
# Airport AFP drives for automount
# password is needed for read/write
# apply changes:
# sudo automount -vc
# Cinema
KoekoekCinema -fstype=afp afp://USER:PASSWORD@192.168.87.87/KoekoekCinema
# Media
KoekoekMedia -fstype=afp afp://USER:PASSWORD@192.168.87.87/KoekoekMedia
Tags: automatisch, mount, netwerk, osx, schijf
Posted in osx, shell / terminal, terminal | Comments Off
January 8th, 2012
Bestanden inpakken gaat makkelijk met de rechtermuisknop. Soms wil je zeker weten dat het archief dat je maakt zo klein mogelijk is en dat elke druppel lucht eruit wordt geperst tijdens het inpakken. Het volgende commando zorgt ervoor dat je zipfile zo klein mogelijk wordt.
-1 is groot maar en het inpakken gaat snel
-9 is klein maar en het inpakken gaat langzaam
zip -v -9 archief.dmg.zip orgineel.dmg
Tags: archief, inpakken, opslag, zip
Posted in osx, shell / terminal, terminal | Comments Off
September 4th, 2011
Je kan, mits ingesteld, de F-toetsen gebruiken om je Mission Control naar voren te halen. Dit zijn enkele applescript snippits.
– All windows F9
tell application “System Events” to key code 101
– Application F10
tell application “System Events” to key code 109
– Desktop F11
tell application “System Events” to key code 103
– Dashboard F12
tell application “System Events” to key code 111
Tags: applescript, dashboard, desktop, mission control, osx, script
Posted in applescript, osx, syntax | Comments Off
June 21st, 2011
Ik wil zonder al te veel moeite mijn netwerkschijven hebben gemount. Autofs zorgt ervoor dat je ‘on-demand’ een schijf kan mounten. Wil je op /Volumes/netwerkschijf zijn, maar is deze niet gemount? Dan mount autofs deze voor jou!
bewerk /etc/auto_master en voeg een regel toe
#
# Automounter master map
#
# edited by b.nelissen
# 09 May 2011
#
# The master map contains a list of directories to be controlled by
# autofs and their associated direct map or indirect maps.
# b.nelissen
# tell auto_mount to check /etc/auto_afp
# /- auto_afp
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
/- -autoafp
Now edit your /etc/auto_afp to mount your LAN disks automatically
# Airport AFP drives for automount
# Cinema
/Volumes/KoekoekCinema -fstype=afp afp://192.168.1.10/KoekoekCinema
# Media
/Volumes/KoekoekMedia -fstype=afp afp://192.168.1.10/KoekoekMedia
# Bas
/Volumes/KoekoekBas -fstype=afp afp://192.168.1.10/KoekoekBas
# ATV
/Volumes/frontrow -fstype=afp afp://username:password@192.168.1.20/frontrow
Het simpele commando
zorgt voor een handmatige start van automount. Veranderde netwerk instellingen doen het zelfde.
Posted in Uncategorized | Comments Off
March 11th, 2011
Ik wil een tekst bestand hebben met daarin de folders en lege bestanden die ik de afgelopen maand heb aangemaakt. Hiervoor kan je spotlight gebruiken, maar je kan ook mdfind gebruiken. mdfind is spotlight in de terminal. Om te weten waar mdfind allemaal naar kijkt kan je mdls gebruiken, mdls geeft een lijst van attributen van het bestand waarop gezocht kan worden.
Dit is mijn mdfind commando:
mdfind -onlyin ~/ '((kMDItemFSCreationDate > $time.this_month)&&(kMDItemFSSize=0))'
Posted in osx, shell / terminal, terminal | Comments Off
March 8th, 2011
Erg vervelend kan het zijn als je bootcamp wilt gebruiken en je niet de ruimte kan krijgen die je wilt. Er zijn verschillende oplossingen voor dit probleem:
- Timemachine backup maken, OSX opnieuw installeren, boot-camp, time-machine herstellen
- iDefrag kan je gebruiken om de schijf te defragmenteren, dit werkt vaak goed. ($30)
- Opstarten met ‘appeltje-s’ ingedrukt (single-user mode) en het volgende commando intoetsen:
/sbin/fsck -y
/sbin/mount -uw /
/sbin/autodiskmount -va
/usr/sbin/diskutil repairPermissions /
reboot
De laatste optie is mijn favoriet, de tweede optie raad ik anderen aan omdat dat de makkelijkste optie is.
Tags: bootcamp, bootkey, defragmenteren, fsk, timemachine, windows
Posted in opslag, osx, shell / terminal, terminal | Comments Off
February 8th, 2011
‘find’ kan worden gebruikt om naar bestanden te zoeken. De onderstaande regel zoekt naar de verschillende film bestanden in de huidige folder.
find . -name *.avi -o -name *.mp4 -o -name *.m4v -type f
Tags: extensions, find, name
Posted in appletv, osx, shell / terminal, terminal | Comments Off
December 29th, 2010
Soms wil je muziek van een iPod kopiƫren zonder dat je eigenaar bent van die iPod. Met iTunes kan dit niet makkelijk, met de Terminal wel.
Zorg dat je ‘/usr/bin/SetFile’ op de plek van het script hebt staan (het script verwijst niet naar deze locatie omdat niet iedereen dit programmaatje op z’n compu heeft staan).
cp /usr/bin/SetFile ./
En dan hier het scriptje
#!/bin/sh
# iPodMusicFinder.sh
#
#
# Created by Bastiaan Nelissen on 31-10-10.
# Copyright 2010 Bastiaan Nelissen. All rights reserved.
# Script shows music files on iPod to copy to iTunes.
# Setup
name=iPodMusicFinder;
chmod 755 ./.SetFile
homedir=`dirname $0`
clear
# Say hello
echo "Welcome to $name"
echo "B.Nelissen - Winter 2010"
echo "This script makes it possible to backup your iPod music"
echo ""
# Startup
# open -a iTunes
echo "We need acces to the iPod-filesystem:"
echo "1. - Start iTunes and connect your iPod."
echo "2. - Select your iPod in the 'Devices' section."
echo "3. - Select the 'Summary' tab."
echo "4. - Select 'Enable disk use'."
echo "5. - 'Apply'."
echo ""
echo "Hit 'Enter' to continu..."
read
clear
# Locate device
echo "Locate your iPod-icon (Desktop) and drag her over here...(hit Enter)"
echo ""
read adress
# Make the right folder visible
if [ -d "$adress" ];then
echo "Mkay..."
echo "Now I will take over..."
"$homedir"/SetFile -a v "$adress/"*
"$homedir"/SetFile -a v "$adress/iPod_Control/Music"
"$homedir"/SetFile -a v "$adress/iPod_Control/Music/"*
open "$adress/iPod_Control/"
echo "Drag your 'iPod/iPod_Control/Music' folder into iTunes."
echo "Thats it."
else
echo "I said:"
echo "Locate your iPod icon and drag her over here..."
echo "Quitting..."
fi
exit
Tags: ipod, muziek, onzichtbaar
Posted in iphone, music, opslag, osx, shell / terminal, terminal | Comments Off
November 19th, 2010
Ik wilde een oneliner maken voor de terminal om tweets te kunnen lezen.
Hierbij mijn “tjirp” scriptje. Wat ik leuk vind, is dat de regel met code in de 140 tekens past.
<code>
#!/bin/bash
# b.nelissen
# terminal script for scraping twitter feeds
if [ 0 != ${#1} ]; then
Q=`echo "$1"|sed 's/#/%23/'`;
curl -s http://mobile.twitter.com/searches?q=$Q|grep ^\<str -A4|sed -e :a -e's/<[^>]*>//g;/
</str></code>
Posted in Uncategorized | Comments Off
November 15th, 2010
GeekTool is een klein programmaatje dat terminal output op je bureaublad weergeeft. GeekTool website.
Omdat het instellen van GeekTool lastig kan zijn heb ik hier een backup van mijn scriptjes.
Systeem gegevens:
uptime
top -l 2 > /tmp/top2x
top -l 1 > /tmp/top1x
cat /tmp/top2x | awk '/CPU usage/ && NR > 5 {print "CPU: " 100-$7 "%"}';
cat /tmp/top1x | awk '/PhysMem/ {print "RAM: ", $8, "(free:",$10 ,")"}';
cat /tmp/top1x | awk '/VM/ {print "pageins:", $7, "pageouts:", $9}';
df -h | grep disk0s2 | awk '{print "Macintosh HD:",$3, "(free:",$4,")"}'
echo "\n"
echo "Network:"
echo "out: `curl -s http://checkip.dyndns.org/ | sed 's/[a-zA-Z<>/ :]//g'`"
ifconfig | awk '/flags=|media|inet / {if (substr($2, 1, 6) == "flags=") printf("\n%s ", $1); else if ($1 == "inet") printf("%s ", $2); else if ($1 == "media:") printf(substr($0, 9))}' | awk '$1 ~ /^en/';
Kalender:
date +%A" "%d" "%B;cal -y
Posted in osx, shell / terminal | Comments Off