powershell配置

powershell配置

0.结果展示


1.配置输出符号

function Prompt {
		$curdir = "$(Get-Location)".Split("\") | Select-Object -Last 1
		return "⚡" + $curdir + "💨"
}

先创建函数
函数中创建变量$curdir写入路径;路径由Split以“\”分割,只取最后一个,以设置简洁路径
返回

2.配置命令

rm -rf

function rmrf ($dir_path){
  Remove-Item -Recurse -Force $dir_path
}

mv

function mv($file_path, $des_name) {
  Move-Item -Path $file_path -Destination $des_name
}
function head($dir_path, $num){
		type $dir_path | Select -First $num
}

tail

function tail($dir_path, $num){
		type $dir_path | Select -Last $num
}

3.配置lsd

下载lsd

  1. scoop下载
    scoop install lsd
  2. 网页下载
    lsd:
    github:https://github.com/lsd-rs/lsd
    gitcode:https://gitcode.com/gh_mirrors/lsd/lsd/overview

配置lsd

function l{
		lsd.exe -l
}
function la{
		lsd.exe -a
}
function lla{
		lsd.exe -la
}
function lt{
		lsd.exe --tree
}

4.创建永久别名

# 更改别名
Remove-Item alias:ls
Set-Alias -Name ls -Value lsd.exe

5.更改文件编码

将配置文件另存为UTF-16LE编码保存

posted @ 2024-12-11 17:03  Loong-Loong  阅读(59)  评论(0)    收藏  举报