mirror of
https://github.com/cmderdev/cmder.git
synced 2025-02-10 23:49:07 +08:00
make powershell use of bash commands more bash like
This commit is contained in:
parent
b424012a08
commit
13de4924ca
50
vendor/profile.ps1
vendored
50
vendor/profile.ps1
vendored
@ -36,26 +36,21 @@ if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderMod
|
|||||||
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;")
|
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
function Configure-Git($GIT_INSTALL_ROOT){
|
||||||
Get-command -Name "vim" -ErrorAction Stop >$null
|
$env:Path += $(";" + $GIT_INSTALL_ROOT + "\cmd")
|
||||||
} catch {
|
|
||||||
# # You could do this but it may be a little drastic and introduce a lot of
|
|
||||||
# # unix tool overlap with powershel unix like aliases
|
|
||||||
# $env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\usr\bin")
|
|
||||||
# set-alias -name "vi" -value "vim"
|
|
||||||
# # I think the below is safer.
|
|
||||||
|
|
||||||
new-alias -name "vim" -value $($ENV:CMDER_ROOT + "\vendor\git-for-windows\usr\bin\vim.exe")
|
# Add "$GIT_INSTALL_ROOT\usr\bin" to the path if exists and not done already
|
||||||
new-alias -name "vi" -value vim
|
$GIT_INSTALL_ROOT_ESC=$GIT_INSTALL_ROOT.replace('\','\\')
|
||||||
}
|
if ((test-path "$GIT_INSTALL_ROOT\usr\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\usr\\bin")) {
|
||||||
|
$env:path = "$env:path;$GIT_INSTALL_ROOT\usr\bin"
|
||||||
try {
|
}
|
||||||
# Check if git is on PATH, i.e. Git already installed on system
|
|
||||||
Get-command -Name "git" -ErrorAction Stop >$null
|
# Add "$GIT_INSTALL_ROOT\mingw[32|64]\bin" to the path if exists and not done already
|
||||||
} catch {
|
if ((test-path "$GIT_INSTALL_ROOT\mingw32\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw32\\bin")) {
|
||||||
$env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\cmd")
|
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw32\bin"
|
||||||
# for bash.exe, which in the cmd version is found as <GIT>\usr\bin\bash.exe
|
} elseif ((test-path "$GIT_INSTALL_ROOT\mingw64\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw64\\bin")) {
|
||||||
$env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\bin")
|
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw64\bin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$gitLoaded = $false
|
$gitLoaded = $false
|
||||||
@ -84,6 +79,19 @@ function checkGit($Path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Check if git is on PATH, i.e. Git already installed on system
|
||||||
|
Get-command -Name "git" -ErrorAction Stop >$null
|
||||||
|
} catch {
|
||||||
|
if (test-path "$env:CMDER_ROOT\vendor\git-for-windows") {
|
||||||
|
Configure-Git "$env:CMDER_ROOT\vendor\git-for-windows"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( Get-command -Name "vim" -ErrorAction silentlycontinue) {
|
||||||
|
new-alias -name "vi" -value vim
|
||||||
|
}
|
||||||
|
|
||||||
if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
||||||
Set-PSReadlineOption -ExtraPromptLineCount 1
|
Set-PSReadlineOption -ExtraPromptLineCount 1
|
||||||
}
|
}
|
||||||
@ -170,7 +178,9 @@ if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
|
|||||||
[ScriptBlock]$CmderPrompt = {
|
[ScriptBlock]$CmderPrompt = {
|
||||||
$Host.UI.RawUI.ForegroundColor = "White"
|
$Host.UI.RawUI.ForegroundColor = "White"
|
||||||
Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
||||||
checkGit($pwd.ProviderPath)
|
if (get-command git -erroraction silentlycontinue) {
|
||||||
|
checkGit($pwd.ProviderPath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
17
vendor/user_profile.ps1.default
vendored
17
vendor/user_profile.ps1.default
vendored
@ -23,3 +23,20 @@
|
|||||||
|
|
||||||
## <Continue to add your own>
|
## <Continue to add your own>
|
||||||
|
|
||||||
|
# Delete default powershell aliases that conflict with bash commands
|
||||||
|
# If you prefer the powershell aliases remove this.
|
||||||
|
if (get-command git) {
|
||||||
|
del -force alias:cat
|
||||||
|
del -force alias:clear
|
||||||
|
del -force alias:cp
|
||||||
|
del -force alias:diff
|
||||||
|
del -force alias:echo
|
||||||
|
del -force alias:kill
|
||||||
|
del -force alias:ls
|
||||||
|
del -force alias:mv
|
||||||
|
del -force alias:ps
|
||||||
|
del -force alias:pwd
|
||||||
|
del -force alias:rm
|
||||||
|
del -force alias:sleep
|
||||||
|
del -force alias:tee
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user