mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
Add Powershell as a supported shell
- There may be additional functionality to implement, but I've been running this way for a month with no known issues
This commit is contained in:
parent
2207dd2668
commit
6daf687237
19
tests/shells/test_powershell.py
Normal file
19
tests/shells/test_powershell.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pytest
|
||||
from thefuck.shells import Powershell
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('isfile', 'no_memoize', 'no_cache')
|
||||
class TestPowershell(object):
|
||||
@pytest.fixture
|
||||
def shell(self):
|
||||
return Powershell()
|
||||
|
||||
def test_and_(self, shell):
|
||||
assert shell.and_('ls', 'cd') == '(ls) -and (cd)'
|
||||
|
||||
def test_app_alias(self, shell):
|
||||
assert 'function fuck' in shell.app_alias('fuck')
|
||||
assert 'function FUCK' in shell.app_alias('FUCK')
|
||||
assert 'thefuck' in shell.app_alias('fuck')
|
@ -9,12 +9,14 @@ from .fish import Fish
|
||||
from .generic import Generic
|
||||
from .tcsh import Tcsh
|
||||
from .zsh import Zsh
|
||||
from .powershell import Powershell
|
||||
|
||||
shells = {'bash': Bash,
|
||||
'fish': Fish,
|
||||
'zsh': Zsh,
|
||||
'csh': Tcsh,
|
||||
'tcsh': Tcsh}
|
||||
'tcsh': Tcsh,
|
||||
'powershell': Powershell}
|
||||
|
||||
|
||||
def _get_shell():
|
||||
|
18
thefuck/shells/powershell.py
Normal file
18
thefuck/shells/powershell.py
Normal file
@ -0,0 +1,18 @@
|
||||
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'
|
Loading…
x
Reference in New Issue
Block a user