Blogs

Monad prompt - aky pouzivate?

  • Comments 7
  • Likes

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • 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:SOFTWARE\Microsoft\VisualStudio\8.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:SOFTWARE\Microsoft\.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 "Common7\Tools"
    $paths += combine-path $env:VSINSTALLDIR "Common7\Tools\bin"
    $paths += combine-path $env:VCINSTALLDIR "PlatformSDK\bin"
    $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 "ATLMFC\INCLUDE"
    $includes += combine-path $env:VCINSTALLDIR "INCLUDE"
    $includes += combine-path $env:VCINSTALLDIR "PlatformSDK\include"
    $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 "ATLMFC\LIB"
    $libs += combine-path $env:VCINSTALLDIR "LIB"
    $libs += combine-path $env:VCINSTALLDIR "PlatformSDK\lib"
    $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 "ATLMFC\LIB"

    $libpathsText = [string]::Join(";",$libpaths)
    $env:LIBPATH = $libpathsText
    }
    else
    {
    write-error "Couldn't find the Visual Studio installation directory."
    }

  • 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
    }

  • pIBKsh r u crazzy? I told u! I can't read!

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

  • La7ZVr r u crazzy? I told u! I can't read!

  • QMQs8n r u crazzy? I told u! I can't read!

  • HiwpZL r u crazzy? I told u! I can't read!