mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
commit
67f35bc05d
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,7 +8,7 @@ vendor/*/*
|
||||
!vendor/bin/*
|
||||
!vendor/lib/*
|
||||
!vendor/*
|
||||
!vendor/psmodules/PsGet
|
||||
!vendor/psmodules/*
|
||||
|
||||
config/*
|
||||
!config/Readme.md
|
||||
|
11
CHANGELOG.md
11
CHANGELOG.md
@ -2,10 +2,18 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.3.13](https://github.com/cmderdev/cmder/tree/v1.3.12) (2019-10-27)
|
||||
## [1.3.13](https://github.com/cmderdev/cmder/tree/v1.3.12) (2019-11-03)
|
||||
|
||||
### Adds
|
||||
|
||||
* #2197, #1364, #447 Add ability to disable git status either globally or for individual repos.
|
||||
* To disable git status globally add the following to `~/.gitconfig` or locally for a single repo `[repo]/.git/config`:
|
||||
|
||||
```
|
||||
[cmder]
|
||||
status = false
|
||||
```
|
||||
|
||||
* #2174 `--` Syntax to pass command line options to Conemu.
|
||||
* Disable Clink Logging
|
||||
* Add `~` tab completion.
|
||||
@ -13,6 +21,7 @@
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix #2191: profile.ps1: CheckGit does not export $gitLoaded
|
||||
* Fix #2192: Set default prompt hooks before loading user profile
|
||||
* Fix #2097, #1899: powershell foreground color changing to green
|
||||
* Fix #1979: Update Clink Completions to 0.3.4
|
||||
|
13
README.md
13
README.md
@ -171,11 +171,22 @@ Note: Bash and Mintty sessions will also source the `$HOME/.bashrc` file if it e
|
||||
You can write `*.cmd|*.bat`, `*.ps1`, and `*.sh` scripts and just drop them in the `%CMDER_ROOT%\config\profile.d` folder to add startup config to Cmder.
|
||||
|
||||
| Shell | Cmder `Profile.d` Scripts |
|
||||
| ------------- | --------------------------------------------------|
|
||||
| ------------- | -------------------------------------------------- |
|
||||
| Cmder | `%CMDER_ROOT%\config\profile.d\*.bat and *.cmd` |
|
||||
| PowerShell | `$ENV:CMDER_ROOT\config\profile.d\*.ps1` |
|
||||
| Bash/Mintty | `$CMDER_ROOT/config/profile.d/*.sh` |
|
||||
|
||||
#### Git Status Opt-Out
|
||||
|
||||
To disable Cmder prompt git status globally add the following to `~/.gitconfig` or locally for a single repo `[repo]/.git/config` and start a new session.
|
||||
|
||||
*Note: This configuration is not portable*
|
||||
|
||||
```
|
||||
[cmder]
|
||||
status = false
|
||||
```
|
||||
|
||||
### Aliases
|
||||
#### Cmder(`Cmd.exe`) Aliases
|
||||
You can define simple aliases for `cmd.exe` sessions with a command like `alias name=command`. Cmd.exe aliases support optional parameters through the `$1-9` or the `$*` special characters so the alias `vi=vim.exe $*` typed as `vi [filename]` will open `[filename]` in `vim.exe`.
|
||||
|
21
vendor/clink.lua
vendored
21
vendor/clink.lua
vendored
@ -280,6 +280,24 @@ local function get_svn_status()
|
||||
return true
|
||||
end
|
||||
|
||||
---
|
||||
-- Get the status of working dir
|
||||
-- @return {bool}
|
||||
---
|
||||
local function get_git_status_setting()
|
||||
gitStatusSetting = io.popen("git config cmder.status")
|
||||
|
||||
for line in gitStatusSetting:lines() do
|
||||
if string.match(line, 'false') then
|
||||
gitStatusSetting:close()
|
||||
return false
|
||||
end
|
||||
end
|
||||
gitStatusSetting:close()
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function git_prompt_filter()
|
||||
|
||||
-- Colors for git status
|
||||
@ -290,6 +308,8 @@ local function git_prompt_filter()
|
||||
}
|
||||
|
||||
local git_dir = get_git_dir()
|
||||
|
||||
if get_git_status_setting() then
|
||||
if git_dir then
|
||||
-- if we're inside of git repo then try to detect current branch
|
||||
local branch = get_git_branch(git_dir)
|
||||
@ -312,6 +332,7 @@ local function git_prompt_filter()
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- No git present or not in git file
|
||||
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", "")
|
||||
|
17
vendor/git-prompt.sh
vendored
17
vendor/git-prompt.sh
vendored
@ -1,3 +1,14 @@
|
||||
function getGitStatusSetting() {
|
||||
gitStatusSetting=$(git config cmder.status 2>/dev/null)
|
||||
|
||||
if [[ -n ${gitStatusSetting} ]] && [[ ${gitStatusSetting} == false ]]
|
||||
then
|
||||
echo false
|
||||
else
|
||||
echo true
|
||||
fi
|
||||
}
|
||||
|
||||
if test -f /etc/profile.d/git-sdk.sh
|
||||
then
|
||||
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
|
||||
@ -7,7 +18,10 @@ fi
|
||||
|
||||
if test -f ~/.config/git/git-prompt.sh
|
||||
then
|
||||
if [[ $(getGitStatusSetting) == true ]]
|
||||
then
|
||||
. ~/.config/git/git-prompt.sh
|
||||
fi
|
||||
else
|
||||
PS1='\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]' # set window title
|
||||
# PS1="$PS1"'\n' # new line
|
||||
@ -26,11 +40,14 @@ else
|
||||
if test -f "$COMPLETION_PATH/git-prompt.sh"
|
||||
then
|
||||
. "$COMPLETION_PATH/git-completion.bash"
|
||||
if [[ $(getGitStatusSetting) == true ]]
|
||||
then
|
||||
. "$COMPLETION_PATH/git-prompt.sh"
|
||||
PS1="$PS1"'\[\033[36m\]' # change color to cyan
|
||||
PS1="$PS1"'`__git_ps1`' # bash function
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
PS1="$PS1"'\[\033[0m\]' # change color
|
||||
PS1="$PS1"'\n' # new line
|
||||
PS1="$PS1"'λ ' # prompt: always λ
|
||||
|
49
vendor/profile.ps1
vendored
49
vendor/profile.ps1
vendored
@ -32,53 +32,13 @@ $moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorActi
|
||||
# Add Cmder modules directory to the autoload path.
|
||||
$CmderModulePath = Join-path $PSScriptRoot "psmodules/"
|
||||
|
||||
$CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1"
|
||||
. $CmderFunctions
|
||||
|
||||
if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderModulePath) ){
|
||||
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;")
|
||||
}
|
||||
|
||||
function Configure-Git($GIT_INSTALL_ROOT){
|
||||
$env:Path += $(";" + $GIT_INSTALL_ROOT + "\cmd")
|
||||
|
||||
# Add "$GIT_INSTALL_ROOT\usr\bin" to the path if exists and not done already
|
||||
$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"
|
||||
}
|
||||
|
||||
# Add "$GIT_INSTALL_ROOT\mingw[32|64]\bin" to the path if exists and not done already
|
||||
if ((test-path "$GIT_INSTALL_ROOT\mingw32\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw32\\bin")) {
|
||||
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw32\bin"
|
||||
} elseif ((test-path "$GIT_INSTALL_ROOT\mingw64\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw64\\bin")) {
|
||||
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw64\bin"
|
||||
}
|
||||
}
|
||||
|
||||
$gitLoaded = $false
|
||||
function Import-Git($Loaded){
|
||||
if($Loaded) { return }
|
||||
$GitModule = Get-Module -Name Posh-Git -ListAvailable
|
||||
if($GitModule | select version | where version -le ([version]"0.6.1.20160330")){
|
||||
Import-Module Posh-Git > $null
|
||||
}
|
||||
if(-not ($GitModule) ) {
|
||||
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder."
|
||||
}
|
||||
# Make sure we only run once by alawys returning true
|
||||
return $true
|
||||
}
|
||||
|
||||
function checkGit($Path) {
|
||||
if (Test-Path -Path (Join-Path $Path '.git') ) {
|
||||
$gitLoaded = Import-Git $gitLoaded
|
||||
Write-VcsStatus
|
||||
return
|
||||
}
|
||||
$SplitPath = split-path $path
|
||||
if ($SplitPath) {
|
||||
checkGit($SplitPath)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
# Check if git is on PATH, i.e. Git already installed on system
|
||||
Get-command -Name "git" -ErrorAction Stop >$null
|
||||
@ -97,6 +57,7 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
||||
}
|
||||
|
||||
# Pre assign default prompt hooks so the first run of cmder gets a working prompt.
|
||||
$env:gitLoaded = $false
|
||||
[ScriptBlock]$PrePrompt = {}
|
||||
[ScriptBlock]$PostPrompt = {}
|
||||
[ScriptBlock]$CmderPrompt = {
|
||||
@ -106,6 +67,7 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
||||
if (get-command git -erroraction silentlycontinue) {
|
||||
checkGit($pwd.ProviderPath)
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray"
|
||||
}
|
||||
|
||||
# Enhance Path
|
||||
@ -195,7 +157,6 @@ if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
|
||||
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
|
||||
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
CmderPrompt
|
||||
Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray"
|
||||
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
||||
return " "
|
||||
|
56
vendor/psmodules/Cmder.ps1
vendored
Normal file
56
vendor/psmodules/Cmder.ps1
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
function Configure-Git($GIT_INSTALL_ROOT){
|
||||
$env:Path += $(";" + $GIT_INSTALL_ROOT + "\cmd")
|
||||
|
||||
# Add "$GIT_INSTALL_ROOT\usr\bin" to the path if exists and not done already
|
||||
$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"
|
||||
}
|
||||
|
||||
# Add "$GIT_INSTALL_ROOT\mingw[32|64]\bin" to the path if exists and not done already
|
||||
if ((test-path "$GIT_INSTALL_ROOT\mingw32\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw32\\bin")) {
|
||||
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw32\bin"
|
||||
} elseif ((test-path "$GIT_INSTALL_ROOT\mingw64\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw64\\bin")) {
|
||||
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw64\bin"
|
||||
}
|
||||
}
|
||||
|
||||
function Import-Git(){
|
||||
$GitModule = Get-Module -Name Posh-Git -ListAvailable
|
||||
if($GitModule | select version | where version -le ([version]"0.6.1.20160330")){
|
||||
Import-Module Posh-Git > $null
|
||||
}
|
||||
if(-not ($GitModule) ) {
|
||||
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder."
|
||||
}
|
||||
# Make sure we only run once by alawys returning true
|
||||
return $true
|
||||
}
|
||||
|
||||
function checkGit($Path) {
|
||||
if (Test-Path -Path (Join-Path $Path '.git') ) {
|
||||
if($env:gitLoaded -eq 'false') {
|
||||
$env:gitLoaded = Import-Git
|
||||
}
|
||||
|
||||
if (getGitStatusSetting -eq $true) {
|
||||
Write-VcsStatus
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
$SplitPath = split-path $path
|
||||
if ($SplitPath) {
|
||||
checkGit($SplitPath)
|
||||
}
|
||||
}
|
||||
|
||||
function getGitStatusSetting() {
|
||||
$gitStatus = (git config cmder.status) | out-string
|
||||
|
||||
if (($gitStatus -replace "`n" -replace "`r") -eq "false") {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user