From 788b5262b4d71e1643f328a5eb84912453844b2a Mon Sep 17 00:00:00 2001 From: Jan Schulz Date: Sat, 9 Jan 2016 12:43:52 +0100 Subject: [PATCH] Reorganize how clink settings are loaded 4bfdf04d59dab80e1ce76d7125c546006273e188 moved all clink config files to vendor/ and therefore the files in config/ were not used and .history was also moved to vendor/. The new arrangement uses `--script` to load our own clink.lua file which in turn as the first thing loads the original clink.lua file. The user defined files are again in config/. As clink regenerates these files, if they are not present, this also means that we don't need to include the settings file in the git repo and therefore don't overwrite it on updates. --- config/settings | 43 --------------------------------- vendor/{cmder.lua => clink.lua} | 17 ++++++------- vendor/init.bat | 8 +++++- 3 files changed, 15 insertions(+), 53 deletions(-) delete mode 100644 config/settings rename vendor/{cmder.lua => clink.lua} (92%) diff --git a/config/settings b/config/settings deleted file mode 100644 index ea1bd7e..0000000 --- a/config/settings +++ /dev/null @@ -1,43 +0,0 @@ -# name: Ctrl-D exits -# type: bool -# Ctrl-D exits the process when it is pressed on an empty line. -ctrld_exits = 1 - -# name: Ctrl-C raises exception -# type: bool -# When Ctrl-C is pressed Clink will pass it thourgh to the parent by raising the -# appropriate exception. -passthrough_ctrlc = 1 - -# name: Esc clears line -# type: bool -# Clink clears the current line when Esc is pressed (unless Readline's Vi mode -# is enabled). -esc_clears_line = 1 - -# name: Match display colour -# type: int -# Colour to use when displaying matches. A value less than 0 will be the -# opposite brightness of the default colour. -match_colour = -1 - -# name: Executable match style -# type: enum -# Changes how Clink will match executables when there is no path separator on -# the line. 0 = PATH only, 1 = PATH and CWD, 2 = PATH, CWD, and directories. In -# all cases both executables and directories are matched when there is a path -# separator present. -exec_match_style = 2 - -# name: Prompt colour -# type: int -# Surrounds the prompt in ANSI escape codes to set the prompt's colour. Disabled -# when the value is less than 0. -prompt_colour = -1 - -# name: Auto-answer terminate prompt -# type: enum -# Automatically answers cmd.exe's 'Terminate batch job (Y/N)?' prompts. 0 = -# disabled, 1 = answer 'Y', 2 = answer 'N'. -terminate_autoanswer = 0 - diff --git a/vendor/cmder.lua b/vendor/clink.lua similarity index 92% rename from vendor/cmder.lua rename to vendor/clink.lua index 0579050..f993702 100644 --- a/vendor/cmder.lua +++ b/vendor/clink.lua @@ -1,3 +1,11 @@ +-- At first, load the original clink.lua file +-- this is needed as we set the script path to this dir and therefore the original +-- clink.lua is not loaded. +local clink_lua_file = clink.get_env('CMDER_ROOT')..'\\vendor\\clink\\clink.lua' +dofile(clink_lua_file) + +-- now add our own things... + function lambda_prompt_filter() clink.prompt.value = string.gsub(clink.prompt.value, "{lamb}", "λ") end @@ -190,12 +198,3 @@ for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do end end --- now do the same for all lua files in config which do not start with '_' -local user_config_dir = clink.get_env('CMDER_ROOT')..'\\config\\' -for _,lua_module in ipairs(clink.find_files(user_config_dir..'*.lua')) do - -- Skip files that starts with _. This could be useful if some files should be ignored - if not string.match(lua_module, '^_.*') then - local filename = user_config_dir..lua_module - dofile(filename) - end -end diff --git a/vendor/init.bat b/vendor/init.bat index ffb4881..89e27c0 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -23,8 +23,14 @@ set architecture=64 ) +:: Tell the user about the clink config files... +@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%\vendor" +@"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor" :: Prepare for git-for-windows