|
1 | | -@echo off |
2 | | - |
3 | | -set lib_base=call "%~dp0lib_base.cmd" |
4 | | - |
5 | | -if "%~1" == "/h" ( |
6 | | - %lib_base% help "%~0" |
7 | | -) else if "%~1" neq "" ( |
8 | | - call :%* |
9 | | -) |
10 | | - |
11 | | -exit /b |
12 | | - |
13 | | -:::=============================================================================== |
14 | | -:::help - shows all sub routines in a .bat/.cmd file with documentation |
15 | | -:::. |
16 | | -:::include: |
17 | | -:::. |
18 | | -::: call "lib_base.cmd" |
19 | | -:::. |
20 | | -:::usage: |
21 | | -:::. |
22 | | -::: %lib_base% help "file" |
23 | | -:::. |
24 | | -:::options: |
25 | | -:::. |
26 | | -::: file <in> full path to file containing lib_routines to display |
27 | | -:::------------------------------------------------------------------------------- |
28 | | - |
29 | | -:help |
30 | | - for /f "tokens=* delims=:" %%a in ('%WINDIR%\System32\findstr /i /r "^:::" "%~1"') do ( |
31 | | - if "%%a"=="." ( |
32 | | - echo. |
33 | | - ) else if /i "%%a" == "usage" ( |
34 | | - echo %%a: |
35 | | - ) else if /i "%%a" == "options" ( |
36 | | - echo %%a: |
37 | | - ) else if not "%%a" == "" ( |
38 | | - echo %%a |
39 | | - ) |
40 | | - ) |
41 | | - |
42 | | - pause |
43 | | - exit /b |
44 | | - |
45 | | -:::=============================================================================== |
46 | | -:::cmder_shell - Initializes the Cmder shell environment variables |
47 | | -:::. |
48 | | -:::description: |
49 | | -:::. |
50 | | -::: This routine sets up the Cmder shell environment by detecting the |
51 | | -::: command shell and initializing related variables. |
52 | | -:::. |
53 | | -:::include: |
54 | | -:::. |
55 | | -::: call "lib_base.cmd" |
56 | | -:::. |
57 | | -:::usage: |
58 | | -:::. |
59 | | -::: %lib_base% cmder_shell |
60 | | -:::------------------------------------------------------------------------------- |
61 | | - |
62 | | -:cmder_shell |
63 | | - call :detect_comspec %ComSpec% |
64 | | - exit /b |
65 | | - |
66 | | -:::=============================================================================== |
67 | | -:::detect_comspec - Detects the command shell being used::: |
68 | | -:::. |
69 | | -:::description: |
70 | | -:::. |
71 | | -::: This function sets the CMDER_SHELL variable to the name of the |
72 | | -::: detected command shell. It also initializes the CMDER_CLINK and |
73 | | -::: CMDER_ALIASES variables if they are not already defined. |
74 | | -:::. |
75 | | -:::include: |
76 | | -:::. |
77 | | -::: call "lib_base.cmd" |
78 | | -:::. |
79 | | -:::usage: |
80 | | -:::. |
81 | | -::: %lib_base% detect_comspec %ComSpec% |
82 | | -:::------------------------------------------------------------------------------- |
83 | | - |
84 | | -:detect_comspec |
85 | | - set CMDER_SHELL=%~n1 |
86 | | - if not defined CMDER_CLINK ( |
87 | | - set CMDER_CLINK=1 |
88 | | - ) |
89 | | - if not defined CMDER_ALIASES ( |
90 | | - set CMDER_ALIASES=1 |
91 | | - ) |
92 | | - exit /b |
93 | | - |
94 | | -:::=============================================================================== |
95 | | -:::update_legacy_aliases - Updates the legacy alias definitions in the user_aliases file |
96 | | -:::. |
97 | | -:::description: |
98 | | -:::. |
99 | | -::: This function checks if the user_aliases file contains the marker |
100 | | -::: ";= Add aliases below here". If the marker is not found, it creates |
101 | | -::: an initial user_aliases store by copying the default user_aliases file |
102 | | -::: from the CMDER_ROOT directory. If the CMDER_USER_CONFIG environment |
103 | | -::: variable is defined, it creates a backup of the existing user_aliases |
104 | | -::: file before copying the default file. |
105 | | -:::. |
106 | | -:::include: |
107 | | -:::. |
108 | | -::: call "lib_base.cmd" |
109 | | -:::. |
110 | | -:::usage: |
111 | | -:::. |
112 | | -::: %lib_base% update_legacy_aliases |
113 | | -:::------------------------------------------------------------------------------- |
114 | | - |
115 | | -:update_legacy_aliases |
116 | | - type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul |
117 | | - if "%errorlevel%" == "1" ( |
118 | | - echo Creating initial user_aliases store in "%user_aliases%"... |
119 | | - if defined CMDER_USER_CONFIG ( |
120 | | - copy "%user_aliases%" "%user_aliases%.old_format" |
121 | | - copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" |
122 | | - ) else ( |
123 | | - copy "%user_aliases%" "%user_aliases%.old_format" |
124 | | - copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" |
125 | | - ) |
126 | | - ) |
127 | | - exit /b |
| 1 | +@echo off |
| 2 | + |
| 3 | +set lib_base=call "%~dp0lib_base.cmd" |
| 4 | + |
| 5 | +if "%~1" == "/h" ( |
| 6 | + %lib_base% help "%~0" |
| 7 | +) else if "%~1" neq "" ( |
| 8 | + call :%* |
| 9 | +) |
| 10 | + |
| 11 | +exit /b |
| 12 | + |
| 13 | +:::=============================================================================== |
| 14 | +:::help - shows all sub routines in a .bat/.cmd file with documentation |
| 15 | +:::. |
| 16 | +:::include: |
| 17 | +:::. |
| 18 | +::: call "lib_base.cmd" |
| 19 | +:::. |
| 20 | +:::usage: |
| 21 | +:::. |
| 22 | +::: %lib_base% help "file" |
| 23 | +:::. |
| 24 | +:::options: |
| 25 | +:::. |
| 26 | +::: file <in> full path to file containing lib_routines to display |
| 27 | +:::------------------------------------------------------------------------------- |
| 28 | + |
| 29 | +:help |
| 30 | + for /f "tokens=* delims=:" %%a in ('%WINDIR%\System32\findstr /i /r "^:::" "%~1"') do ( |
| 31 | + if "%%a"=="." ( |
| 32 | + echo. |
| 33 | + ) else if /i "%%a" == "usage" ( |
| 34 | + echo %%a: |
| 35 | + ) else if /i "%%a" == "options" ( |
| 36 | + echo %%a: |
| 37 | + ) else if not "%%a" == "" ( |
| 38 | + echo %%a |
| 39 | + ) |
| 40 | + ) |
| 41 | + |
| 42 | + pause |
| 43 | + exit /b |
| 44 | + |
| 45 | +:::=============================================================================== |
| 46 | +:::cmder_shell - Initializes the Cmder shell environment variables |
| 47 | +:::. |
| 48 | +:::description: |
| 49 | +:::. |
| 50 | +::: This routine sets up the Cmder shell environment by detecting the |
| 51 | +::: command shell and initializing related variables. |
| 52 | +:::. |
| 53 | +:::include: |
| 54 | +:::. |
| 55 | +::: call "lib_base.cmd" |
| 56 | +:::. |
| 57 | +:::usage: |
| 58 | +:::. |
| 59 | +::: %lib_base% cmder_shell |
| 60 | +:::------------------------------------------------------------------------------- |
| 61 | + |
| 62 | +:cmder_shell |
| 63 | + call :detect_comspec %ComSpec% |
| 64 | + exit /b |
| 65 | + |
| 66 | +:::=============================================================================== |
| 67 | +:::detect_comspec - Detects the command shell being used::: |
| 68 | +:::. |
| 69 | +:::description: |
| 70 | +:::. |
| 71 | +::: This function sets the CMDER_SHELL variable to the name of the |
| 72 | +::: detected command shell. It also initializes the CMDER_CLINK and |
| 73 | +::: CMDER_ALIASES variables if they are not already defined. |
| 74 | +:::. |
| 75 | +:::include: |
| 76 | +:::. |
| 77 | +::: call "lib_base.cmd" |
| 78 | +:::. |
| 79 | +:::usage: |
| 80 | +:::. |
| 81 | +::: %lib_base% detect_comspec %ComSpec% |
| 82 | +:::------------------------------------------------------------------------------- |
| 83 | + |
| 84 | +:detect_comspec |
| 85 | + set CMDER_SHELL=%~n1 |
| 86 | + if not defined CMDER_CLINK ( |
| 87 | + set CMDER_CLINK=1 |
| 88 | + ) |
| 89 | + if not defined CMDER_ALIASES ( |
| 90 | + set CMDER_ALIASES=1 |
| 91 | + ) |
| 92 | + exit /b |
| 93 | + |
| 94 | +:::=============================================================================== |
| 95 | +:::update_legacy_aliases - Updates the legacy alias definitions in the user_aliases file |
| 96 | +:::. |
| 97 | +:::description: |
| 98 | +:::. |
| 99 | +::: This function checks if the user_aliases file contains the marker |
| 100 | +::: ";= Add aliases below here". If the marker is not found, it creates |
| 101 | +::: an initial user_aliases store by copying the default user_aliases file |
| 102 | +::: from the CMDER_ROOT directory. If the CMDER_USER_CONFIG environment |
| 103 | +::: variable is defined, it creates a backup of the existing user_aliases |
| 104 | +::: file before copying the default file. |
| 105 | +:::. |
| 106 | +:::include: |
| 107 | +:::. |
| 108 | +::: call "lib_base.cmd" |
| 109 | +:::. |
| 110 | +:::usage: |
| 111 | +:::. |
| 112 | +::: %lib_base% update_legacy_aliases |
| 113 | +:::------------------------------------------------------------------------------- |
| 114 | + |
| 115 | +:update_legacy_aliases |
| 116 | + type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul |
| 117 | + if "%errorlevel%" == "1" ( |
| 118 | + echo Creating initial user_aliases store in "%user_aliases%"... |
| 119 | + if defined CMDER_USER_CONFIG ( |
| 120 | + copy "%user_aliases%" "%user_aliases%.old_format" |
| 121 | + copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" |
| 122 | + ) else ( |
| 123 | + copy "%user_aliases%" "%user_aliases%.old_format" |
| 124 | + copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" |
| 125 | + ) |
| 126 | + ) |
| 127 | + exit /b |
0 commit comments