Skip to content

Commit

Permalink
Edit environment variable configuration
Browse files Browse the repository at this point in the history
* rename PROFILE_ENABLE_DAILYTRANSCRIPTS TO PROFILE_ENABLE_DAILY_TRANSCRIPTS
* add PROFILE_LOAD_CUSTOM_SCRIPTS and document its behavior in the
  readme file
  • Loading branch information
StefanGreve committed Jun 1, 2023
1 parent 9cc7380 commit e699c7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ New-Item -Path $ProfilePath -ItemType SymbolicLink -Value $(Resolve-Path profile
## Configuration

Some additional features can be turned on by setting their respective environment
variables.
variables:

```powershell
# enable storing daily terminal transcription in the documents folder
Set-EnvironmentVariable -Key PROFILE_ENABLE_DAILYTRANSCRIPTS -Value 1
```
- `PROFILE_ENABLE_DAILY_TRANSCRIPTS`: Set this environment variable to `1` to
enable automatic transcript storing in `MyDocuments\Transcripts` (off by default.)

- `PROFILE_LOAD_CUSTOM_SCRIPTS`: Declare a single path to dot-source Powershell
scripts from on profile launch.

## Features

Expand Down
8 changes: 7 additions & 1 deletion profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ $global:OperatingSystem = if ([OperatingSystem]::IsWindows()) {
[CultureInfo]::CurrentCulture = "ja-JP"
$PSDefaultParameterValues["*:Encoding"] = "utf8"

if ($env:PROFILE_LOAD_CUSTOM_SCRIPTS) {
Get-ChildItem -Path $env:PROFILE_LOAD_CUSTOM_SCRIPTS -Filter "*.ps1" | ForEach-Object {
. $_.FullName
}
}

if ([OperatingSystem]::IsWindows()) {
$global:PSRC = "$HOME\Documents\PowerShell\profile.ps1"
$global:VSRC = "$env:APPDATA\Code\User\settings.json"
Expand Down Expand Up @@ -1257,7 +1263,7 @@ function Start-DailyTranscript {
$Filename = [Path]::Combine($Transcripts, [string]::Format("{0}.txt", [datetime]::Now.ToString("yyyy-MM-dd")))
}
process {
if ($env:PROFILE_ENABLE_DAILYTRANSCRIPTS -eq 1) {
if ($env:PROFILE_ENABLE_DAILY_TRANSCRIPTS -eq 1) {
Write-Verbose "Started a new transcript, output file is $Filename"
Start-Transcript -Path $Filename -Append -IncludeInvocationHeader -UseMinimalHeader | Out-Null
}
Expand Down

0 comments on commit e699c7e

Please sign in to comment.