Monad prompt – aky pouzivate?


Toto je prva zmena, ktoru vzdy robim u Monadu – menim si defaultny prompt 🙂
Na windows prompte sa mi paci, ze vzdy viem, kde som, na linuxovom prompte sa mi paci, ze mam dost miesta a pred prikazom nemam napisane “C:\documents and settings\martin.zugec\documents\msh\testfunctions\test1”


V Monade preto pouzivam vlastny prompt, ktory je kombinaciou – sice mi vypisuje celu cestu, ale len do zahlavia (title). Pretoze som zastancom LUA (t.j. mam vzdy tri ucty – jeden user, pod ktorym pracujem, jeden local administrator a jeden domain administrator), mam vzdy zapnutych niekolko konzolovych okien pod inym uzivatelom – preto mam miesto promptu vypisane, pod akym uzivatelom mam to ktore okno otvorene. Zaroven ich mam aj farebne odlisene – User je zelena, local admin je purpurova a domain admin je cervena… Ale k tej funkcii:


Function Prompt {
 if ($executionContext.SessionState.Path.IsProviderQualified($pwd.Path))
  {
      $path = parse-path -noqualifier $pwd.Path
  }
  else
  {
      $path = $pwd.Path
  }
 Write-Host -nonewline -ForeGroundColor Green $(Echo $Env:Username);”>”
 $host.ui.rawui.windowtitle = “$path”
}


Aky prompt pouzivate Vy? Toto je len kratka ukazka mojho profilu, dalej tam mam vlastne drives (Registry:) alebo vlastne funkcie (Using-Culture pre prepnutie do CZ prostredia) etc..


Martin Zugec

Comments (7)

  1. David Pokluda says:

    Ja pouzivam tento. Chci prostredi podobne CMD:

    function prompt

    {

    "$(get-location)>"

    }

    Krome toho jsem nasel nekde na webu nasledujici script, ktery pridava Visual Studio promenne do prostredi:

    # Determine the base install path

    $VisualStudioKey = get-property HKLM:SOFTWAREMicrosoftVisualStudio8.0

    $vsPath = parse-path $VisualStudioKey.InstallDir -Parent | parse-path -Parent

    if (test-path $vsPath)

    {

    write-host "Setting environment for using Microsoft Visual Studio 2005 x86 tools."

    # Set up the base directory environment variables

    $env:VSINSTALLDIR = $vsPath

    $vcPath = combine-path $vsPath "VC"

    $env:VCINSTALLDIR = $vcPath

    # Determine the configured version of the CLR

    $env:FrameworkVersion = $VisualStudioKey."CLR Version"

    # Set the paths for the Framework and SDK directories

    $FrameworkKey = get-property HKLM:SOFTWAREMicrosoft.NETFramework

    $env:FrameworkDir = $FrameworkKey.InstallRoot

    $env:FrameworkSDKDir = $FrameworkKey."sdkInstallRootv2.0"

    # Root of Visual Studio IDE installed files

    $env:DevEnvDir = $VisualStudioKey.InstallDir

    # Build the additions to the PATH

    $paths = @()

    $paths += $env:DevEnvDir

    $paths += combine-path $env:VCINSTALLDIR "BIN"

    $paths += combine-path $env:VSINSTALLDIR "Common7Tools"

    $paths += combine-path $env:VSINSTALLDIR "Common7Toolsbin"

    $paths += combine-path $env:VCINSTALLDIR "PlatformSDKbin"

    $paths += combine-path $env:FrameworkSDKDir "bin"

    $paths += combine-path $env:FrameworkDir $env:FrameworkVersion

    $paths += combine-path $env:VCINSTALLDIR "VCPackages"

    $pathText = [string]::Join(";",$paths)

    $env:PATH = $pathText + ";" + $env:PATH

    # Build the additions to the INCLUDE

    $includes = @()

    $includes += combine-path $env:VCINSTALLDIR "ATLMFCINCLUDE"

    $includes += combine-path $env:VCINSTALLDIR "INCLUDE"

    $includes += combine-path $env:VCINSTALLDIR "PlatformSDKinclude"

    $includes += combine-path $env:FrameworkSDKDir "include"

    $includeText = [string]::Join(";",$includes)

    $env:INCLUDE = $includeText + ";" + $env:INCLUDE

    # Build the additions to the LIB

    $libs = @()

    $libs += combine-path $env:VCINSTALLDIR "ATLMFCLIB"

    $libs += combine-path $env:VCINSTALLDIR "LIB"

    $libs += combine-path $env:VCINSTALLDIR "PlatformSDKlib"

    $libs += combine-path $env:FrameworkSDKDir "lib"

    $libText = [string]::Join(";",$libs)

    $env:LIB = $libText + ";" + $env:LIB

    # Build the LIBPATH

    $libpaths = @()

    $libpaths += combine-path $env:FrameworkDir $env:FrameworkVersion

    $libpaths += combine-path $env:VCINSTALLDIR "ATLMFCLIB"

    $libpathsText = [string]::Join(";",$libpaths)

    $env:LIBPATH = $libpathsText

    }

    else

    {

    write-error "Couldn’t find the Visual Studio installation directory."

    }

  2. blogCZSK says:

    Ja tam mam este par dalsich veci, napr. Using-Culture 😉

    Function Using-Culture (

    [System.Globalization.CultureInfo]$culture = (throw "USAGE: Using-Culture -Culture culture -Script {scriptblock}"),

    [ScriptBlock]$script= (throw "USAGE: Using-Culture -Culture culture -Script {scriptblock}"))

    {

       $OldCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture

       trap

       {

           [System.Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture

       }

       [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture

       Invoke-Command $script

       [System.Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture

    }

  3. zxevil150 says:

    pIBKsh r u crazzy? I told u! I can’t read!

  4. zxevil151 says:

    6bD8DH r u crazzy? I told u! I can’t read!

  5. zxevil153 says:

    La7ZVr r u crazzy? I told u! I can’t read!

  6. zxevil154 says:

    QMQs8n r u crazzy? I told u! I can’t read!

  7. zxevil155 says:

    HiwpZL r u crazzy? I told u! I can’t read!