PoshConsole Profile Scripts

The first thing you need to know is that PoshConsole has support for an exit script in addition to the regular profile script (which is executed at startup). It also has support for PoshConsole-specific profile scripts. The full list of profile scripts is included below.

Sample Profiles

# PoshConsole_profile.ps1     The PoshConsole startup profile
################################################################################
if (Test-path ~\Documents\WindowsPowerShell\CmdHistory.csv) {
  # Load the stored history from the csv file  back into PowerShell's history,  ... and into PoshConsole's up-arrow/down-arrow history!
  Import-Csv ~\Documents\WindowsPowerShell\CmdHistory.csv | Add-History -passthru | % { $Host.PrivateData.History.Add( $_.CommandLine ) }
}

# Set up some scripts for quickly changing the window mode ...
# Enter Quake Mode
Function PoshQuakeMode {
  $Host.PrivateData.Settings.ShowInTaskbar = $false
  $Host.PrivateData.Settings.AutoHide = $true
  $Host.PrivateData.Settings.AlwaysOnTop = $true
  $Host.PrivateData.Settings.Animate = $true
  $Host.PrivateData.Settings.Opacity = 0.8
  $Host.PrivateData.Settings.BorderThickness = "0,0,0,5"
  $Host.PrivateData.Settings.BorderColorBottomRight = "Red"
  $Host.PrivateData.Settings.BorderColorTopLeft = "#CCFF3300"
  $Host.PrivateData.Settings.WindowHeight = $Host.PrivateData.FullPrimaryScreenHeight/3
  $Host.PrivateData.Settings.WindowWidth = $Host.PrivateData.FullPrimaryScreenWidth
  $Host.PrivateData.Settings.WindowTop = 0
  $Host.PrivateData.Settings.WindowLeft = 0
  $Host.PrivateData.Settings.ConsoleDefaultBackground = "Black"
  $Host.PrivateData.Settings.ConsoleDefaultForeground = "White"
  $Host.PrivateData.Settings.FocusKey = "Win+OemTilde"
  $Host.PrivateData.Settings.StartupBanner = $false

  $global:quake = $true;
}

# Exit Quake Mode
Function PoshNormalMode {
  $Host.PrivateData.Settings.ShowInTaskbar = $true
  $Host.PrivateData.Settings.AutoHide = $false
  $Host.PrivateData.Settings.AlwaysOnTop = $false
  $Host.PrivateData.Settings.Animate = $true
  $Host.PrivateData.Settings.Opacity = 1.0
  $Host.PrivateData.Settings.BorderThickness = "2,10,2,2"
  $Host.PrivateData.Settings.BorderColorBottomRight = "Red"
  $Host.PrivateData.Settings.BorderColorTopLeft = "#CCFF3300"
  $Host.PrivateData.Settings.WindowHeight = $Host.PrivateData.FullPrimaryScreenHeight/2
  $Host.PrivateData.Settings.WindowWidth = $Host.PrivateData.FullPrimaryScreenWidth * (2/3)
  $Host.PrivateData.Settings.WindowTop = $Host.PrivateData.FullPrimaryScreenHeight / 4
  $Host.PrivateData.Settings.WindowLeft = $Host.PrivateData.FullPrimaryScreenWidth * (1/6)
  $Host.PrivateData.Settings.ConsoleDefaultBackground = "DarkBlue"
  $Host.PrivateData.Settings.ConsoleDefaultForeground = "White"
  $Host.PrivateData.Settings.StartupBanner = $true

  $global:quake = $false;
}

# Toggle Quake Mode
Function Quake {
  if( $global:quake ) { PoshNormalMode } else{ PoshQuakeMode }
}



# PoshConsole_profile_exit.ps1      The PoshConsole Exit Script
################################################################################
# Dump the last 100 commands into a csv file for importing at our next startup
Get-History -Count 100 | Export-Csv ~\Documents\WindowsPowerShell\CmdHistory.csv




Profile List

Note that the paths listed are typical paths, but may not be the same as the paths on your system. The folder "C:\Windows\System32\" is actually whatever folder is returned in PowerShell by executing [Environment]::SystemDirectory and the folder "C:\Users\Joel\Documents\" is actually whatever folder is returned by [Environment]::GetFolderPath( "MyDocuments" )

All Profile scripts are optional (and the names are not case sensitive), but will always be executed if they are present. A future option is planned for skipping profile loading.

Startup Profiles

We first call the system-wide PowerShell profile, and then the system-wide PoshConsole profile, followed by the user's PowerShell profile and lastly, the user's PoshConsole profile:
  1. C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
  2. C:\Windows\System32\WindowsPowerShell\v1.0\PoshConsole_profile.ps1
  3. C:\Users\Joel\Documents\WindowsPowerShell\profile.ps1
  4. C:\Users\Joel\Documents\WindowsPowerShell\PoshConsole_profile.ps1

Exit Profiles

The exit profiles are exactly the same as the startup profiles, with the exception that they have "_exit" on the end of the file name:
  1. C:\Windows\System32\WindowsPowerShell\v1.0\profile_exit.ps1
  2. C:\Windows\System32\WindowsPowerShell\v1.0\PoshConsole_profile_exit.ps1
  3. C:\Users\Joel\Documents\WindowsPowerShell\profile_exit.ps1
  4. C:\Users\Joel\Documents\WindowsPowerShell\PoshConsole_profile_exit.ps1

Last edited Sep 14, 2008 at 4:42 AM by Jaykul, version 6

Comments

No comments yet.