Tautuhi aunoa i nga hononga konae, ara, ko te kowhiri i tetahi papatono ka whakatuwhera i tetahi konae mai i te Explorer/Finder. A ka tohatoha ahau.
Nga raruraru tuatahi. Ko nga konae me nga taapiri e hiahiatia ana kaore e whakatuwherahia e tetahi mea ma te taunoa, a ki te whakatuwherahia, na etahi iTunes. I raro i te Matapihi, ka ngaro katoa nga hononga e tika ana i te wa e whakauru ana (me te tango ranei) nga kaupapa: i etahi wa ka tango koe i te GIMP, ka tangohia nga konae ico mai i te kaitirotiro konae ki te Taiwhanga Whakaahua paerewa. He aha? Hei aha? Kaore i te mohiotia... He aha mena ka kitea e au he etita hou, he maha nga take, he whakaurunga hou? He aha mehemea he nui ake i te kotahi rorohiko? I te nuinga o te waa, ko te panui kiore i roto i nga korerorero he momo whakangahau.
Engari, e rua nga konae i tiakina e ahau ki runga Dropbox, ka taea e au te whakahoki mai i te ao rorohiko ki te noho noa tata tonu. A he aha koe e tatari ana mo nga tau maha ... Ka whai ake ko te tunu mo Windows me te macOS.
Windows
I roto i te papatohu Windows cmd.exe
ka mahia tenei i nga waahanga e rua:
ftype my_file_txt="C:Windowsnotepad.exe" "%1"
assoc .txt=my_file_txt
Ka whai mana tonu nga huringa. Ahakoa te mea kua rehitahia te hononga mo tetahi kaiwhakamahi motuhake, mo etahi take me whakahaere enei whakahau hei kaiwhakahaere. A kaua e wareware ki te whakarua i te tohu ōrau (%%1) ina rere ana mai i te konae pekapeka. Ko te ao makutu o Windows 7 Ultimate 64-bit…
MacOS
I roto i te MacOS he watea ki te whakarite hononga ma te whakamahi i te whaipainga brew install duti
. Tauira whakamahi:
duti -s com.apple.TextEdit .txt "editor"
Ka whai mana nga huringa, kaore e hiahiatia te sudo. I konei ko te tautohe "com.apple.TextEdit" ko te "id paihere" o te kaupapa e hiahiatia ana e tatou. Ko te tautohetohe "kaiwhakatika" ko te momo hononga: "kaiwhakatika" mo te whakatika, "kaitaki" mo te maataki, "katoa" mo nga mea katoa.
Ka kitea e koe te "id paihere" penei: mena he "/Applications/Sublime Text.app" o te putanga tuatoru, katahi ko tana ID paihere ko "com.sublimetext.3", tetahi atu ranei:
> osascript -e 'id of app "Sublime Text"'
com.sublimetext.3
I whakamatauria i runga i te macOS Sierra.
Tuhituhi whakamutunga mo Windows (.bat)
@echo off
set XNVIEW=C:Program Files (x86)XnViewxnview.exe
set SUBLIME=C:Program FilesSublime Text 3sublime_text.exe
set FOOBAR=C:Program Files (x86)foobar2000foobar2000.exe
call :assoc_ext "%SUBLIME%" txt md js json css java sh yaml
call :assoc_ext "%XNVIEW%" png gif jpg jpeg tiff bmp ico
call :assoc_ext "%FOOBAR%" flac fla ape wav mp3 wma m4a ogg ac3
goto :eof
:assoc_ext
set EXE=%1
shift
:loop
if "%1" neq "" (
ftype my_file_%1=%EXE% "%%1"
assoc .%1=my_file_%1
shift
goto :loop
)
goto :eof
Hōtuhi whakamutunga mō te macOS (.sh)
#!/bin/bash
# this allows us terminate the whole process from within a function
trap "exit 1" TERM
export TERM_PID=$$
# check `duti` installed
command -v duti >/dev/null 2>&1 ||
{ echo >&2 "duti required: brew install duti"; exit 1; }
get_bundle_id() {
osascript -e "id of app """ || kill -s TERM $TERM_PID;
}
assoc() {
bundle_id=$1; shift
role=$1; shift
while [ -n "$1" ]; do
echo "setting file assoc: $bundle_id .$1 $role"
duti -s "$bundle_id" "." "$role"
shift
done
}
SUBLIME=$(get_bundle_id "Sublime Text")
TEXT_EDIT=$(get_bundle_id "TextEdit")
MPLAYERX=$(get_bundle_id "MPlayerX")
assoc "$SUBLIME" "editor" txt md js jse json reg bat ps1 cfg sh bash yaml
assoc "$MPLAYERX" "viewer" mkv mp4 avi mov webm
assoc "$MPLAYERX" "viewer" flac fla ape wav mp3 wma m4a ogg ac3
Source: will.com