
I tried to make the scripts awk-agnostic, but I'm not sure whether I succeeded or not. By default, many Linux distributions use mawk as the included awk intepreter. A big thing to watch out for, the drive letters in your macros file need to be in the same case as they appear in /mnt. bashrc or similar where it will be evaluated using source filename: alias dir='ls -color=auto'Īnd that will replace all backslashes with forward, replace c:\ with /mnt/c/ and similar, and create functions using the massaged data. In the Linux side, you'd put the following in your. doskey /macrofile="path\to\macros.doskey" In the Windows side, you'd still source it the same. Take the following macros.doskey example: hi=echo Hello $*ĭesktop=pushd "c:\Users\username\desktop" & dir & popd With the second method, if you want to translate Windows filesystem paths into Linux notation, you can do so by adding a couple of gsub commands. Unfortunately, I haven't been able to find a solution using eval to define functions or aliases - I'm guessing because eval spawns a new shell that doesn't pass environment changes to the calling scope. It seems cmd is more accepting of Unix-style line terminations than bash is of Windows. Save this using a bash shell so that lines are terminated with LF only, not the Windows-style CRLF. I believe I've successfully created a batch + bash polyglot script. What I am think of doing this, Is there any good way to do it? Reg add "hkcu\software\microsoft\command processor" /v Autorun /t reg_sz /d %~dp0\gen_doskey.cmd /f read it and define "doskey in commands", and "alias in shell" (autoload-batch.bat)įOR /f "tokens=1,2,3* delims= " %%A IN (

"SET" "DIR_PROGRAM" "D:\OneDrive\_MyProgram"Ģ. define common definition text file (common-define.txt) Is there good way to do it or any related work about this?Įxample) 1. make a script that read "common definition file" and define "doskey in Commands", and "alias in Bash shell".
Windows alias for systemname how to#
Therefore, I'd like to know how to define common definitions which will work in both shell. What is really annoying me on this, I have to define alias for each shell (doskey & alias), even I am using same command & folder alias.Īlias np='D:_MyProgram_IDEditor\Notepad++\notepad++.exe'ĭoskey np=D:_MyProgram_IDEditor\Notepad++\notepad++.exe $*
Windows alias for systemname windows 10#
I am using "Window Command shell" and "Bash shell" in windows 10 OS.
