Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added profile.d like support for all supported shells #855

Merged
merged 5 commits into from
Feb 29, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'.

### 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
#### 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`.
Expand Down
13 changes: 13 additions & 0 deletions vendor/cmder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ PATH=${CMDER_ROOT}/bin:$PATH:${CMDER_ROOT}

export PATH

# Drop *.sh files into "%CMDER_ROOT%\config\profile.d"
# to run them at startup.
if [ ! -d ${CMDER_ROOT}/config/profile.d ] ; then
mkdir -p "${CMDER_ROOT}/config/profile.d"
fi

pushd ${CMDER_ROOT}/config/profile.d >/dev/null
for x in $(ls ${CMDER_ROOT}/config/profile.d/*.sh) ; do
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix this - Do not merge.

# echo ${x}
. $x
done
popd >/dev/null

if [ -f ${CMDER_ROOT}/config/user-profile.sh ] ; then
. ${CMDER_ROOT}/config/user-profile.sh
else
Expand Down
14 changes: 14 additions & 0 deletions vendor/init.bat
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@
@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" (
@rem create this file and place your own command in there
call "%CMDER_ROOT%\config\user-profile.cmd"
Expand Down
12 changes: 12 additions & 0 deletions vendor/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ if ( $ENV:CMDER_START ) {
# Enhance Path
$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"
if(Test-Path $CmderUserProfilePath) {
# Create this file and place your own command in there.
Expand Down