Skip to content

Instantly share code, notes, and snippets.

@HUGHNew
Last active March 24, 2024 09:23
Show Gist options
  • Save HUGHNew/15015bc03bec742c025b2b92f2e0e094 to your computer and use it in GitHub Desktop.
Save HUGHNew/15015bc03bec742c025b2b92f2e0e094 to your computer and use it in GitHub Desktop.
profile for PowerShell(detail in link: https://hughnew.github.io/feeds/blogs/Friendly-PowerShell.html)
# Set-ExecutionPolicy RemoteSigned # enable script exec
#------------------------ Import BEGIN ---------------------------#
Import-Module PSReadLine # Install-Module -Name PSReadLine
# to know more: https://github.com/PowerShell/PSReadLine/blob/master/README.md
#------------------------------- Set Hot-keys BEGIN -------------------------------
# 设置 Tab 键补全
# Set-PSReadlineKeyHandler -Key Tab -Function Complete
# 命令行使用 Emacs 模式 (与Bash一致)
Set-PSReadLineOption -EditMode Emacs
# 每次回溯输入历史,光标定位于输入内容末尾
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
# 设置 Tab 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete
# 设置 Ctrl+d 为退出 PowerShell
Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit
# 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
# 设置 Ctrl+t 创建新窗口
# Set-PSReadLineKeyHandler -Key "Ctrl+t" -Function
# 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
# 设置向下键为前向搜索历史纪录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
#------------------------------- Set Hot-keys END -------------------------
#------------------------------- Set Profile BEGIN -------------------------
Import-Module oh-my-posh
# Set-PoshPrompt -Theme slimfat
Set-PoshPrompt -Theme LambdaLike
#------------------------------- Set Profile END -------------------------
#------------------------------- Functions BEGIN -------------------------------
function proxy {
git config --global http.proxy socks5://127.0.0.1:7890
git config --global https.proxy socks5://127.0.0.1:7890
echo "set git proxy"
}
function unproxy {
git config --global --unset http.proxy
git config --global --unset https.proxy
echo "unset git proxy"
}
function update { # for scoop
sproxy
scoop update
unproxy
}
#------------------------------- Functions END -------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment