余白の書きなぐり

aueweのブログ

CraftLaunchの設定ファイルを任意の場所からインポートする方法

Windowsには CraftLaunch という便利なキーボードランチャがある。 設定ファイルの config.py をいじれば色々楽しめる。

自分用の設定が詰まった config.py を他のソフトの設定ファイルと一緒に git 管理したい。 自分用の設定ファイルを任意の場所からインポートするには、以下のファイルを clnch.exeのあるフォルダconfig.py の名前で保存する。 そうすれば C:\path\to\dotfiles\config.py が読み込まれる。

import os
import sys
from clnch import *

# 自分用の config.py のディレクトリへのパス
NewImportPath = 'C:/path/to/dotfiles'

# clnch.exeからの相対パスで指定する場合
# DotFilesPath = '..\\..\\dotfiles'
# NewImportPath = os.path.join(getAppExePath(), DotFilesPath).replace(os.path.sep,'/')

# import する path に NewImportPath を追加
sys.path.append( NewImportPath )

# NewImportPath/config.py を読み込み
from config import *