LoginSignup
3
2

More than 5 years have passed since last update.

Theme (テーマ) を気楽に変更する。

Last updated at Posted at 2015-05-02

結局練習も兼ねて Package にしてみた。

theme-switch

最初、名前は theme-switcher にしてたんだが、この名前のパッケージ( theme-switcher ) が既に存在して、publish の最後で弾かれたので、theme-switch に名前を変えた。

theme-switcher より better な点は

  • prev, next で theme を進んだり、戻ったり出来る
  • uiとsyntaxペアの設定がしやすい
  • Theme set(ui syntax のペア) は何個でも登録可
  • 現在のtheme設定を尊重する(現在の theme set を prev,next の始点にする)

といったところ。
Coffeescript や、Web 技術(Js,HTML, CSS) のお勉強も兼ねて、しばらくは Atom Hack してみよう。

↓元の投稿

昼間カフェで作業する場合は、外が明るいので light な syntax で、
夜暗い時は、目が痛いので、dark な syntax で作業したい、とか良くある。
これを気楽に行えるようにしたい。

カラーテーマとシンタックスの組は配列として、core.themes Config に保存されているので、
これを set すれば気楽に変えられる。

init.coffee
class ThemeProfile
  constructor: (@profiles) ->
    @index = 0
  next: ->
    @index = (@index + 1) % @profiles.length
    @profiles[@index]

# ThemeProfile の constructor に好きなだけ ui-theme と syntax ペアを登録する。
themeProfile = new ThemeProfile [
  ["atom-dark-ui", "atom-dark-syntax"]
  ["atom-dark-ui", "atom-light-syntax"]
]

atom.commands.add 'atom-text-editor',
  'user:theme-next': (event) ->
    atom.config.set("core.themes", themeProfile.next())

使い方

command palette から user:theme-next を実行(tn<enter>とかで)。
頻繁に変更するなら keymap 設定してね♥

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2