Custom common alias(example and difference) to auto sync across local and remote SSH hosts plus docker containers like:
- Local = Windows or Linux/MacOS/FreeBSD:
- Remote = Linux/MacOS/FreeBSD via SSH connection.
- Remote = Docker Containers in Linux/MacOS/FreeBSD.
- First time:
- Open user settings (hotkey =
F1
or"Ctrl + Shift + P"
). - Choose
"Open User Settings"
to open vscode settings. - Choose common alias type:
msr
.commonAliasNameBodyList for all platforms (Windows + MinGW/Cygwin + Linux/MacOS/FreeBSD).msr
.cmd.commonAliasNameBodyList
for Windows only.msr
.bash.commonAliasNameBodyList
for MinGW/Cygwin + Linux/MacOS/FreeBSD.
- Click
"Edit in settings.json"
.
- Open user settings (hotkey =
- After first time:
- Choose
"Open User Settings (JSON)"
to directly opensettings.json
to addaliasName
+aliasBody
.
- Choose
aliasName
is required: the name of the alias/doskey, see example below.- Recommend using long
aliasName
on Linux/MacOS/FreeBSD since it's easy to auto complete byTab
key.
- Recommend using long
aliasBody
is required: the command lines of batch or bash script.- Should not use single quote(
'
) inaliasBody
for Linux to avoid breakingalias function
.
- Should not use single quote(
description
is optional: you can write any words for the alias.
- Write script body (maybe multi-lines) in a temp file, or edit in alias file (e.g.
~/msr-cmd-alias.bashrc
). - Copy the pure content body to clipboard.
- Run to-alias-body to read clipboard and transform to one-line
aliasBody
JSON forsettings.json
.- Linux/MacOS/FreeBSD: install PowerShell if not exists (like
sudo apt install -y powershell
).
- Linux/MacOS/FreeBSD: install PowerShell if not exists (like
- Paste the JSON body to
aliasBody
insettings.json
.
vscode-msr will auto transform(create) normal alias/doskey based on aliasName
+ aliasBody
.
- Auto convert
aliasBody
forTab
/spaces
(see below) +return
/exit
(Linux alias functions + script files).- When editing/updating
aliasBody
: Free to copy from either alias function body or script file (then useto-alias-body
).
- When editing/updating
- Immediately effective for all
MSR-RUN-CMD
+ new terminals in all opened vscode (Windows + remote SSH/docker). - Immediately effective for new system terminals(Bash/CMD/etc.) on Windows + Linux/MacOS/FreeBSD of opened vscode.
- For old/opened terminals(system or vscode), run
use-this-alias
orupdate-alias
to effect immediately.
"msr.commonAliasNameBodyList": [
{
"aliasName": "gsf",
"aliasBody": "git --no-pager diff --name-only $1~1 $1",
"description": "Show file list of a git commit(change). The arg is the commit id. Example: gsf HEAD or gsf {commit-hash-id}."
}
]
vscode-msr will transform it to alias/doskey on Windows + Linux/MacOS/FreeBSD like below:
- Linux/MacOS/FreeBSD: Stored in alias file - default =
~/msr-cmd-alias.bashrc
with below content:
alias gsf='function _gsf() {
git --no-pager diff --name-only $1~1 $1
}; _gsf'
- Windows: Stored in alias file - default =
%USERPROFILE%\msr-cmd-alias.doskeys
with below content:
gsf=git --no-pager diff --name-only $1~1 $1
msr.replaceMultiLineAliasBodyTabTo
:- Replace
Tab
(\t
) to4 spaces
or2 spaces
for multi-line alias body insettings.json
. - Default =
4 spaces
.
- Replace
msr.replaceHeadSpacesToTabForToAliasBody
- Replace
4 spaces
or2 spaces
back toTab
(\t
) when calling to-alias-body.- Not only reduce
aliasBody
size insettings.json
but also make Tab-conversion reversible.
- Not only reduce
- Default =
true
.
- Replace
- Synchronization:
- Normal alias are only for current vscode on Windows or Linux/MacOS/FreeBSD.
- Custom common alias are auto synced across all vscode on Windows + Linux/MacOS/FreeBSD.
- Creating
aliasName
+aliasBody
is an once-for-all effort for current + future vscode/system-console.
- Creating
- Storage location:
- Custom common alias stored in
settings.json
. - Normal alias stored in alias files:
- Windows:
%USERPROFILE%\msr-cmd-alias.doskeys
. - Linux/MacOS/FreeBSD:
~/msr-cmd-alias.bashrc
plus~/.bashrc
.
- Windows:
- Custom common alias stored in
- Readability:
- Normal alias are readable and easy to edit.
- Custom common alias
aliasBody
which is one-line JSON need escape some chars (use to-alias-body to help transform).