<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yusuke Minami</title>
    <description>The latest articles on DEV Community by Yusuke Minami (@minyus).</description>
    <link>https://dev.to/minyus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F412767%2Fcdb37dfb-e4b3-4812-9e2c-c12c50acc7e2.jpeg</url>
      <title>DEV Community: Yusuke Minami</title>
      <link>https://dev.to/minyus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/minyus"/>
    <language>en</language>
    <item>
      <title>An alternative way to debug your Python code</title>
      <dc:creator>Yusuke Minami</dc:creator>
      <pubDate>Sat, 13 Jan 2024 14:39:53 +0000</pubDate>
      <link>https://dev.to/minyus/an-alternative-way-to-debug-your-python-code-115b</link>
      <guid>https://dev.to/minyus/an-alternative-way-to-debug-your-python-code-115b</guid>
      <description>&lt;h1&gt;
  
  
  Rich Exception
&lt;/h1&gt;

&lt;p&gt;Python developers use print(variable_foobar) or debugging feature of IDE such as VS Code to troubleshoot, but aren't there any quicker alternative ways?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rich&lt;/code&gt; package can make the exception traceback nicer; show the local variable values and extra lines of code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fji0x71eqa8vylp12yl45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fji0x71eqa8vylp12yl45.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Install rich
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-U&lt;/span&gt; rich
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Place the following code in the beginning of your main module.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;rich.traceback&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt;

    &lt;span class="nf"&gt;install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;console&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;extra_lines&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;theme&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;word_wrap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;show_locals&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;locals_max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;locals_max_string&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;locals_hide_dunder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;locals_hide_sunder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;indent_guides&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;suppress&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="n"&gt;max_frames&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Failed to set up rich traceback. Try: pip install -U rich&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, to apply to all the codes you run, you may place the Python code in &lt;code&gt;sitecustomize.py&lt;/code&gt; file in &lt;code&gt;site-packages&lt;/code&gt; directory which can be found by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import sys;print(sys.path)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;Regarding the options, see the documents:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rich.readthedocs.io/en/stable/traceback.html#traceback-handler" rel="noopener noreferrer"&gt;https://rich.readthedocs.io/en/stable/traceback.html#traceback-handler&lt;/a&gt;&lt;br&gt;
&lt;a href="https://rich.readthedocs.io/en/stable/reference/traceback.html#rich.traceback.install" rel="noopener noreferrer"&gt;https://rich.readthedocs.io/en/stable/reference/traceback.html#rich.traceback.install&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>vscode</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Tools I use</title>
      <dc:creator>Yusuke Minami</dc:creator>
      <pubDate>Sat, 13 Jan 2024 01:35:41 +0000</pubDate>
      <link>https://dev.to/minyus/tools-i-use-1ain</link>
      <guid>https://dev.to/minyus/tools-i-use-1ain</guid>
      <description>&lt;p&gt;Wezterm (Terminal)&lt;br&gt;
&lt;a href="https://wezfurlong.org/wezterm/"&gt;https://wezfurlong.org/wezterm/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/minyus/tired-of-copying-text-in-terminal-1anj"&gt;https://dev.to/minyus/tired-of-copying-text-in-terminal-1anj&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Xonsh (Shell)&lt;br&gt;
&lt;a href="https://xon.sh/"&gt;https://xon.sh/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git&lt;br&gt;
&lt;a href="https://git-scm.com/"&gt;https://git-scm.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;gitui (CLI)&lt;br&gt;
&lt;a href="https://github.com/extrawurst/gitui"&gt;https://github.com/extrawurst/gitui&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;VS Code (IDE)&lt;br&gt;
&lt;a href="https://code.visualstudio.com/"&gt;https://code.visualstudio.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GitLens (VS Code Extension)&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens"&gt;https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Python&lt;/p&gt;

&lt;p&gt;Black formatter (VS Code Extension)&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter"&gt;https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ruff (VS Code Extension)&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff"&gt;https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rich exception traceback&lt;br&gt;
&lt;a href="https://github.com/Textualize/rich"&gt;https://github.com/Textualize/rich&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/minyus/an-alternative-way-to-debug-your-python-code-115b"&gt;https://dev.to/minyus/an-alternative-way-to-debug-your-python-code-115b&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Phind&lt;br&gt;
&lt;a href="https://www.phind.com/"&gt;https://www.phind.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Raycast&lt;br&gt;
&lt;a href="https://www.raycast.com/"&gt;https://www.raycast.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Obsidian&lt;br&gt;
&lt;a href="https://obsidian.md/"&gt;https://obsidian.md/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mac only: Karabiner-Elements&lt;br&gt;
&lt;a href="https://karabiner-elements.pqrs.org/"&gt;https://karabiner-elements.pqrs.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Windows only: sharpkeys&lt;br&gt;
&lt;a href="https://apps.microsoft.com/detail/XPFFCG7M673D4F?hl=en-US&amp;amp;gl=US"&gt;https://apps.microsoft.com/detail/XPFFCG7M673D4F?hl=en-US&amp;amp;gl=US&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Tired of copying text in terminal?</title>
      <dc:creator>Yusuke Minami</dc:creator>
      <pubDate>Sun, 07 Jan 2024 12:10:26 +0000</pubDate>
      <link>https://dev.to/minyus/tired-of-copying-text-in-terminal-1anj</link>
      <guid>https://dev.to/minyus/tired-of-copying-text-in-terminal-1anj</guid>
      <description>&lt;h2&gt;
  
  
  Paint point
&lt;/h2&gt;

&lt;p&gt;As an engineer, it has been my pain point to copy text in terminal.&lt;br&gt;
The situation occurs frequently while navigating files in remote data storage such as S3 and HDFS which does not support &lt;code&gt;cd&lt;/code&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;A solution I found is quick select feature of Wezterm, which assigns keyboard shortcut (1-2 characters) to copy quickly in the terminal.&lt;/p&gt;

&lt;p&gt;In default, however, the selection does not work as expected.&lt;/p&gt;

&lt;p&gt;Here is my config.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ctrl + Shift + y &amp;gt;&amp;gt; copy a text separated by whitespace characters&lt;/li&gt;
&lt;li&gt;Ctrl + Shift + l &amp;gt;&amp;gt; copy a line (useful to copy and paste error message into Google search or LLM)&lt;/li&gt;
&lt;li&gt;Ctrl + Shift + p &amp;gt;&amp;gt; copy a text separated by whitespace/slash/quotation/bracket characters (useful to copy only file names, values in JSON, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qVIwf7ED--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/if00vvdrkgroj3cnx8zb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qVIwf7ED--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/if00vvdrkgroj3cnx8zb.png" alt="Image description" width="800" height="842"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set up
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Install Wezterm following &lt;a href="https://wezfurlong.org/wezterm/installation.html"&gt;https://wezfurlong.org/wezterm/installation.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;~/.wezterm.lua&lt;/code&gt; file including the following content:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Pull in the wezterm API
local wezterm = require 'wezterm'

-- This table will hold the configuration.
local config = {}

-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
    config = wezterm.config_builder()
end

-- This is where you actually apply your config choices


config.quick_select_patterns = {
    -- match things that look like sha1 hashes
    -- (this is actually one of the default patterns)
    '\\S{6,}',
}

config.keys = {
    {
        key = 'Y',
        mods = 'CTRL',
        action = wezterm.action.QuickSelectArgs {
            patterns = {
                '\\S{6,}',
            },
            scope_lines = 0,
            label = 'copy a text separated by whitespace characters',
        },
    },
    {
        key = 'L',
        mods = 'CTRL',
        action = wezterm.action.QuickSelectArgs {
            patterns = {
                '.{6,}',
            },
            scope_lines = 0,
            label = 'copy a line',
        },
    },
    {
        key = 'P',
        mods = 'CTRL',
        action = wezterm.action.QuickSelectArgs {
            patterns = {
                '[^\\s\\/\'\"\\&amp;lt;\\&amp;gt;\\{\\}\\(\\)\\[\\]]{6,}',
            },
            scope_lines = 0,
            label = 'copy a text separated by whitespace/slash/quotation/bracket characters',
        },
    },
}

config.disable_default_quick_select_patterns = true

config.colors = {
    quick_select_label_fg = { Color = '#ff0000' },
    quick_select_match_fg = { Color = '#aaaaaa' },
    scrollbar_thumb = '#aaaaaa',
}

config.enable_scroll_bar = true

-- and finally, return the configuration to wezterm
return config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/wez/wezterm/issues/4219#issuecomment-1697977950"&gt;https://github.com/wez/wezterm/issues/4219#issuecomment-1697977950&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>terminal</category>
      <category>wezterm</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
