wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.14k stars 771 forks source link

Unicode chars ๐Ÿ”ด or ๐Ÿ”ถ not shown in tab title #711

Closed jankatins closed 3 years ago

jankatins commented 3 years ago

Describe the bug

Unicode char not shown in tab title: If I use ๐Ÿ”ด or ๐Ÿ”ถ. It woks with โ– .

Environment (please complete the following information):

To Reproduce

I use the following title function to show if I'm in the toolbox or not:

function title {
  emulate -L zsh
  setopt prompt_subst

  [[ "$INSIDE_EMACS" == *term* ]] && return

  # if $2 is unset use $1 as default
  # if it is set and empty, leave it as is
  : ${2=$1}

  case "$TERM" in
    cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
      print -Pn "\e]2;${TITLE_ADDITION}${2:q}\a" # set window name
      print -Pn "\e]1;${TITLE_ADDITION}${1:q}\a" # set tab name
      ;;
    screen*|tmux*)
      print -Pn "\ek${1:q}\e\\" # set screen hardstatus
      ;;
    *)
      if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
        print -Pn "\e]2;${2:q}\a" # set window name
        print -Pn "\e]1;${1:q}\a" # set tab name
      else
        # Try to use terminfo to set the title
        # If the feature is available set title
        if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
          echoti tsl
          print -Pn "$1"
          echoti fsl
        fi
      fi
      ;;
  esac
}

In .zshrc, i set:

export TITLE_ADDITION=""

# Toolbox specific things
if [[ -f /run/.containerenv && -f /run/.toolboxenv ]]; then
  # inside toolbox container
  # same with ๐Ÿ”ด, but โ–  works
  TITLE_ADDITION="๐Ÿ”ถ" 
fi

This is intended a workaround for https://github.com/wez/wezterm/issues/647

Configuration

-- https://wezfurlong.org/wezterm/config/
local wezterm = require 'wezterm';

-- The status bar
wezterm.on("update-right-status", function(window, pane)
  -- Each element holds the text for a cell in a "powerline" style << fade
  local cells = {};

  -- Figure out the cwd and host of the current pane.
  -- This will pick up the hostname for the remote host if your
  -- shell is using OSC 7 on the remote host.
  local cwd_uri = pane:get_current_working_dir()
  if cwd_uri then
    cwd_uri = cwd_uri:sub(8);
    local slash = cwd_uri:find("/")
    local cwd = ""
    local hostname = ""
    if slash then
      hostname = cwd_uri:sub(1, slash-1)
      -- Remove the domain name portion of the hostname
      local dot = hostname:find("[.]")
      if dot then
        hostname = hostname:sub(1, dot-1)
      end
      -- and extract the cwd from the uri
      cwd = cwd_uri:sub(slash)

      table.insert(cells, cwd);
--      table.insert(cells, hostname);
    end
  end

  local date = wezterm.strftime("%a %Y-%m-%d %H:%M");
  table.insert(cells, date);

  -- An entry for each battery (typically 0 or 1 battery)
  for _, b in ipairs(wezterm.battery_info()) do
    local symbol = "๐Ÿ”‹"
    if b.state == "Charging" then
      symbol = "๐Ÿ”Œ"
    end
    table.insert(cells, string.format(symbol .. " %.0f%%", b.state_of_charge * 100))
  end

  -- The powerline < symbol
  local LEFT_ARROW = utf8.char(0xe0b3);
  -- The filled in variant of the < symbol
  local SOLID_LEFT_ARROW = utf8.char(0xe0b2)

  -- Color palette for the backgrounds of each cell
  local colors = {
    "#3c1361",
    "#52307c",
    "#663a82",
    "#7c5295",
    "#b491c8",
  };

  -- Foreground color for the text across the fade
  local text_fg = "#c0c0c0";

  -- The elements to be formatted
  local elements = {};
  -- How many cells have been formatted
  local num_cells = 0;

  -- Translate a cell into elements
  function push(text, is_last)
    local cell_no = num_cells + 1
    table.insert(elements, {Foreground={Color=text_fg}})
    table.insert(elements, {Background={Color=colors[cell_no]}})
    table.insert(elements, {Text=" "..text.." "})
    if not is_last then
      table.insert(elements, {Foreground={Color=colors[cell_no+1]}})
      table.insert(elements, {Text=SOLID_LEFT_ARROW})
    end
    num_cells = num_cells + 1
  end

  while #cells > 0 do
    local cell = table.remove(cells, 1)
    push(cell, #cells == 0)
  end

  window:set_right_status(wezterm.format(elements));
end);

-- some host specific stuff
-- See also https://wezfurlong.org/wezterm/config/lua/wezterm/hostname.html
local font_size;
if wezterm.target_triple == "x86_64-apple-darwin" then
  -- apple laptop at work
  font_size=12.0
else
  -- private laptop...
  font_size=11.0
end

-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)

-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)

return {
  -- font = wezterm.font_with_fallback({"JetBrains Mono Semi Light", "Noto Color Emoji"}),
  font_size = font_size,
  -- dpi = 96.0,
  -- font_antialias = "Subpixel", -- None, Greyscale, Subpixel
  --font_antialias = "Greyscale", -- None, Greyscale, Subpixel
  --font_hinting = "Full",  -- None, Vertical, VerticalSubpixel, Full

  -- this disables ligatures
  harfbuzz_features = {"calt=0", "clig=0", "liga=0"},

  -- Use a adjusted tango theme -> in colors subfolder
  color_scheme = "TangoDarkAdjusted",
  --color_scheme = "Builtin Tango Dark",

  --use_dead_keys = false,
  --debug_key_events = true ,

  -- ALT/OPT/META = Alt/Option key, SUPER/CMD/WIN = Windows/Command key
  keys = {
    -- Some default shortcuts
    {key="PageUp", mods="CTRL", action=wezterm.action{ActivateTabRelative=-1}},
    {key="PageDown", mods="CTRL", action=wezterm.action{ActivateTabRelative=1}},

    -- from https://github.com/wez/wezterm/issues/253
    -- Make Option-Left equivalent to Alt-b which many line editors interpret as backward-word
    {key="LeftArrow", mods="ALT", action=wezterm.action{SendString="\x1bb"}},
    -- Make Option-Right equivalent to Alt-f; forward-word
    {key="RightArrow", mods="ALT", action=wezterm.action{SendString="\x1bf"}},

    -- get a tilde inserted directly on Mac... seems to be some kind of bug: https://github.com/wez/wezterm/issues/410
    {key="n", mods="OPT", action=wezterm.action{SendString="~"}},
  },

  -- works together with update-right-status and colors -> tab_bar settings
  tab_bar_style = {
    active_tab_left = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#52307c"}},
      {Text=SOLID_LEFT_ARROW},
      {Background={Color="#52307c"}},
      {Text=" "},
    }),
    active_tab_right = wezterm.format({
      {Background={Color="#52307c"}},
      {Text=" "},
      {Background={Color="#0b0022"}},
      {Foreground={Color="#52307c"}},
      {Text=SOLID_RIGHT_ARROW},
    }),
    inactive_tab_left = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#3c1361"}},
      {Text=SOLID_LEFT_ARROW},
      {Background={Color="#3c1361"}},
      {Text=" "},
    }),
    inactive_tab_right = wezterm.format({
      {Background={Color="#3c1361"}},
      {Text=" "},
      {Background={Color="#0b0022"}},
      {Foreground={Color="#3c1361"}},
      {Text=SOLID_RIGHT_ARROW},
    }),
    inactive_tab_hover_left = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#3c1361"}},
      {Text=SOLID_LEFT_ARROW},
      {Background={Color="#3c1361"}},
      {Text=" "},
    }),
    inactive_tab_hover_right = wezterm.format({
      {Background={Color="#3c1361"}},
      {Text=" "},
      {Background={Color="#0b0022"}},
      {Foreground={Color="#3c1361"}},
      {Text=SOLID_RIGHT_ARROW},
    }),
  },

  colors = {
    tab_bar = {

      -- The color of the strip that goes along the top of the window
      background = "#0b0022",

      -- The active tab is the one that has focus in the window
      active_tab = {
        -- The color of the background area for the tab
        bg_color = "#52307c",
        -- The color of the text for the tab
        fg_color = "#c0c0c0",

        -- Specify whether you want "Half", "Normal" or "Bold" intensity for the
        -- label shown for this tab.
        -- The default is "Normal"
        intensity = "Bold",

        -- Specify whether you want "None", "Single" or "Double" underline for
        -- label shown for this tab.
        -- The default is "None"
        underline = "None",

        -- Specify whether you want the text to be italic (true) or not (false)
        -- for this tab.  The default is false.
        italic = false,

        -- Specify whether you want the text to be rendered with strikethrough (true)
        -- or not for this tab.  The default is false.
        strikethrough = false,
      },

      -- Inactive tabs are the tabs that do not have focus
      inactive_tab = {
        bg_color = "#3c1361",
        fg_color = "#808080",

        -- The same options that were listed under the `active_tab` section above
        -- can also be used for `inactive_tab`.
      },

      -- You can configure some alternate styling when the mouse pointer
      -- moves over inactive tabs
      inactive_tab_hover = {
        bg_color = "#3c1361",
        fg_color = "#909090",
        --italic = true,
        intensity = "Bold",
        underline = "Single",

        -- The same options that were listed under the `active_tab` section above
        -- can also be used for `inactive_tab_hover`.
      }
    }
  }
}

Expected behavior

The orange diamond/red dot should show up in the tab. It does with โ– .

Screenshots

image

As there is a bit more space in front of the '~' sign I guess that something is printed, but it doesn't show up.

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days โณ. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.