#!/usr/bin/env bash
#!/bin/bash
sudo find . -iname \*.html
^ ^ ^
| | shift-alt 7
| case insensitive
starting from current dir
locate
sudo find . | grep -i mystring
# will find "mystring" anywhere with any case
set | grep P4
printenv | grep P4
# sensible à la casse
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
/private/etc/paths
# Ou ajouter des fichiers dans le répertoire /private/etc/paths.d/. Les variables seront concaténées.
find ~/Pictures -name \*.jpg -exec md5 {} \;;
find . -type f -exec chmod -x {} \;
find "/Volumes/nicobook/backup_nicomac/Music/iTunes/iTunes Media/Music/" -type f -exec shasum -a 256 {} > ~/Desktop/music.txt \;;
find ~ -name ".DS_Store" -delete
find ~/Pictures -name .DS_Store -exec mv {} ~/.Trash/ \;;
# Les paths sont affichés en relatif si le point est utilisé comme répertoire de départ et en absolu si un répertoire de départ absolu et précisé.
# L’option r fait une recherche récursive.
# L’option i (case insensitive) ralenti la recherche d’un facteur 3.
# L’option I ignore les fichiers binaires.
# L’option -s désactive les messages d’avertissement.
grep -riIls --include="*.txt" --include="*.php" "My String" .
{ time grep -ril "My String" . ; } > ~/Desktop/grep.txt 2> ~/Desktop/time_grep.txt
enregistrer la commande dans ~/.bash_profile
export EDITOR=nano
# source : http://codesnippets.joyent.com/posts/show/1325
# first create a symbolic link
# Before OSX 10.9
sudo ln -s "/Applications/Utilities/Network Utility.app/Contents/Resources/stroke" /bin/portscan
# Since OSX 10.9
sudo ln -s "/System/Library/CoreServices/Applications/Network Utility.app/Contents/Resources/stroke" /bin/portscan
# usage: portscan address startPort endPort
portscan localhost 1 5000
portscan $(/usr/sbin/ipconfig getifaddr en0 2>/dev/null || /bin/echo localhost) 1 10000
arp -a
rsync -avn --delete --progress /Users/nico/Music/iTunes /Volumes/nicobook/backup_nicomac/Music/ > ~/Desktop/rsync_itunes.txt
rsync -avn --delete --progress /Volumes/nicobook/backup_nicomac/Music/iTunes/iTunes\ Music/Music/ "/Users/nico/Music/iTunes/iTunes Music/Music/" > ~/Desktop/rsync_itunes.txt
rsync -avn --delete --progress /Volumes/nicobook/backup_nicomac/Music/iTunes/iTunes\ Music/Music/ /Users/nico/Music/iTunes/iTunes\ Media/Music/ > ~/Desktop/rsync_itunes.txt
rsync -avn --delete --progress /Users/nico/Music/iTunes/iTunes\ Media/Music/ /Volumes/nicobook/backup_nicomac/Music/iTunes/iTunes\ Music/Music/ > ~/Desktop/rsync_itunes.txt
# http://stackoverflow.com/questions/1053853/unable-to-exclude-ds-store-in-rsync
echo ".DS_Store" > $HOME/.rsync_exclude
SOURCE=~/Desktop/
TARGET=/Volumes/nicobook/backup/2017-05-14-backup_nicobook/Desktop/
rsync -avn --progress --exclude-from=$HOME/.rsync_exclude $TARGET $SOURCE
defaults write com.apple.Dashboard devmode YES
killall Dock
Déplacer le widget souhaité en maintenant le raccourci clavier de Dashboard appuyé (F12)
Pour l’enlever du bureau utiliser la même méthode (il sera ouvert dans dashboard) ou maintenir la touche option appuyée et fermer le widget (il sera aussi fermé dans Dashboard)
defaults write com.apple.finder QuitMenuItem YES
killall Finder
# Faire une copie des défauts d’Apple
mv "/System/Library/User Template/French.lproj" "/System/Library/User Template/French.lproj-original"
# Se logger à ce compte, faire les modifs désirées
# Copier le répertoire ~/Library dans /System/Library/User Template/new/Library
cp -R ~/Library /System/Library/User\ Template/new/
# Se délogger
# Se logger comme admin et changer les permissions
sudo chown -R nico:wheel /System/Library/User\ Template/new
# Renommer le répertoire
mv /System/Library/User\ Template/new /System/Library/User\ Template/French.lproj
# Je ne sais pas pourquoi il faut passer par un répertoire intermédiaire, mais sans ça, ça ne fonctionne pas.
hdiutil makehybrid -o ~/Desktop/CD_name.iso ~/Desktop/CDFolder/ -iso -joliet
hdiutil burn ~/Desktop/CD_name.iso
- insérer CD/DVD
- Ouvrir /Applications/Utilities/Disk Utility.app/
- Sélectionner la session à graver ! Typiquement il y a trois niveaux à un CD/DVD a) le drive b) la session c) le contenu de la session. C’est le niveau session qu’il faut sélectionner.
- Cliquer sur Nouvelle image
- Format d’image : maître DVD/CD
- Chiffrement : aucun
- Renommer en *iso
sudo mdutil -a -i off
sudo mdutil -a -i on
# Effacer le fichier
mv ~/Library/Preferences/com.panic.Transmit.plist ~/.Trash/
# Effacer le fichier
mv ~/Library/Preferences/com.macromates.textmate.plist ~/.Trash/
# Enregistrer sous monFichier.url
# TOUJOURS FINIR PAR UN CR !!!
[InternetShortcut]
URL=http://www.google.ch/
# The -e flag specifies encryption is to be used on the zipfile; you’ll be prompted for a password.
# The -r flag specifies recursion; all the files in dir2 and dir4 will be included.
# The resulting zipped, encrypted file containing dir2 and dir4 will be placed at filename.zip
zip -er filename.zip dir2 dir4
zip -r foo.zip foo -x "*.DS_Store"
http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
# http://www.macports.org/
sudo port selfupdate
sudo port upgrade outdated
sudo port clean texlive-latex-recommended
sudo port install texlive-latex-recommended
# On Mavericks, Xcode command line tools must be installed prior to octave installation (see https://trac.macports.org/ticket/40810)
xcode-select --install
sudo port -v selfupdate
sudo port clean octave-devel
TIMEFORMAT='time : %3R s'; time( sudo port install octave-devel +atlas+docs )
# http://stackoverflow.com/questions/17756587/installing-graphicsmagick-on-mac-os-x-10-8
sudo port -v selfupdate
sudo port clean graphicsmagick
sudo port install graphicsmagick
sudo port selfupdate; sudo port upgrade outdated;
PP=wget
PP=ImageMagick
PP=poppler # HOMEBREW version ci-dessous avec pdf2htmlex !! # http://poppler.freedesktop.org
PP=pdftk
sudo port clean $PP; sudo port install $PP
sudo port install ImageMagick +jbig +mpeg +rsvg +wmf
brew install pdf2htmlex
# en format texte
man ls | col -b > manpage.txt
# en format postscript
man -t pandoc_markdown | open -f -a /Applications/Preview.app
# (REBOOT TO BE EFFECTIVE).
# Before Mountain Lion : ~/.MacOSX/environment.plist
# Since Mountain Lion : /private/etc/launchd.conf
# The variable P4EDITOR must be placed in /.p4config
# This is because launchd.conf doesn’t support spaces.
# P4EDITOR=bbedit --wait --resume
# ou
# P4EDITOR="/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" -w --new-window
setenv P4CLIENT frankmac
setenv P4COMMANDCHARSET utf8
setenv P4CONFIG .p4config
setenv P4PORT ssl:www.xxx.net:1666
setenv P4USER nico
setenv P4IGNORE .p4ignore
setenv EDITOR nano
launchctl setenv P4IGNORE .p4ignore
# ~/.bash_profile
alias ls='ls -lGhF'
alias la='ls -a'
alias pisshready=until nc -vzw 2 $PIIP 22; do sleep 2; done
alias sha='shasum -a 256'
PS1=$'\n\n\xf0\x9f\x98\x88'" \t – \[\033[01m\]\u@\h\[\033[00m\]:\W > "
export P4CONFIG=.p4config
export PIIP=192.168.1.113
PATH=$PATH:$HOME/Documents/mes_livres/tools/
#####
# PERFORCE
# Config Yosemite
#####
# Pour Bash + BBEdit -> dans ~/.bash_profile
export P4CONFIG=.p4config
# Pour P4V
# http://www.perforce.com/perforce/doc.current/manuals/cmdref/envars.html
# Exécuter une fois la commande :
p4 set P4CONFIG=.p4config
# Contenu du fichier /.p4config
P4EDITOR=subl --wait
P4IGNORE=.p4ignore
P4PORT=ssl:www.×××.net:1666
P4USER=nico
## Pour le texte gras
> #7F2819
## Pour le fond
> #F2F2F2
# http://stackoverflow.com/questions/602912/how-do-you-echo-a-4-digit-unicode-character-in-bash
echo -n ☠ | hexdump
echo -e "\xE2\x98\xA0"
# Crée un symlink vers l’exe qui permet de lancer sublimeText depuis le terminal
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
# #########################
# MODIFIE LA COULEUR DANS LE FINDER
# Violet
FINDERINFO='00 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
# Rouge
#FINDERINFO='00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
# Exécute le changement de couleur
xattr -wx com.apple.FinderInfo "`echo $FINDERINFO`" myfolder
# xattr -wx com.apple.FinderInfo "`xattr -px com.apple.FinderInfo ./test`" ./test2
# Afficher les attributs d’un fichier (ou répertoire)
# xattr -px com.apple.FinderInfo ./test
# http://gotofritz.net/blog/geekery/os-x-extended-attibutes/
xattr -rd com.apple.quarantine *
# Enlever tous les attributs de tous les fichiers du répertoire courant
xattr -cr .
# Enlever tous les attributs d’un fichier
xattr -c $FILE
# Lister les attributs d’un fichier
xattr $FILE
xattr -l $FILE
sudo easy_install pip
# NE PAS UTILISER
# https://pip.pypa.io/en/latest/installing.html
curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
sudo python get-pip.py
rm get-pip.py
# https://jamie.curle.io/posts/installing-pip-virtualenv-and-virtualenvwrapper-on-os-x/
# Voir aussi
# http://www.marinamele.com/2014/05/install-python-virtualenv-virtualenvwrapper-mavericks.html
sudo pip install virtualenv
sudo pip install virtualenvwrapper
# Ajouter à ~/.bash_profile
source /usr/local/bin/virtualenvwrapper.sh
system_profiler SPUSBDataType | pbcopy
alias listserial='ls -d1 /dev/cu.* | grep -v Bluetooth'
ls -l | pbcopy
# get pasteboard lines containing foo and save them in a_file
pbpaste | grep foo > a_file
fdesetup status
http://apple.stackexchange.com/questions/160161/filevault-stuck-on-pause
https://discussions.apple.com/message/26913486#26913486
# > Hi,
# > same problem, i’ve try the command in terminal but no way
# > i’ve resolved the issued doing this:
# > restarting my mac book pro ssd 500gb
# > reset pram with option+cmd+p+r
# > booting with cmd+r the utility disc (i’ve macintosh hd and one partition encrypted (the one with encoding paused)) >select the partition encrypted>click file and unlock>repair the partition disk>repair permission on partition>repair macintosh hd
# > restar
# > the encryption was resumed, after almost 9 hour the encryption ended.
# >
# > Hope this can help you.
# > Federico
# http://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
SCRIPT=`realpath $0`
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH
nmap -sP -PS22 192.168.1.0/24
shopt -s expand_aliases
# Créer le fichier /usr/local/bin/mark avec le contenu suivant :
#!/bin/sh
if [ $1 ]; then
open -a "Marked 2" $1;
else
open -a "Marked 2";
fi
pmset noidle # ⇒ obsolète, utiliser caffeinate
caffeinate -i # ⇒ no system sleep
caffeinate -d # ⇒ no display sleep
# Changer intervalle Google Chrome
# https://fauxzen.com/little-snitch-google-chrome-ksfetch-issues/
defaults write com.google.Keystone.Agent checkInterval 86400
## Une ligne par résultat
grep -IUrl --include=*.md --color $'\r'
grep -IUr --include=*.md --color $'\r'
grep -IUrl --include=*.md --color $'\t'
ISOPATH=~/Downloads/ubuntu-16.04.1-desktop-amd64
hdiutil convert -format UDRW -o $ISOPATH $ISOPATH.iso
diskutil list
# Modifier le no du disque dans les 3 commandes suivantes
# Lorsque le Finder montre un dialogue pour se plaindre qu’il n’arrive pas lire le disque, cliquer sur “Ignorer”.
diskutil unmountDisk /dev/disk2
sudo dd if=$ISOPATH.dmg of=/dev/rdisk2 bs=1m
diskutil eject /dev/disk2
Kindle Previewer 2.941 ne fonctionne pas par défaut avec Java 1.7, mais seulement avec Java 1.6
Pour résoude ce problème
subl "/Applications/Kindle Previewer.app/Contents/MacOS/Launcher"
# coller la ligne ci-dessous juste après le shebang et enregistrer le fichier
export JAVA_HOME="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"
Path Kindle
open "$HOME/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/My Kindle Content"
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true; killall Finder
# http://stackoverflow.com/questions/31972968/cant-install-gems-on-os-x-el-capitan
# Coller la commande ci-dessous dans
# ~/.gemrc
gem: -n/usr/local/bin
# Après cela, les installations devraient être OK
# Par exemple
sudo gem install kramdown
# Version simple
python -m SimpleHTTPServer 8000
# Avec affichage URL
PORT=8000; echo http://0.0.0.0:$PORT/; python -m SimpleHTTPServer $PORT;
# Par défaut ces propriétés n’existent pas !
defaults write com.apple.screencapture type jpg
defaults write com.apple.screencapture disable-shadow -bool TRUE
killall SystemUIServer
defaults read com.apple.screencapture
defaults write com.apple.screencapture type png
sudo apt-get install screen
screen
CTRL-A + D # disconnect
CTRL + D # kill
screen -r # reconnect
screen -list
Dragonframe Free Trial temporary serial number:
D4T00-51ACW-VLESQ-6D5GF-ZEU6X
brew install gphoto2
sudo apt-get install gphoto2
gphoto2 --auto-detect
gphoto2 --abilities
gphoto2 --summary
gphoto2 --list-ports
more ~/.gphoto/settings
gphoto2 --list-config
gphoto2 --get-config /main/status/batterylevel
gphoto2 --list-all-config
gphoto2 --capture-image-and-download --interval 2 --frames 2 --filename=image_%Y-%m-%d_%H-%M-%S.jpg
gphoto2 --capture-image-and-download --filename=image_%Y-%m-%d_%H-%M-%S.jpg
gphoto2 --list-files
gphoto2 --get-all-files --skip-existing
https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=117102
#!/bin/bash
mkfifo fifo.mjpg
gphoto2 --capture-movie --stdout> fifo.mjpg &
omxplayer fifo.mjpg
CAMERA-TOOLBOX
https://github.com/rlamarche/camera-toolbox
CameraControllerApi
https://github.com/scheckmedia/CameraControllerApi
http://raspberrypi.local:8888/capture?action=shot
http://raspberrypi.local:8888/settings?action=list
https://hyfrmn.wordpress.com/2015/02/03/install-libgphoto2-and-gphoto2-from-source-on-raspberry-pi/
# Install Dependencies
sudo apt-get install libltdl-dev libusb-dev libusb-1.0 libexif-dev libpopt-dev
# Download
curl https://sourceforge.net/projects/gphoto/files/libgphoto/2.5.13/libgphoto2-2.5.13.tar.gz/download > libgphoto2-2.5.13.tar.gz
curl https://sourceforge.net/projects/gphoto/files/gphoto/2.5.11/gphoto2-2.5.11.tar.gz/download > gphoto2-2.5.11.tar.gz
wget http://192.168.1.124:4000/libgphoto2-2.5.13.tar.gz
wget http://192.168.1.124:4000/gphoto2-2.5.11.tar.gz
md5 libgphoto2-2.5.13.tar.gz
MD5 (libgphoto2-2.5.13.tar.gz) = ee6f388badf2d3d29e1bfb04e7214ca6
md5 gphoto2-2.5.11.tar.gz
MD5 (gphoto2-2.5.11.tar.gz) = 3ab57ce2d85effc9d9c861609c5bfc22
tar -xvzf libgphoto2-2.5.13.tar.gz
cd libgphoto2-2.5.13
./configure
make #This is going to take some time. Go get a cup of coffee.
sudo make install
sudo apt-get purge libgphoto2-dev
tar -xvzf gphoto2-2.5.11.tar.gz
https://kuvacode.com/ https://itunes.apple.com/fr/app/smart-shooter-3/id926013641?mt=12
http://www.heliconsoft.com/helicon-remote-history/
mkdir gphoto2
cd gphoto2
# Install Dependencies ~ 1 min
sudo apt-get install libltdl-dev libusb-dev libusb-1.0 libexif-dev libpopt-dev
wget --content-disposition https://sourceforge.net/projects/gphoto/files/libgphoto/2.5.13/libgphoto2-2.5.13.tar.gz/download
wget --content-disposition https://sourceforge.net/projects/gphoto/files/gphoto/2.5.11/gphoto2-2.5.11.tar.gz/download
md5sum libgphoto2-2.5.13.tar.gz # ee6f388badf2d3d29e1bfb04e7214ca6
md5sum gphoto2-2.5.11.tar.gz # 3ab57ce2d85effc9d9c861609c5bfc22
tar -xvzf libgphoto2-2.5.13.tar.gz
tar -xvzf gphoto2-2.5.11.tar.gz
cd libgphoto2-2.5.13
./configure # ~ 2 min
make # ~ 13 min
sudo make install # ~ 2 min
cd ../gphoto2-2.5.11
./configure # ~ 30 s
make # ~ 30 s
sudo make install # ~ 2 s
sudo ldconfig
sudo reboot
gphoto2 --version
# https://github.com/gphoto/gphoto2/issues/25
sudo apt-get remove libgphoto2-port10
ps auxw | grep -i gphoto2
# pi 992 0.1 0.6 69380 6148 ? Sl 12:14 0:00 /usr/lib/gvfs/gvfsd-gphoto2 --spawner :1.1 /org/gtk/gvfs/exec_spaw/2
kill `pidof /usr/lib/gvfs/gvfsd-gphoto2`
# http://gphoto-software.10949.n7.nabble.com/Move-to-2-5-6-failed-td14945.html
# http://gphoto-software.10949.n7.nabble.com/Gphoto2-Cannot-Claim-USB-Device-td14321.html
gphoto2 --version
gphoto2 2.5.11
Copyright (c) 2000-2016 Lutz Mueller and others
gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.
This version of gphoto2 is using the following software versions and options:
gphoto2 2.5.11 gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2 2.5.4 all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0 gcc, ltdl, USB, serial without locking
gphoto2 --version
gphoto2 2.5.11
Copyright (c) 2000-2016 Lutz Mueller and others
gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.
This version of gphoto2 is using the following software versions and options:
gphoto2 2.5.11 gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2 2.5.13 all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0 gcc, ltdl, USB, serial without locking
STREAMING ⇒ Ça fonctionne, mais le lag est infernal : http://blendps.blogspot.ch/2017/01/live-preview-streaming-from-nikon-3200.html
Flushing your DNS cache in Mac OS X and Linux https://help.dreamhost.com/hc/en-us/articles/214981288-Flushing-your-DNS-cache-in-Mac-OS-X-and-Linux
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
VIRTUALBOX USB CONFIGURATION
https://greatxam.wordpress.com/2010/11/23/virtualbox-usb-configuration/
system_profiler SPUSBDataType
Finder show hidden files
https://recoverit.wondershare.com/mac-tips/see-hidden-files-mac.html
defaults write com.apple.finder AppleShowAllFiles true;
killall Finder
env SHELL=/bin/bash TERM=dterm open /Applications/DTerm.app
sudo spctl --master-disable
sudo spctl --master-enable
xcode-select --install
###
# Lacie HD peut se bloquer parce que macOS essaie de faire un scan avec fsck, mais le processus ne se termine jamais.
# Solution : obtenir le PID de fsk et le killer
##
PID=`pgrep -x fsck_exfat` && echo $PID && sudo kill -9 $PID
# ou directement
sudo killall -u root fsck_exfat -s # -s=dummy try
# Autres commandes utiles pour gérer les disques
# Get mountpoints
diskutil list
df -h
# Unmount a partition
MOUNTPOINT="/dev/disk4s2"
diskutil unmount $MOUNTPOINT
# S.O.S on partition
fsck_exfat -y -x $MOUNTPOINT
# Unmount an entire disk
diskutil list
MOUNTPOINT="/dev/disk4"
diskutil unmountDisk $MOUNTPOINT