mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-13 03:09:10 +08:00
Merge pull request #855 from daxgames/profile.d_support
Added profile.d like support for all supported shells
This commit is contained in:
commit
33d6f11e87
10
README.md
10
README.md
@ -95,6 +95,16 @@ User specific configuration is possible using the cmder specific shell config fi
|
|||||||
|
|
||||||
Note: Bash and Mintty sessions will also source the '$HOME/.bashrc' file it it exists after it sources '$CMDER_ROOT/config/user-profile.sh'.
|
Note: Bash and Mintty sessions will also source the '$HOME/.bashrc' file it it exists after it sources '$CMDER_ROOT/config/user-profile.sh'.
|
||||||
|
|
||||||
|
### Linux like 'profile.d' support for all supported shell types.
|
||||||
|
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|
|
||||||
|
|
||||||
|
|
||||||
### Aliases
|
### Aliases
|
||||||
#### Cmder(Cmd.exe) 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`.
|
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`.
|
||||||
|
20
vendor/cmder.sh
vendored
20
vendor/cmder.sh
vendored
@ -35,6 +35,26 @@ PATH=${CMDER_ROOT}/bin:$PATH:${CMDER_ROOT}
|
|||||||
|
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
# Drop *.sh or *.zsh files into "${CMDER_ROOT}\config\profile.d"
|
||||||
|
# to source them at startup.
|
||||||
|
if [ ! -d "${CMDER_ROOT}/config/profile.d" ] ; then
|
||||||
|
mkdir -p ${CMDER_ROOT}/config/profile.d
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "${CMDER_ROOT}/config/profile.d" ] ; then
|
||||||
|
unset profile_d_scripts
|
||||||
|
pushd ${CMDER_ROOT}/config/profile.d >/dev/null
|
||||||
|
profile_d_scripts=$(ls ${CMDER_ROOT}/config/profile.d/*.sh) 2>/dev/null
|
||||||
|
|
||||||
|
if [ ! "x${profile_d_scripts}" = "x" ] ; then
|
||||||
|
for x in ${profile_d_scripts} ; do
|
||||||
|
# echo Sourcing "${x}"...
|
||||||
|
. $x
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
popd >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f ${CMDER_ROOT}/config/user-profile.sh ] ; then
|
if [ -f ${CMDER_ROOT}/config/user-profile.sh ] ; then
|
||||||
. ${CMDER_ROOT}/config/user-profile.sh
|
. ${CMDER_ROOT}/config/user-profile.sh
|
||||||
else
|
else
|
||||||
|
14
vendor/init.bat
vendored
14
vendor/init.bat
vendored
@ -88,6 +88,20 @@
|
|||||||
@cd /d "%CMDER_START%"
|
@cd /d "%CMDER_START%"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
:: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d"
|
||||||
|
:: to run them at startup.
|
||||||
|
@if not exist "%CMDER_ROOT%\config\profile.d" (
|
||||||
|
mkdir "%CMDER_ROOT%\config\profile.d"
|
||||||
|
}
|
||||||
|
|
||||||
|
@pushd "%CMDER_ROOT%\config\profile.d"
|
||||||
|
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd` ) do (
|
||||||
|
REM @echo Calling %CMDER_ROOT%\config\profile.d\%%x...
|
||||||
|
@call %%x
|
||||||
|
)
|
||||||
|
@popd
|
||||||
|
|
||||||
|
|
||||||
@if exist "%CMDER_ROOT%\config\user-profile.cmd" (
|
@if exist "%CMDER_ROOT%\config\user-profile.cmd" (
|
||||||
@rem create this file and place your own command in there
|
@rem create this file and place your own command in there
|
||||||
call "%CMDER_ROOT%\config\user-profile.cmd"
|
call "%CMDER_ROOT%\config\user-profile.cmd"
|
||||||
|
12
vendor/profile.ps1
vendored
12
vendor/profile.ps1
vendored
@ -91,6 +91,18 @@ if ( $ENV:CMDER_START ) {
|
|||||||
# Enhance Path
|
# Enhance Path
|
||||||
$env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
|
$env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
|
||||||
|
|
||||||
|
# Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d"
|
||||||
|
# to source them at startup.
|
||||||
|
if (-not (test-path "$ENV:CMDER_ROOT\config\profile.d")) {
|
||||||
|
mkdir "$ENV:CMDER_ROOT\config\profile.d"
|
||||||
|
}
|
||||||
|
|
||||||
|
pushd $ENV:CMDER_ROOT\config\profile.d
|
||||||
|
foreach ($x in ls *.ps1) {
|
||||||
|
# write-host Sourcing $ENV:CMDER_ROOT\config\profile.d\$x
|
||||||
|
. $x
|
||||||
|
}
|
||||||
|
|
||||||
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
||||||
if(Test-Path $CmderUserProfilePath) {
|
if(Test-Path $CmderUserProfilePath) {
|
||||||
# Create this file and place your own command in there.
|
# Create this file and place your own command in there.
|
||||||
|
Loading…
Reference in New Issue
Block a user