31 Mar 2024

Tab Auto Completion of History Commands for PowerShell

收藏到CSDN网摘

PowerShell has the capability of Tab auto completion. Moreover, it also remind you the last used parameters and commands in the history as grayed out text. However, Tab cannot auto-complete these grayed-out words - they are there as the reminder to guide your typing. There are two commands to run for enabling the tab completion on these parameters/commands.

Speed up Oh-My-Posh Cold Start

收藏到CSDN网摘

Oh-My-Posh is a beautiful cross-platform command line customisation tool that runs on windows, linux, and mac. I have set up it for my win11 laptop's Terminal (PowerShell) and WSL2 prompt. One day, I've noticed that it started incredibly slow (>20s). After browsing the internet for a while, a simple fix is to replace the existing one line code in my $PROFILE setting file. Here it is!

22 Oct 2023

Customise Mouse Keys (including side keys)

收藏到CSDN网摘

I purchased a mouse some time ago from Amazon. It features 2 additional side buttons in addition to the typical left-right-middle layout. I was pleasantly surprised to find that these side buttons functioned seamlessly while browsing webpages, serving as the backward/forward navigation controls in the browsing history. This convenience sufficed for most of my needs.

However, I required the side buttons to emulate the LEFT/RIGHT or UP/DOWN arrow keys to ensure smooth navigation within my HTML slide deck for teaching. This mouse is budget-friendly, and unfortunately, the manufacturer does not provide any driver or software support for customisation.

Fortunately, I came across a free software solution known as X-Mouse Button Control, which expertly resolved my issues. I have successfully tested it on a Windows 11 x64 system, and it has been reported to work on Windows 7 and Windows 10 as well. If you encounter a similar issue, it's certainly worth trying out this software.

24 Mar 2023

Matlab: Terminate Execution by emulating CTRL+C

收藏到CSDN网摘

This is a really usful trick for GUI development in Matlab. Although Matlab has some advanced methods such as Future object to run the process in background. But a simple method to mimic what the user does by pressing CTRL+C would be nice to have!

7 Mar 2023

Matlab: convert time duration to string

收藏到CSDN网摘

Matlab has its own tic/toc function to measure the running time a peice of code, which is very convenient and widely used by developers. The duration() function along with hours(), minutes(), and seconds() is another way of creating time durations explicitly. All of these duration types need to be converted to string format for displaying purpose. How can/should we convert them properly?

8 Dec 2022

Find All Opened Matlab Figures

收藏到CSDN网摘

Sometimes, Matlab is really good at plotting data for analysis or image processing. The simple figure() function can be used to create a new figure to plot on. Otherwise, it will plot directly on the last existing (or the current figure, which can be accessed via gcf function) figure. Moreover, the existing plotted data would be overwritten if you forgot to turn 'hold on' to preserve the current plots. So it's very common to always call figure() to get a new convas before plotting. However, this leads to another problem that you may get massive number of figures opened after a while using Matlab. I call it as Figure Explosion. To get rid of all open figures, one can simply type 'close all'. However, what if there are some figures you'd like to keep but you just cannot find them manually. How can we close some figures selectively based on there properties, e.g. names maybe? Here it is!