mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-11 16:39:10 +01:00
Improve list-formatted.ps1 and my-profile.ps1
This commit is contained in:
parent
b351e570d9
commit
27aeeb9806
@ -6,24 +6,22 @@
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
param($Dir = "")
|
||||
param($Directory = "$PWD")
|
||||
|
||||
function ListDirectory { param([string]$Path)
|
||||
function ListDir { param([string]$Path)
|
||||
$Items = get-childItem -path $Path
|
||||
foreach ($Item in $Items) {
|
||||
if ($Item.Name[0] -eq '.') { continue } # hidden file/dir
|
||||
if ($Item.Mode -like "d*") {
|
||||
New-Object PSObject -Property @{ Filename = "$($Item.Name)/" }
|
||||
New-Object PSObject -Property @{ Name = "$($Item.Name)/" }
|
||||
} else {
|
||||
New-Object PSObject -Property @{ Filename = "$($Item.Name)" }
|
||||
New-Object PSObject -Property @{ Name = "$($Item.Name)" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if ($Dir -eq "") {
|
||||
$Dir = "$PWD"
|
||||
}
|
||||
ListDirectory $Dir | format-wide -autoSize
|
||||
ListDir $Directory | format-wide -autoSize
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -1,9 +1,15 @@
|
||||
# My PowerShell Profile
|
||||
# =====================
|
||||
# Welcome to 'my-profile.ps1' - this file defines the look&feel of PowerShell for the user.
|
||||
# Simply comment/uncomment/adapt the following lines.
|
||||
#
|
||||
#
|
||||
# Welcome to 'my-profile.ps1' - this file defines the look & feel of PowerShell.
|
||||
# Comment, uncomment or adapt the following lines to your needs, please.
|
||||
|
||||
|
||||
# My Welcome Message
|
||||
# ------------------
|
||||
write-host "+++ Welcome to PowerShell $($PSVersionTable.PSVersion) at $(hostname), it's $(Get-date) +++"
|
||||
write-host ""
|
||||
|
||||
|
||||
# My Command Prompt
|
||||
# -----------------
|
||||
|
||||
@ -12,19 +18,17 @@
|
||||
# function prompt { "$ " } # result is: $
|
||||
|
||||
function prompt {
|
||||
if ($IsLinux) { $Username = $(whoami) } else { $Username = $env:USERNAME }
|
||||
$host.ui.RawUI.WindowTitle = "$Username @ $(hostname)"
|
||||
if ($IsLinux) { $User = $(whoami) } else { $User = $env:USERNAME }
|
||||
$host.ui.RawUI.WindowTitle = "$User @ $(hostname)"
|
||||
write-host -foregroundColor blue -noNewLine "$(Get-Location)"
|
||||
return "> "
|
||||
} # result is: C:\>
|
||||
|
||||
|
||||
# My Alias Names
|
||||
# My Alias Names (sorted alphabetically)
|
||||
# --------------
|
||||
set-alias -name lsf -value get-childitem # lsf means list directory formatted
|
||||
set-alias -name ll -value get-childitem # ll = list long
|
||||
set-alias -name lsf -value list-formatted.ps1 # lsf = list directory formatted in columns
|
||||
|
||||
|
||||
|
||||
# My Welcome Message
|
||||
# ------------------
|
||||
write-host "+++ Welcome to PowerShell $($PSVersionTable.PSVersion) at $(hostname), it's $(Get-date) +++"
|
||||
write-host ""
|
||||
|
Loading…
Reference in New Issue
Block a user