WSL
wsl -- bash
- when you screw up your shell configuration and you need to start a shell clean
- DejaVu Sans Mono for Powershell seems to work
- Meslo LG S DZ Regular for Powerline.ttf
- start a tmux everytime
if command -v tmux &> /dev/null && [ -n "$PS1" ] && ! "$TERM" =~ screen && ! "$TERM" =~ tmux && [ -z "$TMUX" ]; then
exec tmux
fi
Powershell
Get-ChildItem
ls | sort lastwritetime
- equivalent of POSIX ls -lrt
- Amazingly, you CAN'T get human-readable filesize like ls -lh without a bunch of scripting - STUPID!
dir
is an alias for Get-ChildItem
= ls
dir env:
- show all environment variables
echo $Env:Path
- show just one
Copy-Item
Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings\Logs" -Recurse
Pipes
| more
- like linux
| Out-File "\\server\share\log$($env.computername-Get-Date -f yyyy-MM-dd)-logfile.log" -Force
pipe output of operation to log file
| Get-Member -MemberType property
- What are the things you can sort by?
Filesystems
Get-PsDrive -PsProvider FileSystem
equivalent of df -h
Formatting Storage Devices
- Only works if you're running powershell as admin
get-disk
Get-Disk 2 | Clear-Disk -RemoveData
- Cleans a disk by removing all partition information and un-initializing it, erasing all data on the disk.
New-Partition -DiskNumber 1 -UseMaximumSize
get-partition -disknumber 1 | format-volume -filesystem exFAT -newfilesystemlabel ChrisPhone
get-partition -disknumber 1 | set-partition -newdriveletter d
- mount the newly created drive
Get-PnpDevice | sort-object -property class | more
- list all plug and play devices
Other
notepad.exe $PROFILE
- edit the equivalent of your .bashrc
- Can also edit global rcfile
$PROFILE.AllUsersAllHosts
- Profile comments lines begin with hash #
get-command
= equivalent to which
$PSVersionTable.PSVersion
Install-Module <modulename>
Get-Command -module <modulename>
Restart-Computer
type
is an alias for Get-Content
= cat
- Ctrl-L clears screen
help
- equivalent of POSIX man
"{0} GB" -f ((Get-ChildItem . -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1GB)
- get folder size