mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-01-09 22:38:10 -05:00
chore: update alias creation to use consistent naming
### CHANGES - Remove redundant prefix from `pattern_name` variable - Add `alias_name` variable for consistent alias creation - Update alias command to use `alias_name` - Modify PowerShell function to use `aliasName`
This commit is contained in:
10
README.md
10
README.md
@@ -352,10 +352,11 @@ before, if you'd prefer all the fabric aliases to start with the same prefix.
|
|||||||
# Loop through all files in the ~/.config/fabric/patterns directory
|
# Loop through all files in the ~/.config/fabric/patterns directory
|
||||||
for pattern_file in $HOME/.config/fabric/patterns/*; do
|
for pattern_file in $HOME/.config/fabric/patterns/*; do
|
||||||
# Get the base name of the file (i.e., remove the directory path)
|
# Get the base name of the file (i.e., remove the directory path)
|
||||||
pattern_name="${FABRIC_ALIAS_PREFIX:-}"$(basename "$pattern_file")
|
pattern_name="$(basename "$pattern_file")"
|
||||||
|
alias_name="${FABRIC_ALIAS_PREFIX:-}${pattern_name}"
|
||||||
|
|
||||||
# Create an alias in the form: alias pattern_name="fabric --pattern pattern_name"
|
# Create an alias in the form: alias pattern_name="fabric --pattern pattern_name"
|
||||||
alias_command="alias $pattern_name='fabric --pattern $pattern_name'"
|
alias_command="alias $alias_name='fabric --pattern $pattern_name'"
|
||||||
|
|
||||||
# Evaluate the alias command to add it to the current shell
|
# Evaluate the alias command to add it to the current shell
|
||||||
eval "$alias_command"
|
eval "$alias_command"
|
||||||
@@ -386,10 +387,11 @@ $patternsPath = Join-Path $HOME ".config/fabric/patterns"
|
|||||||
foreach ($patternDir in Get-ChildItem -Path $patternsPath -Directory) {
|
foreach ($patternDir in Get-ChildItem -Path $patternsPath -Directory) {
|
||||||
# Prepend FABRIC_ALIAS_PREFIX if set; otherwise use empty string
|
# Prepend FABRIC_ALIAS_PREFIX if set; otherwise use empty string
|
||||||
$prefix = $env:FABRIC_ALIAS_PREFIX ?? ''
|
$prefix = $env:FABRIC_ALIAS_PREFIX ?? ''
|
||||||
$patternName = "$prefix$($patternDir.Name)"
|
$patternName = "$($patternDir.Name)"
|
||||||
|
$aliasName = "$prefix$patternName"
|
||||||
# Dynamically define a function for each pattern
|
# Dynamically define a function for each pattern
|
||||||
$functionDefinition = @"
|
$functionDefinition = @"
|
||||||
function $patternName {
|
function $aliasName {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[Parameter(ValueFromPipeline = `$true)]
|
[Parameter(ValueFromPipeline = `$true)]
|
||||||
|
|||||||
Reference in New Issue
Block a user