diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..763b3b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/Modules diff --git a/profile/profile.ps1 b/Microsoft.PowerShell_profile.ps1 similarity index 64% rename from profile/profile.ps1 rename to Microsoft.PowerShell_profile.ps1 index 54882ae..9f5a652 100644 --- a/profile/profile.ps1 +++ b/Microsoft.PowerShell_profile.ps1 @@ -1,3 +1,9 @@ +########################################################### +# +# Scott's custom profile +# +########################################################### + # prompt customization coming from the following: # http://winterdom.com/2008/08/mypowershellprompt function shorten-path([string] $path) { @@ -21,13 +27,15 @@ function prompt { write-host ' {' -n -f $cdelim write-host (shorten-path (pwd).Path) -n -f $cloc write-host '}' -n -f $cdelim - + $global:GitStatus = Get-GitStatus Write-GitStatus $GitStatus - + return '> ' } +Set-Alias which Get-Command + function Setup-Path { $paths = @("$($env:Path)", "$($env:UserProfile)\poshfiles\scripts") gci $env:UserProfile\bin | % { $paths += $_.FullName } @@ -38,7 +46,22 @@ function Import-InstalledModules { Get-Module -ListAvailable | ? { $_.ModuleType -eq "Script" } | Import-Module } +function Nuke-Item($item) { Remove-Item $item -Recurse -Force } + +function Edit-HostsFiles { + Start-Process -FilePath notepad -ArgumentList "$env:windir\system32\drivers\etc\hosts" +} + +# found at http://www.gregorystrike.com/2011/01/27/how-to-tell-if-powershell-is-32-bit-or-64-bit/ +Function Get-Bits { + Switch ([System.Runtime.InterOpServices.Marshal]::SizeOf([System.IntPtr])) { + 4 { Return "32-bit" } + 8 { Return "64-bit" } + default { Return "Unknown Type" } + } +} + Setup-Path Import-InstalledModules -Enable-GitColors \ No newline at end of file +Enable-GitColors diff --git a/README.md b/README.md index 9305ce9..4e268e1 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,13 @@ Powershell Profile To install simply run the following in Powershell
-(new-object Net.WebClient).DownloadString("https://github.com/scottmuc/poshfiles/raw/master/install.ps1") | invoke-expression
+git clone git@github.com:scottmuc/poshfiles %USERPROFILE%\Documents\WindowsPowershell
 
Features -------- -- Add any script to $env:UserProfile\poshfiles\scripts and it will be globally available - look at Edit-Hosts.ps1 as an example - Creates a pretty prompt - Imports all Script modules whenever powershell is run - Sets up your $env:Path so all directories in $env:UserProfile\bin are globally available - -TODO ----- - -- Instructions on how to fork, modify the installer, and have your own custom powershell profile +- Loaded with some utility functions diff --git a/install.ps1 b/install.ps1 deleted file mode 100644 index 27e754d..0000000 --- a/install.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -$temp_file = "$($env:Temp)\poshfiles.zip" - -function Get-PoshfilesZip { - param ($file) - if (Test-Path $file) { - Remove-Item $file | Out-Null - } - "Downloading poshfiles from github" | Write-Host - (new-object Net.WebClient).DownloadFile("https://github.com/scottmuc/poshfiles/zipball/master", $file) -} - -function Unzip-PoshfilesZip { - Resolve-Path $env:Temp\*-poshfiles-* | Remove-Item -Recurse - - "Extracting poshfiles" | Write-Host - $shell_app = new-object -com shell.application - $zip_file = $shell_app.namespace($temp_file) - $destination = $shell_app.namespace($env:Temp) - $destination.Copyhere($zip_file.items()) - - if ((Test-Path $env:UserProfile\poshfiles)) { - Resolve-Path $env:UserProfile\poshfiles | Remove-Item -Recurse - } - - New-Item $env:UserProfile\poshfiles -Type Container | Out-Null - $unzip_dir = (Resolve-Path $env:Temp\*-poshfiles-* ).Path - Copy-Item $unzip_dir\* -Dest $env:UserProfile\poshfiles -Recurse -} - -function Setup-Profile { - $profile_dir = Split-Path $profile - if (-not (Test-Path $profile_dir)) { - New-Item $profile_dir -Type Container | Out-Null - } - "Setting up profile" | Write-Host - ". `$env:Userprofile\poshfiles\profile\profile.ps1" | Out-File $profile -} - -Get-PoshfilesZip $temp_file -Unzip-PoshfilesZip -Setup-Profile - -. $profile -"Custom poshfiles installed!" | Write-Host -Fore Green diff --git a/scripts/Edit-HostsFile.ps1 b/scripts/Edit-HostsFile.ps1 deleted file mode 100644 index c1d38fb..0000000 --- a/scripts/Edit-HostsFile.ps1 +++ /dev/null @@ -1 +0,0 @@ -Start-Process -FilePath notepad -ArgumentList "$env:windir\system32\drivers\etc\hosts" diff --git a/scripts/Get-Bits.ps1 b/scripts/Get-Bits.ps1 deleted file mode 100644 index d68388f..0000000 --- a/scripts/Get-Bits.ps1 +++ /dev/null @@ -1,11 +0,0 @@ - -# found at http://www.gregorystrike.com/2011/01/27/how-to-tell-if-powershell-is-32-bit-or-64-bit/ -Function Get-Bits(){ - Switch ([System.Runtime.InterOpServices.Marshal]::SizeOf([System.IntPtr])) { - 4 { Return "32-bit" } - 8 { Return "64-bit" } - default { Return "Unknown Type" } - } -} - -Get-Bits