diff --git a/config/Readme.md b/config/Readme.md index 5a72301..d123efc 100644 --- a/config/Readme.md +++ b/config/Readme.md @@ -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. * `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 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 - 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. * `settings`: settings for readline; overwritten on update. * `ConEmu.xml`: settings from ConEmu (=the UI of cmder -> Preferences); overwritten on update. diff --git a/vendor/cmder.sh b/vendor/cmder.sh index a0ab173..7ccddcf 100644 --- a/vendor/cmder.sh +++ b/vendor/cmder.sh @@ -90,12 +90,7 @@ fi if [ ! -f "${CmderUserProfilePath}" ] ; then echo Creating user startup file: "${CmderUserProfilePath}" - cat <<-eof >"${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 + cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${CmderUserProfilePath}" fi # Source the users .bashrc file if it exists diff --git a/vendor/cmder_exinit b/vendor/cmder_exinit index bab6f20..095a1e9 100644 --- a/vendor/cmder_exinit +++ b/vendor/cmder_exinit @@ -108,11 +108,6 @@ if [ ! "$CMDER_ROOT" = "" ] ; then if [ ! -f "${CmderUserProfilePath}" ] ; then echo Creating user startup file: "${CmderUserProfilePath}" - cat <<-eof >"${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 + cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${CmderUserProfilePath}" fi fi diff --git a/vendor/init.bat b/vendor/init.bat index 7430bcd..04f7900 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -298,7 +298,7 @@ if defined CMDER_USER_CONFIG ( :: scripts run above by setting the 'aliases' env variable. :: :: 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. if not defined user_aliases ( if defined CMDER_USER_CONFIG ( @@ -319,17 +319,17 @@ if "%CMDER_ALIASES%" == "1" ( setlocal enabledelayedexpansion if not exist "%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 ( type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul if "!errorlevel!" == "1" ( echo Creating initial user_aliases store in "%user_aliases%"... if defined CMDER_USER_CONFIG ( 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 ( 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%" ) ) ) @@ -382,27 +382,7 @@ if defined CMDER_USER_CONFIG ( if not exist "%initialConfig%" ( echo Creating user startup file: "%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%" + copy "%CMDER_ROOT%\vendor\user_profile.cmd.default" "%initialConfig%" ) if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMDER_ROOT%\vendor\bin\alias.cmd" ( diff --git a/vendor/lib/start-ssh-agent.sh b/vendor/lib/start-ssh-agent.sh new file mode 100644 index 0000000..a359ae0 --- /dev/null +++ b/vendor/lib/start-ssh-agent.sh @@ -0,0 +1,22 @@ +# 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 \ No newline at end of file diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index 159ebe2..73fde18 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -181,41 +181,8 @@ if ($ENV:CMDER_USER_CONFIG) { } 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" - -$UserProfileTemplate = @' -# Use this file to run your own startup commands - -## Prompt Customization -<# -.SYNTAX - - λ -.EXAMPLE - N:\Documents\src\cmder [master] - λ | -#> - -[ScriptBlock]$PrePrompt = { - -} - -# Replace the cmder prompt entirely with this. -# [ScriptBlock]$CmderPrompt = {} - -[ScriptBlock]$PostPrompt = { - -} - -## - - -'@ - -New-Item -ItemType File -Path $CmderUserProfilePath -Value $UserProfileTemplate > $null - + 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 } # Once Created these code blocks cannot be overwritten diff --git a/vendor/user_aliases.cmd.example b/vendor/user_aliases.cmd.default similarity index 100% rename from vendor/user_aliases.cmd.example rename to vendor/user_aliases.cmd.default diff --git a/vendor/user_profile.cmd.default b/vendor/user_profile.cmd.default new file mode 100644 index 0000000..aa5f4f8 --- /dev/null +++ b/vendor/user_profile.cmd.default @@ -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 \ No newline at end of file diff --git a/vendor/user_profile.ps1.default b/vendor/user_profile.ps1.default new file mode 100644 index 0000000..b85ebee --- /dev/null +++ b/vendor/user_profile.ps1.default @@ -0,0 +1,25 @@ +# Use this file to run your own startup commands + +## Prompt Customization +<# +.SYNTAX + + λ +.EXAMPLE + N:\Documents\src\cmder [master] + λ | +#> + +[ScriptBlock]$PrePrompt = { + +} + +# Replace the cmder prompt entirely with this. +# [ScriptBlock]$CmderPrompt = {} + +[ScriptBlock]$PostPrompt = { + +} + +## + diff --git a/vendor/user_profile.sh.default b/vendor/user_profile.sh.default new file mode 100644 index 0000000..4d55ecc --- /dev/null +++ b/vendor/user_profile.sh.default @@ -0,0 +1,7 @@ +# 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} + +# Uncomment this to have the ssh agent load with the first bash terminal +# . "${CMDER_ROOT}/vendor/lib/start-ssh-agent.sh" \ No newline at end of file