<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>terminal on Kevin Heruer</title><link>/tags/terminal/</link><description>Recent content in terminal on Kevin Heruer</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 24 Dec 2020 09:36:34 +0100</lastBuildDate><atom:link href="/tags/terminal/index.xml" rel="self" type="application/rss+xml"/><item><title>Running Spotify From a Terminal</title><link>/posts/2020/12/24/running-spotify-from-a-terminal/</link><pubDate>Thu, 24 Dec 2020 09:36:34 +0100</pubDate><guid>/posts/2020/12/24/running-spotify-from-a-terminal/</guid><description>This post exist of two different projects, the first one is Spotify-tui, and de second is Spotifyd.
Spotify-tui Spotify-tui is a terminal interface using the web API and is witten in the Rust language, however, it does not play the songs itself. It only uses the API to select/play a song, you&amp;rsquo;ll need another piece of the puzzle to actually play the music.
Since Spotify-tui is written in Rust it&amp;rsquo;s very memory efficient and safe, meaning it will never do unexpected things.</description><content>&lt;p>This post exist of two different projects, the first one is &lt;a href="https://github.com/Rigellute/spotify-tui">Spotify-tui&lt;/a>,
and de second is &lt;a href="https://github.com/Spotifyd/spotifyd">Spotifyd&lt;/a>.&lt;/p>
&lt;h2 id="spotify-tui">Spotify-tui&lt;/h2>
&lt;p>Spotify-tui is a terminal interface using the web API and is witten in the Rust language, however, it does not play
the songs itself. It only uses the API to select/play a song, you&amp;rsquo;ll need another piece of the puzzle to actually
play the music.&lt;/p>
&lt;p>Since Spotify-tui is written in Rust it&amp;rsquo;s very memory efficient and &lt;a href="https://doc.rust-lang.org/nomicon/meet-safe-and-unsafe.html">safe&lt;/a>,
meaning it will never do unexpected things. Running Spotify-tui it only uses 16MB of RAM and it has been running for 11+ hours.&lt;/p>
&lt;p>You may argue that 16MB of RAM is a lot, but in the world of applications and even command line applications running on JavaScript it&amp;rsquo;s a
godsend. Spotify itself is around 200MB.&lt;/p>
&lt;h2 id="spotifyd">Spotifyd&lt;/h2>
&lt;p>The other part of the puzzle is Spotifyd, a Spotify daemon written in Rust. It&amp;rsquo;s a tiny Spotify client using only around 8MB of RAM.
However, Spotifyd is not just specifically for Spotify-tui, it&amp;rsquo;s a generic daemon. You could also use your Spotify app and stream it
to the daemon using the device list in the app.&lt;/p>
&lt;p>This means you could create your own smart speaker for cheap! Or you could hook up a raspberry pi zero to your old sound system and
give your old system new streaming functionalities.&lt;/p></content></item><item><title>Tmux Shortcuts</title><link>/posts/2020/12/22/tmux-shortcuts/</link><pubDate>Tue, 22 Dec 2020 09:00:00 +0100</pubDate><guid>/posts/2020/12/22/tmux-shortcuts/</guid><description>As per my previous blog post, I&amp;rsquo;ve discovered Alacritty but it has no tab functionality. That&amp;rsquo;s why I started using Tmux more outside of server management. Locally I now have multiple sessions with multiple windows that (can) have multiple panes. I have two sessons running, my personal dev environment and one for work.
I also have a separate tmux window for Spotify-tui, I might make a blog post about that in the future with Spotifyd.</description><content>&lt;p>As per my previous blog post, I&amp;rsquo;ve discovered Alacritty but it has no tab functionality. That&amp;rsquo;s why
I started using Tmux more outside of server management. Locally I now have multiple sessions with
multiple windows that (can) have multiple panes. I have two sessons running, my personal dev environment
and one for work.&lt;/p>
&lt;p>I also have a separate tmux window for &lt;a href="https://github.com/Rigellute/spotify-tui">Spotify-tui&lt;/a>, I might
make a blog post about that in the future with &lt;a href="https://github.com/Spotifyd/spotifyd">Spotifyd&lt;/a>.&lt;/p>
&lt;p>Since I&amp;rsquo;m now actively using tmux I thought I&amp;rsquo;d post a great link to a cheatsheet: &lt;a href="https://tmuxcheatsheet.com/">https://tmuxcheatsheet.com/&lt;/a>&lt;/p>
&lt;p>I also always have a window open in tmux with the command &lt;code>tmux lsk -N|more&lt;/code> which I
can switch to whenever I need. My most used shortcuts at the moment are &lt;code>C-b + w&lt;/code> for changing windows, &lt;code>C-b + arrow key&lt;/code>
for changing panels, &lt;code>C-b + c&lt;/code> for creating a new window, and &lt;code>C-b + x&lt;/code> for closing a panel.
I also use &lt;code>C-b %&lt;/code> and &lt;code>C-b + &amp;quot;&lt;/code> for splitting a window/creating panels quite often.&lt;/p>
&lt;p>The full tmux lsk -N|more output:
&lt;div class="collapsable-code">
&lt;input id="645138279" type="checkbox" />
&lt;label for="645138279">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="△" data-label-collapse="▽">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
C-b C-b Send the prefix key
C-b C-o Rotate through the panes
C-b C-z Suspend the current client
C-b Space Select next layout
C-b ! Break pane to a new window
C-b &amp;#34; Split window vertically
C-b # List all paste buffers
C-b $ Rename current session
C-b % Split window horizontally
C-b &amp;amp; Kill current window
C-b &amp;#39; Prompt for window index to select
C-b ( Switch to previous client
C-b ) Switch to next client
C-b , Rename current window
C-b - Delete the most recent paste buffer
C-b . Move the current window
C-b / Describe key binding
C-b 0 Select window 0
C-b 1 Select window 1
C-b 2 Select window 2
C-b 3 Select window 3
C-b 4 Select window 4
C-b 5 Select window 5
C-b 6 Select window 6
C-b 7 Select window 7
C-b 8 Select window 8
C-b 9 Select window 9
C-b : Prompt for a command
C-b ; Move to the previously active pane
C-b = Choose a paste buffer from a list
C-b ? List key bindings
C-b D Choose a client from a list
C-b E Spread panes out evenly
C-b L Switch to the last client
C-b M Clear the marked pane
C-b [ Enter copy mode
C-b ] Paste the most recent paste buffer
C-b c Create a new window
C-b d Detach the current client
C-b f Search for a pane
C-b i Display window information
C-b l Select the previously current window
C-b m Toggle the marked pane
C-b n Select the next window
C-b o Select the next pane
C-b p Select the previous pane
C-b q Display pane numbers
C-b r Redraw the current client
C-b s Choose a session from a list
C-b t Show a clock
C-b w Choose a window from a list
C-b x Kill the active pane
C-b z Zoom the active pane
C-b { Swap the active pane with the pane above
C-b } Swap the active pane with the pane below
C-b ~ Show messages
C-b DC Reset so the visible part of the window follows the cursor
C-b PPage Enter copy mode and scroll up
C-b Up Select the pane above the active pane
C-b Down Select the pane below the active pane
C-b Left Select the pane to the left of the active pane
C-b Right Select the pane to the right of the active pane
C-b M-1 Set the even-horizontal layout
C-b M-2 Set the even-vertical layout
C-b M-3 Set the main-horizontal layout
C-b M-4 Set the main-vertical layout
C-b M-5 Select the tiled layout
C-b M-n Select the next window with an alert
C-b M-o Rotate through the panes in reverse
C-b M-p Select the previous window with an alert
C-b M-Up Resize the pane up by 5
C-b M-Down Resize the pane down by 5
C-b M-Left Resize the pane left by 5
C-b M-Right Resize the pane right by 5
C-b C-Up Resize the pane up
C-b C-Down Resize the pane down
C-b C-Left Resize the pane left
C-b C-Right Resize the pane right
C-b S-Up Move the visible part of the window up
C-b S-Down Move the visible part of the window down
C-b S-Left Move the visible part of the window left
C-b S-Right Move the visible part of the window right
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p></content></item><item><title>Alacritty</title><link>/posts/2020/12/21/alacritty/</link><pubDate>Mon, 21 Dec 2020 11:52:35 +0100</pubDate><guid>/posts/2020/12/21/alacritty/</guid><description>I&amp;rsquo;ve recently come across a new terminal emulator called Alacritty, it is a new terminal emulator written in Rust. It uses the GPU to accellerate the calculations it needs to make which results in a more responsive terminal, some commands like tree also seem to run faster.
Check out this video from DistroTube: The terminal emulator is still in beta and does not have any GUI to edit the settings, all settings need to be defined in a YAML config file.</description><content>&lt;p>I&amp;rsquo;ve recently come across a new terminal emulator called &lt;a href="https://github.com/alacritty/alacritty">Alacritty&lt;/a>, it is a new terminal emulator written in Rust.
It uses the GPU to accellerate the calculations it needs to make which results in a more responsive terminal,
some commands like tree also seem to run faster.&lt;/p>
&lt;p>Check out this video from DistroTube:
&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
&lt;iframe src="https://www.youtube.com/embed/PZPMvTvUf1Y" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" allowfullscreen title="YouTube Video">&lt;/iframe>
&lt;/div>
&lt;/p>
&lt;p>The terminal emulator is still in beta and does not have any GUI to edit the settings, all settings need to be
defined in a YAML config file. It also does not (yet) have tab funcionality, you&amp;rsquo;ll need to open a new window
every time you want another terminal. Of course you could use something like &lt;a href="https://github.com/tmux/tmux">tmux&lt;/a> to work around that problem.&lt;/p></content></item><item><title>Zsh Speedup</title><link>/posts/2020/12/17/zsh-speedup/</link><pubDate>Thu, 17 Dec 2020 09:16:54 +0100</pubDate><guid>/posts/2020/12/17/zsh-speedup/</guid><description>I&amp;rsquo;ve been experiencing some slowdowns in my shell lately, I could not explain why. But I am using Oh My Zsh, and after some searching I found a blog post by Matthew J. Clemente that has a complete walkthrough of how to diagnose and fix slow (Oh My Zsh) shells.
You start by measuring actual load times to set a base with a simple function you can put into your .</description><content>&lt;p>I&amp;rsquo;ve been experiencing some slowdowns in my shell lately, I could not explain why.
But I am using &lt;a href="https://github.com/ohmyzsh/ohmyzsh">Oh My Zsh&lt;/a>, and after some
searching I found a blog post by Matthew J. Clemente that has a complete walkthrough
of how to diagnose and fix slow (Oh My Zsh) shells.&lt;/p>
&lt;p>You start by measuring actual load times to set a base with a simple function you can
put into your .zshrc file:
&lt;div class="collapsable-code">
&lt;input id="936752814" type="checkbox" />
&lt;label for="936752814">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="△" data-label-collapse="▽">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
timezsh() {
shell=${1-$SHELL}
for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
}
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p>
&lt;p>Now you can run timezsh and see how long it takes for your shell to start up and be ready.
To figure out exactly which plugin is causing the slowdown you can run the following to
see how long it takes for each plugin to be loaded in:
&lt;div class="collapsable-code">
&lt;input id="372695814" type="checkbox" />
&lt;label for="372695814">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="△" data-label-collapse="▽">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
timer=$(($(gdate &amp;#43;%s%N)/1000000))
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
now=$(($(gdate &amp;#43;%s%N)/1000000))
elapsed=$(($now-$timer))
echo $elapsed&amp;#34;:&amp;#34; $plugin
done
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p>
&lt;p>In my case it was the kubectl plugin for Oh My Zsh, the fix was to use the given kubectl command
to load in the autocomplete:
&lt;div class="collapsable-code">
&lt;input id="762914385" type="checkbox" />
&lt;label for="762914385">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="△" data-label-collapse="▽">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
function kubectl() {
if ! type __start_kubectl &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then
source &amp;lt;(command kubectl completion zsh)
fi
command kubectl &amp;#34;$@&amp;#34;
}
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p>
&lt;p>Now I can remove the plugin and lazy load the kubectl command every time I start up a new shell
session.&lt;/p>
&lt;p>Sometimes you don&amp;rsquo;t need a plugin for things, take each plugin you install seriously and check if
you really need it. A slow shell is not great and a killer for productivity.&lt;/p>
&lt;p>Source: &lt;a href="https://blog.mattclemente.com/2020/06/26/oh-my-zsh-slow-to-load.html">https://blog.mattclemente.com/2020/06/26/oh-my-zsh-slow-to-load.html&lt;/a>&lt;/p></content></item></channel></rss>