Puede cmdarrastrar un elemento a la barra de herramientas del Finder para tenerlo allí de forma permanente, pero ¿hay alguna forma de hacerlo en la Terminal?
Lo más cercano que he encontrado es este antiguo hilo: http://macscripter.net/viewtopic.php?id=21344
Lo que sugiere algo como esto:
defaults write com.apple.finder FXToolbarItems -array-add '<dict><key>file-data</key><dict><key>_CFURLString</key><string>"/Applications/Chess.app"</string><key>_CFURLStringType</key><integer>0</integer></dict></dict>'
killall -HUP Finder
.. o quizás ...
defaults write com.apple.finder FXToolbarItems -array-add '<dict><key>file-data</key><dict><key>_CFURLString</key><string>"/Applications/Chess.app"</string><key>_CFURLStringType</key><integer>0</integer></dict><key>item-id</key><string>loc%20</string></dict>'
killall -HUP Finder
Ninguno parece funcionar. ¿Hay algo que funcione con Yosemite y superior?
Me doy cuenta de que si agrego manualmente la aplicación Chess a la barra de herramientas del Finder y luego muestro las preferencias del Finder de la siguiente manera:
defaults read com.apple.finder >> finderprefs
Puedo ver que lo pone así:
"TB Item Plists" = {
7 = {
"_CFURLAliasData" = <(lots of hex code)>;
"_CFURLString" = "file:///Applications/Chess.app";
"_CFURLStringType" = 15;
};
};
Así que supongo que necesito encontrar una manera de hacer eso condefaults write
Más investigaciones sugieren que no es recomendable agregar elementos programáticamente: http://prod.lists.apple.com/archives/cocoa-dev/2015/May/msg00212.html
Si sabes diferente, me encantaría saber...
Esto es todo lo que tengo, y no funciona para mí en El Capitán (aunque, eso podría tener algo que ver con la versión beta...).
Parece que defaults
no es lo suficientemente completo (¿ya no? /usr/libexec/PlistBuddy
)
Estos son los dos comandos que puede usar para agregar _CFURLString
y _CFURLStringType
:
/usr/libexec/PlistBuddy -c 'Add "NSToolbar Configuration Browser":"TB Item Plists":8:_CFURLString string "file:///Applications/Chess.app"' ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c 'Add "NSToolbar Configuration Browser":"TB Item Plists":8:_CFURLStringType integer 15' ~/Library/Preferences/com.apple.finder.plist
El "8" que se encuentra en los dos comandos anteriores es el índice de matriz del elemento.
No _CFURLAliasData
se genera (como se sugiere en varios lugares). Intenté crear un archivo vacío _CFURLAliasData
, pero Finder no lo completó.
Otro problema es que si agrego/elimino otro elemento usando cmd-arrastrar, todos los datos que he agregado con PlistBuddy se borran...
Con suerte, esta información llevará a alguien más a mitad de camino.
Además de agregar una entrada a TB Item Plists
usted, también debe agregar una entrada a TB Item Identifiers
.
El siguiente código agregará Go2Shell a la barra de herramientas del Finder:
#!/usr/bin/env bash
PLIST=~/Library/Preferences/com.apple.finder.plist
ITEMS=`/usr/libexec/PlistBuddy -c "Print 'NSToolbar Configuration Browser:TB Default Item Identifiers'" $PLIST | sed '1d; $d'`
APP=/Applications/Go2Shell.app/Contents/MacOS/Go2ShellHelper.app/
POSITION=8
/usr/libexec/PlistBuddy -c "Delete 'NSToolbar Configuration Browser:TB Item Identifiers'" $PLIST
/usr/libexec/PlistBuddy -c "Delete 'NSToolbar Configuration Browser:TB Item Plists'" $PLIST
/usr/libexec/PlistBuddy -c "Add 'NSToolbar Configuration Browser:TB Item Identifiers' array" $PLIST
i=1
for ITEM in $ITEMS
do
if [ $i -ne $POSITION ]; then
/usr/libexec/PlistBuddy -c "Add 'NSToolbar Configuration Browser:TB Item Identifiers:$i' string $ITEM" $PLIST
fi
((i++))
done
/usr/libexec/PlistBuddy -c "Add 'NSToolbar Configuration Browser:TB Item Plists:$POSITION:_CFURLString' string 'file://$APP'" $PLIST
/usr/libexec/PlistBuddy -c "Add 'NSToolbar Configuration Browser:TB Item Plists:$POSITION:_CFURLStringType' integer 15" $PLIST
#/usr/libexec/PlistBuddy -c "Import 'NSToolbar Configuration Browser:TB Item Plists:$POSITION:_CFURLAliasData' alias_data" $PLIST
/usr/libexec/PlistBuddy -c "Add 'NSToolbar Configuration Browser:TB Item Identifiers:$POSITION' string 'com.apple.finder.loc '" $PLIST
killall -HUP Finder
com.apple.finder.loc
se requiere el espacio posterior)La _CFURLAliasData
importación está comentada ya que no es necesaria para la barra de herramientas del Finder, y probablemente también sea una mala idea . Si se requieren los datos del alias (puede ser para la barra lateral del Finder o el Dock ), el siguiente código generará un alias_data
archivo para Go2Shell y lo agregará al plist:
#!/usr/bin/env bash
APP=/Applications/Go2Shell.app/Contents/MacOS/Go2ShellHelper.app/
POSITION=8
python2 -c "from Carbon import File; print File.FSNewAlias(None, File.FSRef('$APP')).data" > alias_data
/usr/libexec/PlistBuddy -c "Import 'NSToolbar Configuration Browser:TB Item Plists:$POSITION:_CFURLAlias_Data' alias_data" ~/Library/Preferences/com.apple.finder.plist
rm alias_data
Grasa amante de los caballos