Merge pull request #2199 from daxgames/git_opt_out

Git opt out
This commit is contained in:
Dax T Games 2019-11-09 17:03:07 -05:00 committed by GitHub
commit 67f35bc05d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 151 additions and 76 deletions

2
.gitignore vendored
View File

@ -8,7 +8,7 @@ vendor/*/*
!vendor/bin/*
!vendor/lib/*
!vendor/*
!vendor/psmodules/PsGet
!vendor/psmodules/*
config/*
!config/Readme.md

View File

@ -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

View File

@ -92,8 +92,8 @@ _(Some shortcuts are not yet documented, though they exist - please document the
### Access to multiple shells in one window using tabs
You can open multiple tabs each containing one of the following shells:
| Task | Shell | Description |
| ---- | ----- | ----------- |
| Task | Shell | Description |
| ---- | ----- | ----------- |
| Cmder | `cmd.exe` | Windows `cmd.exe` shell enhanced with Git, Git aware prompt, Clink (GNU Readline), and Aliases. |
| Cmder as Admin | `cmd.exe` | Administrative Windows `cmd.exe` Cmder shell. |
| PowerShell | `powershell.exe` | Windows PowerShell enhanced with Git and Git aware prompt . |
@ -164,17 +164,28 @@ Single user portable configuration is possible using the cmder specific shell co
| ------------- | ----------------------------------------- |
| Cmder | `%CMDER_ROOT%\config\user_profile.cmd` |
| PowerShell | `$ENV:CMDER_ROOT\config\user_profile.ps1` |
| Bash/Mintty | `$CMDER_ROOT/config/user_profile.sh` |
| Bash/Mintty | `$CMDER_ROOT/config/user_profile.sh` |
Note: Bash and Mintty sessions will also source the `$HOME/.bashrc` file if it exists after it sources `$CMDER_ROOT/config/user_profile.sh`.
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` |
| 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

57
vendor/clink.lua vendored
View File

@ -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,27 +308,30 @@ local function git_prompt_filter()
}
local git_dir = get_git_dir()
if git_dir then
-- if we're inside of git repo then try to detect current branch
local branch = get_git_branch(git_dir)
local color
if branch then
-- Has branch => therefore it is a git folder, now figure out status
local gitStatus = get_git_status()
local gitConflict = get_git_conflict()
color = colors.dirty
if gitStatus then
color = colors.clean
end
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)
local color
if branch then
-- Has branch => therefore it is a git folder, now figure out status
local gitStatus = get_git_status()
local gitConflict = get_git_conflict()
if gitConflict then
color = colors.conflict
end
color = colors.dirty
if gitStatus then
color = colors.clean
end
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")")
return false
end
if gitConflict then
color = colors.conflict
end
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")")
return false
end
end
end
-- No git present or not in git file

25
vendor/git-prompt.sh vendored
View File

@ -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
. ~/.config/git/git-prompt.sh
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,9 +40,12 @@ else
if test -f "$COMPLETION_PATH/git-prompt.sh"
then
. "$COMPLETION_PATH/git-completion.bash"
. "$COMPLETION_PATH/git-prompt.sh"
PS1="$PS1"'\[\033[36m\]' # change color to cyan
PS1="$PS1"'`__git_ps1`' # bash function
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

49
vendor/profile.ps1 vendored
View File

@ -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
View 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
}
}