Skip to content

Instantly share code, notes, and snippets.

@hyeomans
Last active December 27, 2015 12:49
Show Gist options
  • Save hyeomans/7328676 to your computer and use it in GitHub Desktop.
Save hyeomans/7328676 to your computer and use it in GitHub Desktop.
My powershell profile.
# Executables
function subl { &"C:\Program Files\Sublime Text 2\sublime_text.exe" $args }
function visual { &"${Env:ProgramFiles}\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" $args }
#Directories
function development {
Set-Location 'C:\development'
}
#Files
function hosts { cd C:\Windows\System32\drivers\etc\ }
function edit_profile { subl C:\Users\Hector\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 }
#Git
function gst { git status }
function glog {
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
}
function git_show_orig {
git status -su | grep -e"\.orig$" | cut -f2 -d" "
}
function git_clean_orig {
git_show_orig | xargs rm
}
function remove_bin_obj {
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse -WhatIf }
}
function remove_bin_obj_force {
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
}
#Visual Studio
function compile {
$solution = (Get-Item .\*.sln).Name
if ($solution.Length -gt 0) {
Install-Nuget-Packages
Write-Host "Compiling(With " + (Get-Item Env:\NUMBER_OF_PROCESSORS) + " processors): " + $solution
msbuild /m $solution
} else {
Write-Host $solution
Write-Host "Not able to compile anything. Solution file not found in current directory:"
pwd
}
}
function Install-Nuget-Packages {
$config_files = Get-ChildItem .\ -include "packages.config" -Recurse
if (-Not (Get-Location).Path.EndsWith("packages")) {
cd packages
}
foreach ($config_file in $config_files) {
Write-Host "Installing: $config_files.Fullname"
nuget install $config_file.FullName
}
cd ..
}
function Reload-Profile {
@(
$Profile.AllUsersAllHosts,
$Profile.AllUsersCurrentHost,
$Profile.CurrentUserAllHosts,
$Profile.CurrentUserCurrentHost
) | % {
if(Test-Path $_){
Write-Verbose "Running $_"
. $_
}
}
}
#Vagrant
function vagrant_start {
vagrant up; vagrant ssh;
}
# Load posh-git example profile
#. 'C:\Chocolatey\lib\poshgit.0.4.0.20120717\tools\profile.example.ps1'
# Load posh-git example profile
. 'C:\Users\Hector\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment