repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/remove_trailing_cedilla.py | thefuck/rules/remove_trailing_cedilla.py | # -*- encoding: utf-8 -*-
CEDILLA = u"ç"
def match(command):
return command.script.endswith(CEDILLA)
def get_new_command(command):
return command.script[:-1]
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/ln_s_order.py | thefuck/rules/ln_s_order.py | import os
from thefuck.specific.sudo import sudo_support
def _get_destination(script_parts):
"""When arguments order is wrong first argument will be destination."""
for part in script_parts:
if part not in {'ln', '-s', '--symbolic'} and os.path.exists(part):
return part
@sudo_support
def... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/brew_link.py | thefuck/rules/brew_link.py | from thefuck.utils import for_app
@for_app('brew', at_least=2)
def match(command):
return (command.script_parts[1] in ['ln', 'link']
and "brew link --overwrite --dry-run" in command.output)
def get_new_command(command):
command_parts = command.script_parts[:]
command_parts[1] = 'link'
co... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/cat_dir.py | thefuck/rules/cat_dir.py | import os
from thefuck.utils import for_app
@for_app('cat', at_least=1)
def match(command):
return (
command.output.startswith('cat: ') and
os.path.isdir(command.script_parts[1])
)
def get_new_command(command):
return command.script.replace('cat', 'ls', 1)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/terraform_no_command.py | thefuck/rules/terraform_no_command.py | import re
from thefuck.utils import for_app
MISTAKE = r'(?<=Terraform has no command named ")([^"]+)(?="\.)'
FIX = r'(?<=Did you mean ")([^"]+)(?="\?)'
@for_app('terraform')
def match(command):
return re.search(MISTAKE, command.output) and re.search(FIX, command.output)
def get_new_command(command):
mistak... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/az_cli.py | thefuck/rules/az_cli.py | import re
from thefuck.utils import for_app, replace_argument
INVALID_CHOICE = "(?=az)(?:.*): '(.*)' is not in the '.*' command group."
OPTIONS = "^The most similar choice to '.*' is:\n\\s*(.*)$"
@for_app('az')
def match(command):
return "is not in the" in command.output and "command group" in command.output
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/vagrant_up.py | thefuck/rules/vagrant_up.py | from thefuck.shells import shell
from thefuck.utils import for_app
@for_app('vagrant')
def match(command):
return 'run `vagrant up`' in command.output.lower()
def get_new_command(command):
cmds = command.script_parts
machine = None
if len(cmds) >= 3:
machine = cmds[2]
start_all_instance... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/__init__.py | thefuck/rules/__init__.py | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false | |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/react_native_command_unrecognized.py | thefuck/rules/react_native_command_unrecognized.py | import re
from subprocess import Popen, PIPE
from thefuck.utils import for_app, replace_command, cache, eager
@for_app('react-native')
def match(command):
return re.findall(r"Unrecognized command '.*'", command.output)
@cache('package.json')
@eager
def _get_commands():
proc = Popen(['react-native', '--help'... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/grunt_task_not_found.py | thefuck/rules/grunt_task_not_found.py | import re
from subprocess import Popen, PIPE
from thefuck.utils import for_app, eager, get_closest, cache
regex = re.compile(r'Warning: Task "(.*)" not found.')
@for_app('grunt')
def match(command):
return regex.findall(command.output)
@cache('Gruntfile.js')
@eager
def _get_all_tasks():
proc = Popen(['grun... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_merge.py | thefuck/rules/git_merge.py | import re
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@git_support
def match(command):
return ('merge' in command.script
and ' - not something we can merge' in command.output
and 'Did you mean this?' in command.output)
@git_support
def get_new_... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_clone_git_clone.py | thefuck/rules/git_clone_git_clone.py | from thefuck.specific.git import git_support
@git_support
def match(command):
return (' git clone ' in command.script
and 'fatal: Too many arguments.' in command.output)
@git_support
def get_new_command(command):
return command.script.replace(' git clone ', ' ', 1)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/sed_unterminated_s.py | thefuck/rules/sed_unterminated_s.py | import shlex
from thefuck.shells import shell
from thefuck.utils import for_app
@for_app('sed')
def match(command):
return "unterminated `s' command" in command.output
def get_new_command(command):
script = shlex.split(command.script)
for (i, e) in enumerate(script):
if e.startswith(('s/', '-es... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/apt_get_search.py | thefuck/rules/apt_get_search.py | import re
from thefuck.specific.apt import apt_available
from thefuck.utils import for_app
enabled_by_default = apt_available
@for_app('apt-get')
def match(command):
return command.script.startswith('apt-get search')
def get_new_command(command):
return re.sub(r'^apt-get', 'apt-cache', command.script)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/apt_list_upgradable.py | thefuck/rules/apt_list_upgradable.py | from thefuck.specific.apt import apt_available
from thefuck.specific.sudo import sudo_support
from thefuck.utils import for_app
enabled_by_default = apt_available
@sudo_support
@for_app('apt')
def match(command):
return 'apt list --upgradable' in command.output
@sudo_support
def get_new_command(command):
r... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/long_form_help.py | thefuck/rules/long_form_help.py | from thefuck.utils import replace_argument
import re
# regex to match a suggested help command from the tool output
help_regex = r"(?:Run|Try) '([^']+)'(?: or '[^']+')? for (?:details|more information)."
def match(command):
if re.search(help_regex, command.output, re.I) is not None:
return True
if '... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/systemctl.py | thefuck/rules/systemctl.py | """
The confusion in systemctl's param order is massive.
"""
from thefuck.specific.sudo import sudo_support
from thefuck.utils import for_app
@sudo_support
@for_app('systemctl')
def match(command):
# Catches "Unknown operation 'service'." when executing systemctl with
# misordered arguments
cmd = command.... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/pip_install.py | thefuck/rules/pip_install.py | from thefuck.utils import for_app
from thefuck.specific.sudo import sudo_support
@sudo_support
@for_app('pip')
def match(command):
return ('pip install' in command.script and 'Permission denied' in command.output)
def get_new_command(command):
if '--user' not in command.script: # add --user (attempt 1)
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/rm_dir.py | thefuck/rules/rm_dir.py | import re
from thefuck.specific.sudo import sudo_support
@sudo_support
def match(command):
return ('rm' in command.script
and 'is a directory' in command.output.lower())
@sudo_support
def get_new_command(command):
arguments = '-rf'
if 'hdfs' in command.script:
arguments = '-r'
re... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/mkdir_p.py | thefuck/rules/mkdir_p.py | import re
from thefuck.specific.sudo import sudo_support
@sudo_support
def match(command):
return ('mkdir' in command.script
and 'No such file or directory' in command.output)
@sudo_support
def get_new_command(command):
return re.sub('\\bmkdir (.*)', 'mkdir -p \\1', command.script)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/no_such_file.py | thefuck/rules/no_such_file.py | import re
from thefuck.shells import shell
patterns = (
r"mv: cannot move '[^']*' to '([^']*)': No such file or directory",
r"mv: cannot move '[^']*' to '([^']*)': Not a directory",
r"cp: cannot create regular file '([^']*)': No such file or directory",
r"cp: cannot create regular file '([^']*)': Not ... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/unsudo.py | thefuck/rules/unsudo.py | patterns = ['you cannot perform this operation as root']
def match(command):
if command.script_parts and command.script_parts[0] != 'sudo':
return False
for pattern in patterns:
if pattern in command.output.lower():
return True
return False
def get_new_command(command):
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/no_command.py | thefuck/rules/no_command.py | from thefuck.utils import get_all_executables, get_close_matches, \
get_valid_history_without_current, get_closest, which
from thefuck.specific.sudo import sudo_support
@sudo_support
def match(command):
return (not which(command.script_parts[0])
and ('not found' in command.output
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/pacman_not_found.py | thefuck/rules/pacman_not_found.py | """ Fixes wrong package names with pacman or yaourt.
For example the `llc` program is in package `llvm` so this:
yay -S llc
should be:
yay -S llvm
"""
from thefuck.utils import replace_command
from thefuck.specific.archlinux import get_pkgfile, archlinux_env
def match(command):
return (command.script_pa... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/cd_parent.py | thefuck/rules/cd_parent.py | # Adds the missing space between the cd command and the target directory
# when trying to cd to the parent directory.
#
# Does not really save chars, but is fun :D
#
# Example:
# > cd..
# cd..: command not found
def match(command):
return command.script == 'cd..'
def get_new_command(command):
return 'cd ..'... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_two_dashes.py | thefuck/rules/git_two_dashes.py | from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@git_support
def match(command):
return ('error: did you mean `' in command.output
and '` (with two dashes ?)' in command.output)
@git_support
def get_new_command(command):
to = command.output.split('`')[1]
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_main_master.py | thefuck/rules/git_main_master.py | from thefuck.specific.git import git_support
@git_support
def match(command):
return "'master'" in command.output or "'main'" in command.output
@git_support
def get_new_command(command):
if "'master'" in command.output:
return command.script.replace("master", "main")
return command.script.replac... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/docker_login.py | thefuck/rules/docker_login.py | from thefuck.utils import for_app
from thefuck.shells import shell
@for_app('docker')
def match(command):
return ('docker' in command.script
and "access denied" in command.output
and "may require 'docker login'" in command.output)
def get_new_command(command):
return shell.and_('dock... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/dnf_no_such_command.py | thefuck/rules/dnf_no_such_command.py | import subprocess
import re
from thefuck.specific.sudo import sudo_support
from thefuck.utils import for_app, replace_command
from thefuck.specific.dnf import dnf_available
regex = re.compile(r'No such command: (.*)\.')
@sudo_support
@for_app('dnf')
def match(command):
return 'no such command' in command.output... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_rebase_merge_dir.py | thefuck/rules/git_rebase_merge_dir.py | from thefuck.utils import get_close_matches
from thefuck.specific.git import git_support
@git_support
def match(command):
return (' rebase' in command.script and
'It seems that there is already a rebase-merge directory' in command.output and
'I wonder if you are in the middle of another re... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/hostscli.py | thefuck/rules/hostscli.py | import re
from thefuck.specific.sudo import sudo_support
from thefuck.utils import replace_command, for_app
no_command = "Error: No such command"
no_website = "hostscli.errors.WebsiteImportError"
@sudo_support
@for_app('hostscli')
def match(command):
errors = [no_command, no_website]
for error in errors:
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/gradle_wrapper.py | thefuck/rules/gradle_wrapper.py | import os
from thefuck.utils import for_app, which
@for_app('gradle')
def match(command):
return (not which(command.script_parts[0])
and 'not found' in command.output
and os.path.isfile('gradlew'))
def get_new_command(command):
return u'./gradlew {}'.format(' '.join(command.script_pa... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_lfs_mistype.py | thefuck/rules/git_lfs_mistype.py | import re
from thefuck.utils import get_all_matched_commands, replace_command
from thefuck.specific.git import git_support
@git_support
def match(command):
'''
Match a mistyped command
'''
return 'lfs' in command.script and 'Did you mean this?' in command.output
@git_support
def get_new_command(comm... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_flag_after_filename.py | thefuck/rules/git_flag_after_filename.py | import re
from thefuck.specific.git import git_support
error_pattern = "fatal: bad flag '(.*?)' used after filename"
error_pattern2 = "fatal: option '(.*?)' must come before non-option arguments"
@git_support
def match(command):
return re.search(error_pattern, command.output) or re.search(error_pattern2, command... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_pull.py | thefuck/rules/git_pull.py | from thefuck.shells import shell
from thefuck.specific.git import git_support
@git_support
def match(command):
return 'pull' in command.script and 'set-upstream' in command.output
@git_support
def get_new_command(command):
line = command.output.split('\n')[-3].strip()
branch = line.split(' ')[-1]
se... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/man_no_space.py | thefuck/rules/man_no_space.py | def match(command):
return (command.script.startswith(u'man')
and u'command not found' in command.output.lower())
def get_new_command(command):
return u'man {}'.format(command.script[3:])
priority = 2000
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/ag_literal.py | thefuck/rules/ag_literal.py | from thefuck.utils import for_app
@for_app('ag')
def match(command):
return command.output.endswith('run ag with -Q\n')
def get_new_command(command):
return command.script.replace('ag', 'ag -Q', 1)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/python_command.py | thefuck/rules/python_command.py | from thefuck.specific.sudo import sudo_support
# add 'python' suffix to the command if
# 1) The script does not have execute permission or
# 2) is interpreted as shell script
@sudo_support
def match(command):
return (command.script_parts
and command.script_parts[0].endswith('.py')
and ('... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/npm_run_script.py | thefuck/rules/npm_run_script.py | from thefuck.specific.npm import npm_available, get_scripts
from thefuck.utils import for_app
enabled_by_default = npm_available
@for_app('npm')
def match(command):
return ('Usage: npm <command>' in command.output
and not any(part.startswith('ru') for part in command.script_parts)
and com... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_branch_exists.py | thefuck/rules/git_branch_exists.py | import re
from thefuck.shells import shell
from thefuck.specific.git import git_support
from thefuck.utils import eager
@git_support
def match(command):
return ("fatal: A branch named '" in command.output
and "' already exists." in command.output)
@git_support
@eager
def get_new_command(command):
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/rails_migrations_pending.py | thefuck/rules/rails_migrations_pending.py | import re
from thefuck.shells import shell
SUGGESTION_REGEX = r"To resolve this issue, run:\s+(.*?)\n"
def match(command):
return "Migrations are pending. To resolve this issue, run:" in command.output
def get_new_command(command):
migration_script = re.search(SUGGESTION_REGEX, command.output).group(1)
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_stash_pop.py | thefuck/rules/git_stash_pop.py | from thefuck.shells import shell
from thefuck.specific.git import git_support
@git_support
def match(command):
return ('stash' in command.script
and 'pop' in command.script
and 'Your local changes to the following files would be overwritten by merge' in command.output)
@git_support
def g... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/cpp11.py | thefuck/rules/cpp11.py | from thefuck.utils import for_app
@for_app('g++', 'clang++')
def match(command):
return ('This file requires compiler and library support for the '
'ISO C++ 2011 standard.' in command.output or
'-Wc++11-extensions' in command.output)
def get_new_command(command):
return command.scrip... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/tmux.py | thefuck/rules/tmux.py | import re
from thefuck.utils import replace_command, for_app
@for_app('tmux')
def match(command):
return ('ambiguous command:' in command.output
and 'could be:' in command.output)
def get_new_command(command):
cmd = re.match(r"ambiguous command: (.*), could be: (.*)",
command.... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/brew_reinstall.py | thefuck/rules/brew_reinstall.py | import re
from thefuck.utils import for_app
warning_regex = re.compile(r'Warning: (?:.(?!is ))+ is already installed and '
r'up-to-date')
message_regex = re.compile(r'To reinstall (?:(?!, ).)+, run `brew reinstall '
r'[^`]+`')
@for_app('brew', at_least=2)
def ma... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/fix_alt_space.py | thefuck/rules/fix_alt_space.py | # -*- encoding: utf-8 -*-
import re
from thefuck.specific.sudo import sudo_support
@sudo_support
def match(command):
return ('command not found' in command.output.lower()
and u' ' in command.script)
@sudo_support
def get_new_command(command):
return re.sub(u' ', ' ', command.script)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_remote_seturl_add.py | thefuck/rules/git_remote_seturl_add.py | from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@git_support
def match(command):
return ('set-url' in command.script
and 'fatal: No such remote' in command.output)
def get_new_command(command):
return replace_argument(command.script, 'set-url', 'add')
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/gulp_not_task.py | thefuck/rules/gulp_not_task.py | import re
import subprocess
from thefuck.utils import replace_command, for_app, cache
@for_app('gulp')
def match(command):
return 'is not in your gulpfile' in command.output
@cache('gulpfile.js')
def get_gulp_tasks():
proc = subprocess.Popen(['gulp', '--tasks-simple'],
stdout=sub... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_push_different_branch_names.py | thefuck/rules/git_push_different_branch_names.py | import re
from thefuck.specific.git import git_support
@git_support
def match(command):
return "push" in command.script and "The upstream branch of your current branch does not match" in command.output
@git_support
def get_new_command(command):
return re.findall(r'^ +(git push [^\s]+ [^\s]+)', command.outpu... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_rm_staged.py | thefuck/rules/git_rm_staged.py | from thefuck.specific.git import git_support
@git_support
def match(command):
return (' rm ' in command.script and
'error: the following file has changes staged in the index' in command.output and
'use --cached to keep the file, or -f to force removal' in command.output)
@git_support
def... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/man.py | thefuck/rules/man.py | from thefuck.utils import for_app
@for_app('man', at_least=1)
def match(command):
return True
def get_new_command(command):
if '3' in command.script:
return command.script.replace("3", "2")
if '2' in command.script:
return command.script.replace("2", "3")
last_arg = command.script_p... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_add.py | thefuck/rules/git_add.py | import re
from thefuck.shells import shell
from thefuck.specific.git import git_support
from thefuck.system import Path
from thefuck.utils import memoize
@memoize
def _get_missing_file(command):
pathspec = re.findall(
r"error: pathspec '([^']*)' "
r'did not match any file\(s\) known to git.', comm... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/pacman.py | thefuck/rules/pacman.py | from thefuck.specific.archlinux import get_pkgfile, archlinux_env
from thefuck.shells import shell
def match(command):
return 'not found' in command.output and get_pkgfile(command.script)
def get_new_command(command):
packages = get_pkgfile(command.script)
formatme = shell.and_('{} -S {}', '{}')
re... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/git_branch_0flag.py | thefuck/rules/git_branch_0flag.py | from thefuck.shells import shell
from thefuck.specific.git import git_support
from thefuck.utils import memoize
@memoize
def first_0flag(script_parts):
return next((p for p in script_parts if len(p) == 2 and p.startswith("0")), None)
@git_support
def match(command):
return command.script_parts[1] == "branch... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/yarn_command_not_found.py | thefuck/rules/yarn_command_not_found.py | import re
from subprocess import Popen, PIPE
from thefuck.utils import (for_app, eager, replace_command, replace_argument,
cache, which)
regex = re.compile(r'error Command "(.*)" not found.')
@for_app('yarn')
def match(command):
return regex.findall(command.output)
npm_commands = {'r... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/ls_lah.py | thefuck/rules/ls_lah.py | from thefuck.utils import for_app
@for_app('ls')
def match(command):
return command.script_parts and 'ls -' not in command.script
def get_new_command(command):
command = command.script_parts[:]
command[0] = 'ls -lah'
return ' '.join(command)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/tsuru_login.py | thefuck/rules/tsuru_login.py | from thefuck.shells import shell
from thefuck.utils import for_app
@for_app('tsuru')
def match(command):
return ('not authenticated' in command.output
and 'session has expired' in command.output)
def get_new_command(command):
return shell.and_('tsuru login', command.script)
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/docker_not_command.py | thefuck/rules/docker_not_command.py | from itertools import dropwhile, takewhile, islice
import re
import subprocess
from thefuck.utils import replace_command, for_app, which, cache
from thefuck.specific.sudo import sudo_support
@sudo_support
@for_app('docker')
def match(command):
return 'is not a docker command' in command.output or 'Usage: docker' ... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/rules/python_module_error.py | thefuck/rules/python_module_error.py | import re
from thefuck.shells import shell
MISSING_MODULE = r"ModuleNotFoundError: No module named '([^']+)'"
def match(command):
return "ModuleNotFoundError: No module named '" in command.output
def get_new_command(command):
missing_module = re.findall(MISSING_MODULE, command.output)[0]
return shell.a... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/nix.py | thefuck/specific/nix.py | from thefuck.utils import which
nix_available = bool(which('nix'))
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/archlinux.py | thefuck/specific/archlinux.py | """ This file provide some utility functions for Arch Linux specific rules."""
import subprocess
from .. import utils
@utils.memoize
def get_pkgfile(command):
""" Gets the packages that provide the given command using `pkgfile`.
If the command is of the form `sudo foo`, searches for the `foo` command
ins... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/git.py | thefuck/specific/git.py | import re
from decorator import decorator
from ..utils import is_app
from ..shells import shell
@decorator
def git_support(fn, command):
"""Resolves git aliases and supports testing for both git and hub."""
# supports GitHub's `hub` command
# which is recommended to be used with `alias git=hub`
# but ... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/apt.py | thefuck/specific/apt.py | from thefuck.utils import which
apt_available = bool(which('apt-get'))
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/sudo.py | thefuck/specific/sudo.py | import six
from decorator import decorator
@decorator
def sudo_support(fn, command):
"""Removes sudo before calling fn and adds it after."""
if not command.script.startswith('sudo '):
return fn(command)
result = fn(command.update(script=command.script[5:]))
if result and isinstance(result, s... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/npm.py | thefuck/specific/npm.py | import re
from subprocess import Popen, PIPE
from thefuck.utils import memoize, eager, which
npm_available = bool(which('npm'))
@memoize
@eager
def get_scripts():
"""Get custom npm scripts."""
proc = Popen(['npm', 'run-script'], stdout=PIPE)
should_yeild = False
for line in proc.stdout.readlines():
... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/dnf.py | thefuck/specific/dnf.py | from thefuck.utils import which
dnf_available = bool(which('dnf'))
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/brew.py | thefuck/specific/brew.py | import subprocess
from ..utils import memoize, which
brew_available = bool(which('brew'))
@memoize
def get_brew_path_prefix():
"""To get brew path"""
try:
return subprocess.check_output(['brew', '--prefix'],
universal_newlines=True).strip()
except Exception... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/__init__.py | thefuck/specific/__init__.py | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false | |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/specific/yum.py | thefuck/specific/yum.py | from thefuck.utils import which
yum_available = bool(which('yum'))
| python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/output_readers/shell_logger.py | thefuck/output_readers/shell_logger.py | import json
import os
import socket
try:
from shutil import get_terminal_size
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size
import pyte
from .. import const, logs
def _get_socket_path():
return os.environ.get(const.SHELL_LOGGER_SOCKET_ENV)
def is_available():
"... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/output_readers/read_log.py | thefuck/output_readers/read_log.py | import os
import shlex
import mmap
import re
try:
from shutil import get_terminal_size
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size
import six
import pyte
from ..exceptions import ScriptNotInLog
from .. import const, logs
def _group_by_calls(log):
ps1 = os.environ['... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/output_readers/__init__.py | thefuck/output_readers/__init__.py | from ..conf import settings
from . import read_log, rerun, shell_logger
def get_output(script, expanded):
"""Get output of the script.
:param script: Console script.
:type script: str
:param expanded: Console script with expanded aliases.
:type expanded: str
:rtype: str
"""
if shell_... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/output_readers/rerun.py | thefuck/output_readers/rerun.py | import os
import shlex
import six
from subprocess import Popen, PIPE, STDOUT
from psutil import AccessDenied, Process, TimeoutExpired
from .. import logs
from ..conf import settings
def _kill_process(proc):
"""Tries to kill the process otherwise just logs a debug message, the
process will be killed when thefu... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/shells/zsh.py | thefuck/shells/zsh.py | from time import time
import os
from subprocess import Popen, PIPE
from tempfile import gettempdir
from uuid import uuid4
from ..conf import settings
from ..const import ARGUMENT_PLACEHOLDER, USER_COMMAND_MARK
from ..utils import DEVNULL, memoize
from .generic import Generic
class Zsh(Generic):
friendly_name = 'Z... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/shells/generic.py | thefuck/shells/generic.py | import io
import os
import shlex
import six
from collections import namedtuple
from ..logs import warn
from ..utils import memoize
from ..conf import settings
from ..system import Path
ShellConfiguration = namedtuple('ShellConfiguration', (
'content', 'path', 'reload', 'can_configure_automatically'))
class Gene... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/shells/powershell.py | thefuck/shells/powershell.py | from subprocess import Popen, PIPE
from ..utils import DEVNULL
from .generic import Generic, ShellConfiguration
class Powershell(Generic):
friendly_name = 'PowerShell'
def app_alias(self, alias_name):
return 'function ' + alias_name + ' {\n' \
' $history = (Get-History -Count 1).Com... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/shells/__init__.py | thefuck/shells/__init__.py | """Package with shell specific actions, each shell class should
implement `from_shell`, `to_shell`, `app_alias`, `put_to_history` and
`get_aliases` methods.
"""
import os
from psutil import Process
from .bash import Bash
from .fish import Fish
from .generic import Generic
from .tcsh import Tcsh
from .zsh import Zsh
fro... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/shells/tcsh.py | thefuck/shells/tcsh.py | from subprocess import Popen, PIPE
from time import time
import os
from ..utils import DEVNULL, memoize
from .generic import Generic
class Tcsh(Generic):
friendly_name = 'Tcsh'
def app_alias(self, alias_name):
return ("alias {0} 'setenv TF_SHELL tcsh && setenv TF_ALIAS {0} && "
"set f... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/shells/fish.py | thefuck/shells/fish.py | from subprocess import Popen, PIPE
from time import time
import os
import sys
import six
from .. import logs
from ..conf import settings
from ..const import ARGUMENT_PLACEHOLDER
from ..utils import DEVNULL, cache
from .generic import Generic
@cache('~/.config/fish/config.fish', '~/.config/fish/functions')
def _get_fu... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
nvbn/thefuck | https://github.com/nvbn/thefuck/blob/c7e7e1d884d3bb241ea6448f72a989434c2a35ec/thefuck/shells/bash.py | thefuck/shells/bash.py | import os
from subprocess import Popen, PIPE
from tempfile import gettempdir
from uuid import uuid4
from ..conf import settings
from ..const import ARGUMENT_PLACEHOLDER, USER_COMMAND_MARK
from ..utils import DEVNULL, memoize
from .generic import Generic
class Bash(Generic):
friendly_name = 'Bash'
def app_ali... | python | MIT | c7e7e1d884d3bb241ea6448f72a989434c2a35ec | 2026-01-04T14:38:15.457096Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/tests/test_normalizer.py | tests/test_normalizer.py | import pytest
from whisper.normalizers import EnglishTextNormalizer
from whisper.normalizers.english import (
EnglishNumberNormalizer,
EnglishSpellingNormalizer,
)
@pytest.mark.parametrize("std", [EnglishNumberNormalizer(), EnglishTextNormalizer()])
def test_number_normalizer(std):
assert std("two") == "... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/tests/test_timing.py | tests/test_timing.py | import numpy as np
import pytest
import scipy.ndimage
import torch
from whisper.timing import dtw_cpu, dtw_cuda, median_filter
sizes = [
(10, 20),
(32, 16),
(123, 1500),
(234, 189),
]
shapes = [
(10,),
(1, 15),
(4, 5, 345),
(6, 12, 240, 512),
]
@pytest.mark.parametrize("N, M", sizes)... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/tests/test_audio.py | tests/test_audio.py | import os.path
import numpy as np
from whisper.audio import SAMPLE_RATE, load_audio, log_mel_spectrogram
def test_audio():
audio_path = os.path.join(os.path.dirname(__file__), "jfk.flac")
audio = load_audio(audio_path)
assert audio.ndim == 1
assert SAMPLE_RATE * 10 < audio.shape[0] < SAMPLE_RATE * 1... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/tests/conftest.py | tests/conftest.py | import random as rand
import numpy
import pytest
def pytest_configure(config):
config.addinivalue_line("markers", "requires_cuda")
@pytest.fixture
def random():
rand.seed(42)
numpy.random.seed(42)
| python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/tests/test_transcribe.py | tests/test_transcribe.py | import os
import pytest
import torch
import whisper
from whisper.tokenizer import get_tokenizer
@pytest.mark.parametrize("model_name", whisper.available_models())
def test_transcribe(model_name: str):
device = "cuda" if torch.cuda.is_available() else "cpu"
model = whisper.load_model(model_name).to(device)
... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/tests/test_tokenizer.py | tests/test_tokenizer.py | import pytest
from whisper.tokenizer import get_tokenizer
@pytest.mark.parametrize("multilingual", [True, False])
def test_tokenizer(multilingual):
tokenizer = get_tokenizer(multilingual=False)
assert tokenizer.sot in tokenizer.sot_sequence
assert len(tokenizer.all_language_codes) == len(tokenizer.all_la... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/transcribe.py | whisper/transcribe.py | import argparse
import os
import traceback
import warnings
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
import numpy as np
import torch
import tqdm
from .audio import (
FRAMES_PER_SECOND,
HOP_LENGTH,
N_FRAMES,
N_SAMPLES,
SAMPLE_RATE,
log_mel_spectrogram,
pad_or_trim,
)
fr... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/decoding.py | whisper/decoding.py | from dataclasses import dataclass, field, replace
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.nn.functional as F
from torch import Tensor
from torch.distributions import Categorical
from .audio import CHUNK_LENGTH
from .tokenize... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/audio.py | whisper/audio.py | import os
from functools import lru_cache
from subprocess import CalledProcessError, run
from typing import Optional, Union
import numpy as np
import torch
import torch.nn.functional as F
from .utils import exact_div
# hard-coded audio hyperparameters
SAMPLE_RATE = 16000
N_FFT = 400
HOP_LENGTH = 160
CHUNK_LENGTH = 3... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/triton_ops.py | whisper/triton_ops.py | from functools import lru_cache
import numpy as np
import torch
try:
import triton
import triton.language as tl
except ImportError:
raise RuntimeError("triton import failed; try `pip install --pre triton`")
@triton.jit
def dtw_kernel(
cost, trace, x, x_stride, cost_stride, trace_stride, N, M, BLOCK_... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/model.py | whisper/model.py | import base64
import gzip
from contextlib import contextmanager
from dataclasses import dataclass
from typing import Dict, Iterable, Optional, Tuple
import numpy as np
import torch
import torch.nn.functional as F
from torch import Tensor, nn
from .decoding import decode as decode_function
from .decoding import detect... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/version.py | whisper/version.py | __version__ = "20250625"
| python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/__main__.py | whisper/__main__.py | from .transcribe import cli
cli()
| python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/utils.py | whisper/utils.py | import json
import os
import re
import sys
import zlib
from typing import Callable, List, Optional, TextIO
system_encoding = sys.getdefaultencoding()
if system_encoding != "utf-8":
def make_safe(string):
# replaces any character not representable using the system default encoding with an '?',
# a... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/__init__.py | whisper/__init__.py | import hashlib
import io
import os
import urllib
import warnings
from typing import List, Optional, Union
import torch
from tqdm import tqdm
from .audio import load_audio, log_mel_spectrogram, pad_or_trim
from .decoding import DecodingOptions, DecodingResult, decode, detect_language
from .model import ModelDimensions... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/tokenizer.py | whisper/tokenizer.py | import base64
import os
import string
from dataclasses import dataclass, field
from functools import cached_property, lru_cache
from typing import Dict, List, Optional, Tuple
import tiktoken
LANGUAGES = {
"en": "english",
"zh": "chinese",
"de": "german",
"es": "spanish",
"ru": "russian",
"ko":... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/timing.py | whisper/timing.py | import itertools
import subprocess
import warnings
from dataclasses import dataclass
from typing import TYPE_CHECKING, List
import numba
import numpy as np
import torch
import torch.nn.functional as F
from .audio import HOP_LENGTH, SAMPLE_RATE, TOKENS_PER_SECOND
from .tokenizer import Tokenizer
if TYPE_CHECKING:
... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/normalizers/english.py | whisper/normalizers/english.py | import json
import os
import re
from fractions import Fraction
from typing import Iterator, List, Match, Optional, Union
from more_itertools import windowed
from .basic import remove_symbols_and_diacritics
class EnglishNumberNormalizer:
"""
Convert any spelled-out numbers into arabic numbers, while handling... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/normalizers/basic.py | whisper/normalizers/basic.py | import re
import unicodedata
import regex
# non-ASCII letters that are not separated by "NFKD" normalization
ADDITIONAL_DIACRITICS = {
"œ": "oe",
"Œ": "OE",
"ø": "o",
"Ø": "O",
"æ": "ae",
"Æ": "AE",
"ß": "ss",
"ẞ": "SS",
"đ": "d",
"Đ": "D",
"ð": "d",
"Ð": "D",
"þ": ... | python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
openai/whisper | https://github.com/openai/whisper/blob/c0d2f624c09dc18e709e37c2ad90c039a4eb72a2/whisper/normalizers/__init__.py | whisper/normalizers/__init__.py | from .basic import BasicTextNormalizer as BasicTextNormalizer
from .english import EnglishTextNormalizer as EnglishTextNormalizer
| python | MIT | c0d2f624c09dc18e709e37c2ad90c039a4eb72a2 | 2026-01-04T14:38:15.473103Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.