mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-10 16:29:08 +08:00
Use default files for default user profiles
This commit is contained in:
parent
ab02c4ce46
commit
0c9e0e2f8c
@ -4,11 +4,12 @@ All config files must be in this folder. If there is no option to set this folde
|
|||||||
directly, it has to be hardlinked.
|
directly, it has to be hardlinked.
|
||||||
|
|
||||||
* `user-aliases.cmd`: aliases in cmd; called from vendor\init.bat; autocreated from
|
* `user-aliases.cmd`: aliases in cmd; called from vendor\init.bat; autocreated from
|
||||||
`vendor\user-aliases.cmd.example`.
|
`vendor\user-aliases.cmd.default`.
|
||||||
* `*.lua`: clink completions and prompt filters; autoloaded after all
|
* `*.lua`: clink completions and prompt filters; autoloaded after all
|
||||||
prompt filter and clink completions are initialized; add your own.
|
prompt filter and clink completions are initialized; add your own.
|
||||||
* `user-profile.{sh|cmd|ps1}`: startup files for bash|cmd|powershell tasks; called from their
|
* `user-profile.{sh|cmd|ps1}`: startup files for bash|cmd|powershell tasks; called from their
|
||||||
respective startup scripts in `vendor\`; autocreated on first start of such a task.
|
respective startup scripts in `vendor\`; autocreated from
|
||||||
|
`vendor\user-profile.{sh|cmd|ps1}.default` on first start of such a task.
|
||||||
* `.history`: the current commandline history; autoupdated on close.
|
* `.history`: the current commandline history; autoupdated on close.
|
||||||
* `settings`: settings for readline; overwritten on update.
|
* `settings`: settings for readline; overwritten on update.
|
||||||
* `ConEmu.xml`: settings from ConEmu (=the UI of cmder -> Preferences); overwritten on update.
|
* `ConEmu.xml`: settings from ConEmu (=the UI of cmder -> Preferences); overwritten on update.
|
||||||
|
7
vendor/cmder.sh
vendored
7
vendor/cmder.sh
vendored
@ -90,12 +90,7 @@ fi
|
|||||||
|
|
||||||
if [ ! -f "${CmderUserProfilePath}" ] ; then
|
if [ ! -f "${CmderUserProfilePath}" ] ; then
|
||||||
echo Creating user startup file: "${CmderUserProfilePath}"
|
echo Creating user startup file: "${CmderUserProfilePath}"
|
||||||
cat <<-eof >"${CmderUserProfilePath}"
|
cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${CmderUserProfilePath}"
|
||||||
# use this file to run your own startup commands for msys2 bash'
|
|
||||||
|
|
||||||
# To add a new vendor to the path, do something like:
|
|
||||||
# export PATH=\${CMDER_ROOT}/vendor/whatever:\${PATH}
|
|
||||||
eof
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source the users .bashrc file if it exists
|
# Source the users .bashrc file if it exists
|
||||||
|
7
vendor/cmder_exinit
vendored
7
vendor/cmder_exinit
vendored
@ -108,11 +108,6 @@ if [ ! "$CMDER_ROOT" = "" ] ; then
|
|||||||
|
|
||||||
if [ ! -f "${CmderUserProfilePath}" ] ; then
|
if [ ! -f "${CmderUserProfilePath}" ] ; then
|
||||||
echo Creating user startup file: "${CmderUserProfilePath}"
|
echo Creating user startup file: "${CmderUserProfilePath}"
|
||||||
cat <<-eof >"${CmderUserProfilePath}"
|
cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${CmderUserProfilePath}"
|
||||||
# use this file to run your own startup commands for msys2 bash'
|
|
||||||
|
|
||||||
# To add a new vendor to the path, do something like:
|
|
||||||
# export PATH=\${CMDER_ROOT}/vendor/whatever:\${PATH}
|
|
||||||
eof
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
30
vendor/init.bat
vendored
30
vendor/init.bat
vendored
@ -284,7 +284,7 @@ if defined CMDER_USER_CONFIG (
|
|||||||
:: scripts run above by setting the 'aliases' env variable.
|
:: scripts run above by setting the 'aliases' env variable.
|
||||||
::
|
::
|
||||||
:: Note: If overriding default aliases store file the aliases
|
:: Note: If overriding default aliases store file the aliases
|
||||||
:: must also be self executing, see '.\user_aliases.cmd.example',
|
:: must also be self executing, see '.\user_aliases.cmd.default',
|
||||||
:: and be in profile.d folder.
|
:: and be in profile.d folder.
|
||||||
if not defined user_aliases (
|
if not defined user_aliases (
|
||||||
if defined CMDER_USER_CONFIG (
|
if defined CMDER_USER_CONFIG (
|
||||||
@ -305,17 +305,17 @@ if "%CMDER_ALIASES%" == "1" (
|
|||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
if not exist "%user_aliases%" (
|
if not exist "%user_aliases%" (
|
||||||
echo Creating initial user_aliases store in "%user_aliases%"...
|
echo Creating initial user_aliases store in "%user_aliases%"...
|
||||||
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_aliases%"
|
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%"
|
||||||
) else (
|
) else (
|
||||||
type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
|
type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
|
||||||
if "!errorlevel!" == "1" (
|
if "!errorlevel!" == "1" (
|
||||||
echo Creating initial user_aliases store in "%user_aliases%"...
|
echo Creating initial user_aliases store in "%user_aliases%"...
|
||||||
if defined CMDER_USER_CONFIG (
|
if defined CMDER_USER_CONFIG (
|
||||||
copy "%user_aliases%" "%user_aliases%.old_format"
|
copy "%user_aliases%" "%user_aliases%.old_format"
|
||||||
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_aliases%"
|
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%"
|
||||||
) else (
|
) else (
|
||||||
copy "%user_aliases%" "%user_aliases%.old_format"
|
copy "%user_aliases%" "%user_aliases%.old_format"
|
||||||
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_aliases%"
|
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -368,27 +368,7 @@ if defined CMDER_USER_CONFIG (
|
|||||||
|
|
||||||
if not exist "%initialConfig%" (
|
if not exist "%initialConfig%" (
|
||||||
echo Creating user startup file: "%initialConfig%"
|
echo Creating user startup file: "%initialConfig%"
|
||||||
(
|
copy "%CMDER_ROOT%\vendor\user_profile.cmd.default" "%initialConfig%"
|
||||||
echo :: use this file to run your own startup commands
|
|
||||||
echo :: use in front of the command to prevent printing the command
|
|
||||||
echo.
|
|
||||||
echo :: uncomment this to have the ssh agent load when cmder starts
|
|
||||||
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
|
|
||||||
echo.
|
|
||||||
echo :: uncomment the next two lines to use pageant as the ssh authentication agent
|
|
||||||
echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
|
|
||||||
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
|
|
||||||
echo.
|
|
||||||
echo :: you can add your plugins to the cmder path like so
|
|
||||||
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
|
|
||||||
echo.
|
|
||||||
echo :: arguments in this batch are passed from init.bat, you can quickly parse them like so:
|
|
||||||
echo :: more useage can be seen by typing "cexec /?"
|
|
||||||
echo.
|
|
||||||
echo :: %%ccall%% "/customOption" "command/program"
|
|
||||||
echo.
|
|
||||||
echo @echo off
|
|
||||||
) >"%initialConfig%"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMDER_ROOT%\vendor\bin\alias.cmd" (
|
if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMDER_ROOT%\vendor\bin\alias.cmd" (
|
||||||
|
35
vendor/profile.ps1
vendored
35
vendor/profile.ps1
vendored
@ -181,41 +181,8 @@ if ($ENV:CMDER_USER_CONFIG) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! (Test-Path $CmderUserProfilePath) ) {
|
if (! (Test-Path $CmderUserProfilePath) ) {
|
||||||
# This multiline string cannot be indented, for this reason I've not indented the whole block
|
|
||||||
|
|
||||||
Write-Host -BackgroundColor Darkgreen -ForegroundColor White "First Run: Creating user startup file: $CmderUserProfilePath"
|
Write-Host -BackgroundColor Darkgreen -ForegroundColor White "First Run: Creating user startup file: $CmderUserProfilePath"
|
||||||
|
Copy-Item "$env:CMDER_ROOT\vendor\user_profile.ps1.default" -Destination $CmderUserProfilePath
|
||||||
$UserProfileTemplate = @'
|
|
||||||
# Use this file to run your own startup commands
|
|
||||||
|
|
||||||
## Prompt Customization
|
|
||||||
<#
|
|
||||||
.SYNTAX
|
|
||||||
<PrePrompt><CMDER DEFAULT>
|
|
||||||
λ <PostPrompt> <repl input>
|
|
||||||
.EXAMPLE
|
|
||||||
<PrePrompt>N:\Documents\src\cmder [master]
|
|
||||||
λ <PostPrompt> |
|
|
||||||
#>
|
|
||||||
|
|
||||||
[ScriptBlock]$PrePrompt = {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Replace the cmder prompt entirely with this.
|
|
||||||
# [ScriptBlock]$CmderPrompt = {}
|
|
||||||
|
|
||||||
[ScriptBlock]$PostPrompt = {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
## <Continue to add your own>
|
|
||||||
|
|
||||||
|
|
||||||
'@
|
|
||||||
|
|
||||||
New-Item -ItemType File -Path $CmderUserProfilePath -Value $UserProfileTemplate > $null
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Once Created these code blocks cannot be overwritten
|
# Once Created these code blocks cannot be overwritten
|
||||||
|
19
vendor/user_profile.cmd.default
vendored
Normal file
19
vendor/user_profile.cmd.default
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
:: use this file to run your own startup commands
|
||||||
|
:: use in front of the command to prevent printing the command
|
||||||
|
|
||||||
|
:: uncomment this to have the ssh agent load when cmder starts
|
||||||
|
:: call "%GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd"
|
||||||
|
|
||||||
|
:: uncomment the next two lines to use pageant as the ssh authentication agent
|
||||||
|
:: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
|
||||||
|
:: call "%GIT_INSTALL_ROOT%/cmd/start-ssh-pageant.cmd"
|
||||||
|
|
||||||
|
:: you can add your plugins to the cmder path like so
|
||||||
|
:: set "PATH=%CMDER_ROOT%\vendor\whatever;%PATH%"
|
||||||
|
|
||||||
|
:: arguments in this batch are passed from init.bat, you can quickly parse them like so:
|
||||||
|
:: more useage can be seen by typing "cexec /?"
|
||||||
|
|
||||||
|
:: %ccall% "/customOption" "command/program"
|
||||||
|
|
||||||
|
@echo off
|
25
vendor/user_profile.ps1.default
vendored
Normal file
25
vendor/user_profile.ps1.default
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Use this file to run your own startup commands
|
||||||
|
|
||||||
|
## Prompt Customization
|
||||||
|
<#
|
||||||
|
.SYNTAX
|
||||||
|
<PrePrompt><CMDER DEFAULT>
|
||||||
|
λ <PostPrompt> <repl input>
|
||||||
|
.EXAMPLE
|
||||||
|
<PrePrompt>N:\Documents\src\cmder [master]
|
||||||
|
λ <PostPrompt> |
|
||||||
|
#>
|
||||||
|
|
||||||
|
[ScriptBlock]$PrePrompt = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Replace the cmder prompt entirely with this.
|
||||||
|
# [ScriptBlock]$CmderPrompt = {}
|
||||||
|
|
||||||
|
[ScriptBlock]$PostPrompt = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
## <Continue to add your own>
|
||||||
|
|
32
vendor/user_profile.sh.default
vendored
Normal file
32
vendor/user_profile.sh.default
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# use this file to run your own startup commands for msys2 bash'
|
||||||
|
|
||||||
|
# To add a new vendor to the path, do something like:
|
||||||
|
# export PATH=${CMDER_ROOT}/vendor/whatever:${PATH}
|
||||||
|
|
||||||
|
function launch_ssh_agent {
|
||||||
|
# Copied from (https://help.github.com/articles/working-with-ssh-key-passphrases)
|
||||||
|
env=~/.ssh/agent.env
|
||||||
|
|
||||||
|
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
|
||||||
|
|
||||||
|
agent_start () {
|
||||||
|
(umask 077; ssh-agent >| "$env")
|
||||||
|
. "$env" >| /dev/null ; }
|
||||||
|
|
||||||
|
agent_load_env
|
||||||
|
|
||||||
|
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
|
||||||
|
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
|
||||||
|
|
||||||
|
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
|
||||||
|
agent_start
|
||||||
|
ssh-add
|
||||||
|
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
|
||||||
|
ssh-add
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset env
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run ssh-agent automatically when you open your first bash terminal
|
||||||
|
# launch_ssh_agent
|
Loading…
Reference in New Issue
Block a user