Skip to content

Commit

Permalink
fixed - not running user-aliases.cmd if aliases variable is overridde…
Browse files Browse the repository at this point in the history
…n in profile.d
  • Loading branch information
Dax T. Games committed Mar 21, 2016
1 parent d5a1ce6 commit 86dd077
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions vendor/init.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" (
if not exist "%CMDER_ROOT%\config\settings" (
echo Generating clink initial settings in %CMDER_ROOT%\config\settings
echo Additional *.lua files in %CMDER_ROOT%\config are loaded on startup.
)
)

:: Run clink
"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
Expand Down Expand Up @@ -77,28 +77,26 @@ popd
:: Allows user to override default aliases store using profile.d
:: scripts run above. Note: If overriding default aliases file
:: in profile.d the aliases must also be loaded in profile.d.
set user-aliases=%CMDER_ROOT%\config\user-aliases.cmd
if not defined aliases (
set aliases=%CMDER_ROOT%\config\user-aliases.cmd
set aliases=%user-aliases%
)

:: make sure we have an example file
if not exist "%user-aliases%" (
echo Creating intial user-aliases store in "%user-aliases%"...
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
)

:: Using default cmder user-aliases.cmd store.
if "%aliases%" == "%CMDER_ROOT%\config\user-aliases.cmd" (
:: make sure we have an example file
if not exist "%aliases%" (
echo Creating intial aliases in "%aliases%"...
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%aliases%"
)

:: Update old 'aliases' to new self executing 'user-aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" (
echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
type "%CMDER_ROOT%\config\aliases" >> "%aliases%" && del "%CMDER_ROOT%\config\aliases"
)

:: Add aliases to the environment
call "%aliases%"
:: Update old 'user-aliases' to new self executing 'user-aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" (
echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
type "%CMDER_ROOT%\config\aliases" >> "%user-aliases%" && del "%CMDER_ROOT%\config\aliases"
)

:: Add aliases to the environment
call "%user-aliases%"

:: See vendor\git-for-windows\README.portable for why we do this
:: Basically we need to execute this post-install.bat because we are
:: manually extracting the archive rather than executing the 7z sfx
Expand Down

7 comments on commit 86dd077

@Stanzilla
Copy link
Member

Choose a reason for hiding this comment

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

@daxgames After this it errors for every user alias in the user file:

Enhancing PATH with unix commands from git [C:\Users\Benjamin\AppData\Local\Atlassian\SourceTree\git_local]
'e.' is not recognized as an internal or external command,
operable program or batch file.
'gl' is not recognized as an internal or external command,
operable program or batch file.
ls: cannot access '=ls': No such file or directory
ls: cannot access '$*': No such file or directory
pwd: ignoring non-option arguments
/c/Users/Benjamin

'history' is not recognized as an internal or external command,
operable program or batch file.
'unalias' is not recognized as an internal or external command,
operable program or batch file.

@daxgames
Copy link
Member

Choose a reason for hiding this comment

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

What changed? This was merged over a month ago and this is the first I have heard over it. Works great for me.

@daxgames
Copy link
Member

Choose a reason for hiding this comment

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

What does your user-aliases.cmd look like?

@Stanzilla
Copy link
Member

Choose a reason for hiding this comment

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

@daxgames yeah I never updated 📦

e.=explorer .
gl=git log --oneline --all --decorate  $*
ls=ls --show-control-chars -F --color $*
pwd=cd
clear=cls
history=cat "%CMDER_ROOT%\config\.history"
unalias=alias /d $1

@daxgames
Copy link
Member

Choose a reason for hiding this comment

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

The init.bat SHOULD have updated the old 'aliases' file format to the new self executing format. I don't know why it did not.

You need to add the below to the top of the 'user-aliases.cmd' file:

;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here

@Stanzilla
Copy link
Member

@Stanzilla Stanzilla commented on 86dd077 May 7, 2016

Choose a reason for hiding this comment

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

@daxgames Then that part is not working, I just tried it again

Enhancing PATH with unix commands from git in "C:\Users\Benjamin\AppData\Local\Atlassian\SourceTree\git_local\usr\bin"
Updating old "C:\Users\Benjamin\Dropbox\cmder\config\aliases" to new format...
'e.' is not recognized as an internal or external command,
operable program or batch file.
'gl' is not recognized as an internal or external command,
operable program or batch file.
ls: cannot access '=ls': No such file or directory
ls: cannot access '$*': No such file or directory
pwd: ignoring non-option arguments
/c/Users/Benjamin

'history' is not recognized as an internal or external command,
operable program or batch file.
'unalias' is not recognized as an internal or external command,
operable program or batch file.
'e.' is not recognized as an internal or external command,
operable program or batch file.
'gl' is not recognized as an internal or external command,
operable program or batch file.
ls: cannot access '=ls': No such file or directory
ls: cannot access '$*': No such file or directory
pwd: ignoring non-option arguments
/c/Users/Benjamin

'history' is not recognized as an internal or external command,
operable program or batch file.
'unalias' is not recognized as an internal or external command,
operable program or batch file.

and the user-aliases.cmd had the same content as the old aliases file with the part missing from your last comment. When I add that, it works.

@daxgames
Copy link
Member

Choose a reason for hiding this comment

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

It works if there is an aliases file and other is not a user-aliases.and file. If the user-aliases.cmd exists and has the same content as the old aliases file then the upgrade of the old file may not happen. I may need to revisit the update logic.

Please sign in to comment.