mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-25 12:09:01 +00:00
Add semi-colons in powershell alias so that if line breaks get lost the function can still be invoked directly. This makes it possible to add thefuck to the current session by running iex "$(thefuck --alias)" which mirrors the eval syntax in bash
19 lines
661 B
Python
19 lines
661 B
Python
from .generic import Generic
|
|
|
|
|
|
class Powershell(Generic):
|
|
def app_alias(self, fuck):
|
|
return 'function ' + fuck + ' { \n' \
|
|
' $fuck = $(thefuck (Get-History -Count 1).CommandLine);\n' \
|
|
' if (-not [string]::IsNullOrWhiteSpace($fuck)) {\n' \
|
|
' if ($fuck.StartsWith("echo")) { $fuck = $fuck.Substring(5); }\n' \
|
|
' else { iex "$fuck"; }\n' \
|
|
' }\n' \
|
|
'}\n'
|
|
|
|
def and_(self, *commands):
|
|
return u' -and '.join('({0})'.format(c) for c in commands)
|
|
|
|
def how_to_configure(self):
|
|
return 'iex "thefuck --alias"', '$profile'
|