Skip to content

Commit

Permalink
Update README and remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
codyduong committed Apr 11, 2024
1 parent d77640a commit e177ebc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ Install the module from the [PowerShell Gallery](https://www.powershellgallery.c
Install-Module alias-tips -AllowClobber
```

Inside your PowerShell profile
Inside your PowerShell profile, import alias-tips.

```powershell
Import-Module alias-tips
```

> [!IMPORTANT]
> alias-tips should be imported after all aliases declared
Everytime your aliases are updated run

```powershell
Expand All @@ -69,14 +72,17 @@ This will store a hash of all aliased commands to: `$HOME/.alias_tips.hash` . It
| ALIASTIPS_DEBUG | `$false` | Enable to show debug messages when processing commands |
| ALIASTIPS_HASH_PATH | `[System.IO.Path]::Combine("$HOME", '.alias_tips.hash')` | File Path to store results from `Find-AliasTips` |
| ALIASTIPS_MSG | `"Alias tip: {0}"` | Alias hint message for non-virtual terminals |
| ALIASTIPS_MSG_VT | `` `e[033mAlias tip: {0}`em" `` | Alias hint message for virtual terminals |
| ALIASTIPS_MSG_VT | `` `e[033mAlias tip: {0}`em" `` | Alias hint message for virtual terminals* |
| ALIASTIPS_FUNCTION_INTROSPECTION | `$false` | **POTENTIALLY DESTRUCTIVE** [Function Alias Introspection](#function-alias-introspection) |

\* This uses [ANSI Escape Codes](https://en.wikipedia.org/wiki/ANSI_escape_code), for a [table of colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors).
This also means alias-tips supports any other virtual terminal features: blinking/bold/underline/italics.

## How Does This Work

It will attempt to read all functions/aliases set in the current context.

### Example Interactions
### Example Interactions/Limitations

#### Alias
```powershell
Expand All @@ -90,6 +96,8 @@ function grbi {
git rebase -i $args
}
```
> [!NOTE]
> This has a limitation in that alias-tips does not know in this case that -i is equivalent to the --interactive flag.
#### Function Alias Introspection

Expand All @@ -101,12 +109,15 @@ function gcm {
}
```

This is potentially destructive behavior, as it requires running `Get-Git-MainBranch` (in this example)
to attempt to parse `$MainBranch` and is disabled by default. It is also currently in a limited parsing stage.
It does not attempt to parse line-by-line, instead performing a backwards search, and is naive in its
implementation.
> [!WARNING]
> This is potentially destructive behavior
This requires backparsing as it requires running `Get-Git-MainBranch` (in this example) to get the value of `$MainBranch`.
This backparsing **could be** a destructive command is not known to alias-tips, and it will run anyways. (ie. rm, git add, etc.)

As a result this behavior is disabled by default.

Set `$env:ALIASTIPS_FUNCTION_INTROSPECTION` to `$true` to enable it
Set `$env:ALIASTIPS_FUNCTION_INTROSPECTION` to `$true` to enable it.

## License

Expand Down
8 changes: 0 additions & 8 deletions alias-tips/Public/Find-Alias.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ function Find-Alias {
$tokens = @()
$ast = [System.Management.Automation.Language.Parser]::ParseInput($Line, [ref]$tokens, [ref]$null)

$fastAlias = Find-AliasCommand ($tokens.Text -join " ")

# fastAlias is not appreciably faster but is definetly less stable, disable for now?
# if (-not [string]::IsNullOrEmpty($fastAlias)) {
# Write-Verbose "Found alias without resorting to parsing"
# return $fastAlias
# }

$queue = [System.Collections.ArrayList]::new()
$extents = @(0, 0)
$offset = 0
Expand Down

0 comments on commit e177ebc

Please sign in to comment.