Skip to content

Commit

Permalink
Add Profile for Alias Shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-johnston committed Nov 28, 2021
1 parent 74104a8 commit d6b8e54
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Scribe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ if (!$Command) {
exit
}


# Set default logging location
$sourceDirectory = "$PSScriptRoot\logs\"

function invoke-logfile {
Expand Down Expand Up @@ -264,10 +264,10 @@ $timeStamp
function invoke-searchentry {
param (
[Parameter(Position = 0, Mandatory = $True)]
[string]$pattern
[string]$pattern
)
Get-ChildItem -path $sourceDirectory | Select-String -pattern $pattern

Get-ChildItem -path $sourceDirectory | Select-String -pattern $pattern
}

function invoke-editlog {
Expand Down
60 changes: 60 additions & 0 deletions profile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<#
.SYNOPSIS
This is a sample profile.ps1 script, used to demonstrate
a technique to alias a PowerShell script in new PowerShell sessions
It allows a shortened command line interface from any directory location
on the machine.
Note PowerShell profiles are located in different locations for various reasons.
get-help about_profiles describes the use of profiles.
This code is designed to run in the scope of current user all hosts.
$Home\[My ]Documents\PowerShell\Profile.ps1
in my environment this file is located at
C:\Users\dj\OneDrive\Documents\PowerShell\profile.ps1
.DESCRIPTION
Long description
.PARAMETER Command
Parameter description
.PARAMETER Rest
Parameter description
.EXAMPLE
An example
.NOTES
General notes
#>
function invoke-codex {
param(
[Parameter(Position = 0)]
#[ValidateSet("edit", "help", "log", "list", "search", "test")]
[string]$Command,

[Parameter(Position = 1, ValueFromRemainingArguments = $true)]
$Rest
)
try {

# Get the current location so we can return to it in the finally block.
$currentLocation = Get-Location

# Set an env variable.
# TODO: Move this to system env variable reference.
$env:Codex = 'X:\OneDrive\Documents\root\lds\Projects\Codex\'

# Use location to call script and pass params through.
set-location $env:Codex
./Scribe.ps1 $Command $Rest

}
finally {
# In all conditions return to the original location.
set-location $currentLocation
}
}

# Set alias for reference and use at command line.
Set-Alias codex invoke-codex

0 comments on commit d6b8e54

Please sign in to comment.