在 Powershell 中增加命令别名

打开 Powershell Profile 配置文件

1
code $PROFILE.CurrentUserAllHosts

which

1
2
3
4
5
Function Show-Full-Path {
    $(Get-Command $args[0]).Source;
}

Set-Alias -Name which -Value Show-Full-Path

grep

1
Set-Alias -Name grep -Value Select-String

rg

rg

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Latest releases

1
cargo install ripgrep
1
Set-Alias -Name grep -Value rg

find

findutils

findutils

Rust implementation of findutils

Install

1
cargo install findutils

fd

fd

A simple, fast and user-friendly alternative to ‘find’

Install

1
cargo install fd-find
1
winget install sharkdp.fd
1
Set-Alias -Name find -Value fd

tree

erd

erd

A modern, multi-threaded file-tree visualization and disk usage analysis tool that respects hidden file and gitignore rules.

1
cargo install erdtree
1
Set-Alias -Name tree -Value erd

ls

lsd

lsd

The next gen ls command

1
cargo install lsd
1
Set-Alias -Name ls -Value lsd

dig

dog

dog

A command-line DNS client.

1
cargo install --git https://github.com/ogham/dog.git dog
1
Set-Alias -Name dig -Value dog

coreutils

coreutils

uutils Coreutils Documentation

Cross-platform Rust rewrite of the GNU coreutils

1
cargo install coreutils
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#  [, arch, b2sum, b3sum, base32, base64, basename, basenc, cat, cksum, comm, cp, csplit, cut,
#  date, dd, df, dir, dircolors, dirname, du, echo, env, expand, expr, factor, false, fmt,
#  fold, hashsum, head, hostname, join, link, ln, ls, md5sum, mkdir, mktemp, more, mv, nl,
#  nproc, numfmt, od, paste, pr, printenv, printf, ptx, pwd, readlink, realpath, relpath, rm,
#  rmdir, seq, sha1sum, sha224sum, sha256sum, sha3-224sum, sha3-256sum, sha3-384sum, sha3-
#  512sum, sha384sum, sha3sum, sha512sum, shake128sum, shake256sum, shred, shuf, sleep, sort,
#  split, sum, sync, tac, tail, tee, test, touch, tr, true, truncate, tsort, uname, unexpand,
#  uniq, unlink, vdir, wc, whoami, yes

Set-Location $(Split-Path -Path $(Get-Command coreutils).Source)

$comands=$(coreutils --list)

foreach ($e in $comands) {
    # enumerate over the whole array
    New-Item -Path ("${e}" + ".exe") -ItemType SymbolicLink -Value coreutils.exe
}

Licensed under CC BY-NC-SA 4.0
Sunday, April 23, 2023