diff options
author | Douman <douman@gmx.se> | 2017-03-31 16:52:52 +0300 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2017-04-09 08:32:23 -0400 |
commit | 9456d95e8f8f170593a68675ca27ee7010ed045a (patch) | |
tree | d9ca2d4436c5b260edb0fc38c3bf3cb05a018455 | |
parent | 0c298f60a68ed9c98192adaa23f1f517366ce336 (diff) |
Add short note on Windows Tips
-rw-r--r-- | README.md | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -378,6 +378,51 @@ $ cargo test from the repository root. +### Tips + +#### Windows Powershell + +##### Powershell Profile + +To customize powershell on start-up there is a special powershell script that has to be created. +In order to find its location run command `Get-Command $profile | Select-Object -ExpandProperty Definition` +See [more](https://technet.microsoft.com/en-us/library/bb613488(v=vs.85).aspx) for profile details. + +Any powershell code in this file gets evaluated at the start of console. +This way you can have own aliases to be created at start. + +##### Setup function alias + +Often you can find a need to make alias for the favourite utility. + +But powershell function aliases do not behave like your typical linux shell alias. + +You always need to propagate arguments and **Stdin** input. +But it cannot be done simply as `function grep() { $input | rg.exe --hidden $args }` + +Use below example as reference to how setup alias in powershell. + +```powershell +function grep { + $count = @($input).Count + $input.Reset() + + if ($count) { + $input | rg.exe --hidden $args + } + else { + rg.exe --hidden $args + } +} +``` + +Powershell special variables: +* input - is powershell **Stdin** object that allows you to access its content. +* args - is array of arguments passed to this function. + +This alias checks whether there is **Stdin** input and propagates only if there is some lines. +Otherwise empty `$input` will make powershell to trigger `rg` to search empty **Stdin** + ### Known issues #### I just hit Ctrl+C in the middle of ripgrep's output and now my terminal's foreground color is wrong! |