LoginSignup
2
2

More than 1 year has passed since last update.

windows terminal + nyagos で透過

Posted at

windows terminal に nyagos のプロファイルを追加して、アクリル透明化を有効にしたのだけれども、入力欄が透明化しない・・・
sc.3.jpg
過去に X11 の rxvt などで同じような症状が出たことがあったから、ASCII文字色の指定か?

ということで nyagos のプロンプトの設定を含めていろいろ調べた結果、きれいに透過させられました。
sc.4.jpg

こちらを参考にさせてもらいました。

【NYAGOS】プロンプトで使える特殊文字と ANSI エスケープシーケンスを Lua でラップする

(markdownのフォーマット指定のために .lua にしてますが、%HOMEPATH%.nyagos に保存します)

~/.nyagos.lua
share.org_prompter = nyagos.prompt
nyagos.prompt = function(this)
    local prompt = share.prompt
    local esc = share.escape_sequence

    -- add dir name (with drive letter)
    -- bg.default (=49) だけでいい気もしますが、追加で bg.trans (=60) も足してます
    local pstart = esc.create_sequence(esc.bg.default, esc.bg.trans)
    local prompt_message = string.format('%s[%s]', pstart, prompt.path)

    -- check git branch
    local git_branch_name = nyagos.eval('git rev-parse --abbrev-ref HEAD 2>nul')

    if (git_branch_name ~= '') then
        -- add git branch name
        prompt_message = string.format(prompt_message .. ' [%s]', git_branch_name)
    end

    -- add line break
    prompt_message = prompt_message .. prompt.crlf

    -- add dollar
    prompt_message = prompt_message .. prompt.dollar .. ' '

    return share.org_prompter(prompt_message)
end

share.prompt = {
    eq = '$q', -- equal '='
    dollar = '$$', -- dollar '$'
    time = '$t', -- current time
    date = '$d', -- current date
    path = '$p', -- current path (with drive letter)
    ver = '$v', -- windows version
    drive = '$n', -- current drive letter
    gt = '$g', -- greater than '>'
    lt = '$l', -- less than '<'
    pipe = '$b', -- pipe '|'
    crlf = '$_', -- line break
    esc = '$e', -- escape
    bs = '$h', -- backspace
    amp = '$a', -- ampersand '&'
    l_par = '$c', -- left parenthesis '('
    r_par = '$f', -- right parenthesis ')'
    space = '$s' -- space
}

share.escape_sequence = {
    -- attribute
    attr = {
        off = '0',
        bold = '1',
        bold_off = '21',
        underline = '4',
        underline_off = '24',
        blink = '5',
        blink_off = '25'
    },

    -- foreground
    fg = {
        black = '30',
        red = '31',
        green = '32',
        yellow = '33',
        blue = '34',
        magenta = '35',
        cyan = '36',
        white = '37',
        default = '39',
        -- prefix 'l' is 'Light'
        l_gray = '90',
        l_red = '91',
        l_green = '92',
        l_yellow = '93',
        l_blue = '94',
        l_magenta = '95',
        l_cyan = '96',
        l_white = '97'
    },

    -- background
    bg = {
        black = '40',
        red = '41',
        green = '42',
        yellow = '43',
        blue = '44',
        magenta = '45',
        cyan = '46',
        white = '47',
        default = '49',
        trans = '60',
        -- prefix 'l' is 'Light'
        l_gray = '100',
        l_red = '101',
        l_green = '102',
        l_yellow = '103',
        l_blue = '104',
        l_magenta = '105',
        l_cyan = '106',
        l_white = '107'
    },

    create_sequence = function(...)
        local prompt = share.prompt
        local attrs = {...}
        local joined_attrs = ''

        for n, v in pairs(attrs) do
            local val = tostring(v)
            if val ~= nil then
                joined_attrs = joined_attrs ~= '' and joined_attrs .. ';' .. val or val
            end
        end

        return string.format('%s[%sm', prompt.esc, joined_attrs)
    end
}
2
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
2
2