在 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
18
19
20
21
22
23
24
#  [, 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 = "[", "arch", "b2sum", "b3sum", "base32", "base64", "basename", "basenc", "cksum", "comm", "csplit", "cut"
$comands += "date", "dd", "df", "dir", "dircolors", "dirname", "du", "echo", "env", "expand", "expr", "factor", "false", "fmt"
$comands += "fold", "hashsum", "head", "hostname", "join", "link", "ln", "ls", "md5sum", "mkdir", "mktemp", "more", "mv", "nl"
$comands += "nproc", "numfmt", "od", "paste", "pr", "printenv", "printf", "ptx", "pwd", "readlink", "realpath", "relpath", "rm"
$comands += "rmdir", "seq", "sha1sum", "sha224sum", "sha256sum", "sha3-224sum", "sha3-256sum", "sha3-384sum", "sha3-512sum"
$comands += "sha384sum", "sha3sum", "sha512sum", "shake128sum", "shake256sum", "shred", "shuf", "sleep", "sort"
$comands += "split", "sum", "sync", "tac", "tail", "tee", "test", "touch", "tr", "true", "truncate", "tsort", "uname", "unexpand"
$comands += "uniq", "unlink", "vdir", "wc", "whoami", "yes"

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
最后更新于 Apr 23, 2023 19:21 +0800
使用 Hugo 构建
主题 StackJimmy 设计