nvbn / thefuck

Magnificent app which corrects your previous console command.
MIT License
84.95k stars 3.43k forks source link

Different rule found when using fish vs bash/zsh #1257

Open septatrix opened 2 years ago

septatrix commented 2 years ago

The output of thefuck --version (something like The Fuck 3.1 using Python 3.5.0 and Bash 4.4.12(1)-release):

The Fuck 3.31 using Python 3.10.1 and Fish Shell 3.3.1

Your system (Debian 7, ArchLinux, Windows, etc.):

Fedora Linux 35 (Workstation Edition)

How to reproduce the bug

  1. Create a git branch which diverges from upstream such that it would require a force push e.g. using git commit --amend and changing the commit message.
  2. Run a normal push without --force.
  3. Run fuck.

The output of The Fuck with THEFUCK_DEBUG=true exported (typically execute export THEFUCK_DEBUG=true in your shell before The Fuck):

Log ``` fuck DEBUG: Run with settings: {'alter_history': True, 'debug': True, 'env': {'GIT_TRACE': '1', 'LANG': 'C', 'LC_ALL': 'C'}, 'exclude_rules': [], 'excluded_search_path_prefixes': [], 'history_limit': None, 'instant_mode': False, 'no_colors': False, 'num_close_matches': 3, 'priority': {}, 'repeat': False, 'require_confirmation': True, 'rules': [], 'slow_commands': ['lein', 'react-native', 'gradle', './gradlew', 'vagrant'], 'user_dir': PosixPath('/home/septatrix/.config/thefuck'), 'wait_command': 3, 'wait_slow_command': 15} DEBUG: Received output: 18:21:50.638803 git.c:455 trace: built-in: git push 18:21:50.641447 run-command.c:666 trace: run_command: unset GIT_PREFIX; ssh -p 20009 gitea@tracker.cde-ev.de 'git-receive-pack '\''/cdedb/cdedb2.git'\''' 18:21:51.551401 run-command.c:666 trace: run_command: .git/hooks/pre-push origin ssh://gitea@tracker.cde-ev.de:20009/cdedb/cdedb2.git To ssh://tracker.cde-ev.de:20009/cdedb/cdedb2.git ! [rejected] feature/configurable-db-host -> feature/configurable-db-host (non-fast-forward) error: failed to push some refs to 'ssh://tracker.cde-ev.de:20009/cdedb/cdedb2.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. DEBUG: Call: git push; with env: {'LC_MEASUREMENT': 'en_GB.UTF-8', 'COLORTERM': 'truecolor', 'GNOME_TERMINAL_SCREEN': '/org/gnome/Terminal/screen/20f05158_bd07_42d0_b162_7281d135ce0d', 'LC_MONETARY': 'en_GB.UTF-8', 'XDG_SESSION_CLASS': 'user', 'LANG': 'C', 'VIRTUAL_ENV': '/home/septatrix/Documents/cde/db/cdedb2/.venv', 'VSCODE_GIT_IPC_HANDLE': '/run/user/1000/vscode-git-996b716d83.sock', 'VSCODE_GIT_ASKPASS_MAIN': '/usr/share/code/resources/app/extensions/git/dist/askpass-main.js', 'WAYLAND_DISPLAY': 'wayland-0', 'TERM': 'xterm-256color', '_OLD_VIRTUAL_PATH': '/home/septatrix/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin', 'SHLVL': '3', 'GNOME_TERMINAL_SERVICE': ':1.441', 'TERM_PROGRAM_VERSION': '1.63.2', 'XDG_RUNTIME_DIR': '/run/user/1000', 'VSCODE_GIT_ASKPASS_NODE': '/usr/share/code/code', 'LC_PAPER': 'en_GB.UTF-8', 'PATH': '/home/septatrix/Documents/cde/db/cdedb2/.venv/bin:/home/septatrix/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin', 'USER': 'septatrix', 'XDG_MENU_PREFIX': 'gnome-', 'XDG_CURRENT_DESKTOP': 'GNOME', 'XDG_SESSION_DESKTOP': 'gnome', 'VIRTUAL_ENV_PROMPT': '(.venv) ', 'CHROME_DESKTOP': 'code-url-handler.desktop', '_OLD_FISH_PROMPT_OVERRIDE': '/home/septatrix/Documents/cde/db/cdedb2/.venv', 'PWD': '/home/septatrix/Documents/cde/db/cdedb2', 'DESKTOP_SESSION': 'gnome', 'XMODIFIERS': '@im=ibus', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'SHELL': '/usr/bin/fish', 'XDG_SESSION_TYPE': 'wayland', 'XDG_DATA_DIRS': '/home/septatrix/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/', 'HOME': '/home/septatrix', 'VTE_VERSION': '6602', 'SESSION_MANAGER': 'local/unix:@/tmp/.ICE-unix/1443610,unix/unix:/tmp/.ICE-unix/1443610', 'VSCODE_GIT_ASKPASS_EXTRA_ARGS': '--ms-enable-electron-run-as-node', 'LC_NUMERIC': 'en_GB.UTF-8', 'GDK_BACKEND': 'x11', 'SYSTEMD_EXEC_PID': '1443968', 'NO_AT_BRIDGE': '1', 'BREAKPAD_DUMP_LOCATION': '/home/septatrix/.config/Code/exthost Crash Reports', 'LC_TIME': 'en_GB.UTF-8', 'DISPLAY': ':0', 'THEFUCK_DEBUG': 'true', 'USERNAME': 'septatrix', 'APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL': 'true', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', 'GNOME_SETUP_DISPLAY': ':1', 'TERM_PROGRAM': 'vscode', 'QT_IM_MODULE': 'ibus', 'GDMSESSION': 'gnome', 'ORIGINAL_XDG_CURRENT_DESKTOP': 'GNOME', 'EDITOR': '/usr/bin/nano', 'LOGNAME': 'septatrix', 'GIT_ASKPASS': '/usr/share/code/resources/app/extensions/git/dist/askpass.sh', 'GDM_LANG': 'en_US.UTF-8', 'XAUTHORITY': '/run/user/1000/.mutter-Xwaylandauth.2WCHF1', 'TF_SHELL': 'fish', 'TF_ALIAS': 'fuck', 'PYTHONIOENCODING': 'utf-8', 'LC_ALL': 'C', 'GIT_TRACE': '1'}; is slow: False took: 0:00:00.980850 DEBUG: Importing rule: adb_unknown_command; took: 0:00:00.000164 DEBUG: Importing rule: ag_literal; took: 0:00:00.000307 DEBUG: Importing rule: apt_get; took: 0:00:00.001086 DEBUG: Importing rule: apt_get_search; took: 0:00:00.000286 DEBUG: Importing rule: apt_invalid_operation; took: 0:00:00.000436 DEBUG: Importing rule: apt_list_upgradable; took: 0:00:00.000262 DEBUG: Importing rule: apt_upgrade; took: 0:00:00.000218 DEBUG: Importing rule: aws_cli; took: 0:00:00.000225 DEBUG: Importing rule: az_cli; took: 0:00:00.000186 DEBUG: Importing rule: brew_cask_dependency; took: 0:00:00.000464 DEBUG: Importing rule: brew_install; took: 0:00:00.000121 DEBUG: Importing rule: brew_link; took: 0:00:00.000183 DEBUG: Importing rule: brew_reinstall; took: 0:00:00.000536 DEBUG: Importing rule: brew_uninstall; took: 0:00:00.000240 DEBUG: Importing rule: brew_unknown_command; took: 0:00:00.000141 DEBUG: Importing rule: brew_update_formula; took: 0:00:00.000201 DEBUG: Importing rule: brew_upgrade; took: 0:00:00.000108 DEBUG: Importing rule: cargo; took: 0:00:00.000172 DEBUG: Importing rule: cargo_no_command; took: 0:00:00.000192 DEBUG: Importing rule: cat_dir; took: 0:00:00.000173 DEBUG: Importing rule: cd_correction; took: 0:00:00.000704 DEBUG: Importing rule: cd_cs; took: 0:00:00.000108 DEBUG: Importing rule: cd_mkdir; took: 0:00:00.000209 DEBUG: Importing rule: cd_parent; took: 0:00:00.000116 DEBUG: Importing rule: chmod_x; took: 0:00:00.000129 DEBUG: Importing rule: choco_install; took: 0:00:00.000350 DEBUG: Importing rule: composer_not_command; took: 0:00:00.000238 DEBUG: Importing rule: conda_mistype; took: 0:00:00.000231 DEBUG: Importing rule: cp_create_destination; took: 0:00:00.000223 DEBUG: Importing rule: cp_omitting_directory; took: 0:00:00.000257 DEBUG: Importing rule: cpp11; took: 0:00:00.000220 DEBUG: Importing rule: dirty_untar; took: 0:00:00.001978 DEBUG: Importing rule: dirty_unzip; took: 0:00:00.001140 DEBUG: Importing rule: django_south_ghost; took: 0:00:00.000128 DEBUG: Importing rule: django_south_merge; took: 0:00:00.000147 DEBUG: Importing rule: dnf_no_such_command; took: 0:00:00.000691 DEBUG: Importing rule: docker_image_being_used_by_container; took: 0:00:00.000248 DEBUG: Importing rule: docker_login; took: 0:00:00.000196 DEBUG: Importing rule: docker_not_command; took: 0:00:00.000539 DEBUG: Importing rule: dry; took: 0:00:00.000161 DEBUG: Importing rule: fab_command_not_found; took: 0:00:00.000241 DEBUG: Importing rule: fix_alt_space; took: 0:00:00.000182 DEBUG: Importing rule: fix_file; took: 0:00:00.001661 DEBUG: Importing rule: gem_unknown_command; took: 0:00:00.000345 DEBUG: Importing rule: git_add; took: 0:00:00.000391 DEBUG: Importing rule: git_add_force; took: 0:00:00.000164 DEBUG: Importing rule: git_bisect_usage; took: 0:00:00.000192 DEBUG: Importing rule: git_branch_delete; took: 0:00:00.000183 DEBUG: Importing rule: git_branch_delete_checked_out; took: 0:00:00.000186 DEBUG: Importing rule: git_branch_exists; took: 0:00:00.000199 DEBUG: Importing rule: git_branch_list; took: 0:00:00.000273 DEBUG: Importing rule: git_checkout; took: 0:00:00.000205 DEBUG: Importing rule: git_clone_git_clone; took: 0:00:00.000179 DEBUG: Importing rule: git_commit_amend; took: 0:00:00.000175 DEBUG: Importing rule: git_commit_reset; took: 0:00:00.000192 DEBUG: Importing rule: git_diff_no_index; took: 0:00:00.000183 DEBUG: Importing rule: git_diff_staged; took: 0:00:00.000189 DEBUG: Importing rule: git_fix_stash; took: 0:00:00.000188 DEBUG: Importing rule: git_flag_after_filename; took: 0:00:00.000200 DEBUG: Importing rule: git_help_aliased; took: 0:00:00.000178 DEBUG: Importing rule: git_hook_bypass; took: 0:00:00.000197 DEBUG: Importing rule: git_lfs_mistype; took: 0:00:00.000184 DEBUG: Importing rule: git_merge; took: 0:00:00.000184 DEBUG: Importing rule: git_merge_unrelated; took: 0:00:00.000173 DEBUG: Importing rule: git_not_command; took: 0:00:00.000192 DEBUG: Importing rule: git_pull; took: 0:00:00.000174 DEBUG: Importing rule: git_pull_clone; took: 0:00:00.000269 DEBUG: Importing rule: git_pull_uncommitted_changes; took: 0:00:00.000195 DEBUG: Importing rule: git_push; took: 0:00:00.000176 DEBUG: Importing rule: git_push_different_branch_names; took: 0:00:00.000184 DEBUG: Importing rule: git_push_force; took: 0:00:00.000170 DEBUG: Importing rule: git_push_pull; took: 0:00:00.000226 DEBUG: Importing rule: git_push_without_commits; took: 0:00:00.000305 DEBUG: Importing rule: git_rebase_merge_dir; took: 0:00:00.000184 DEBUG: Importing rule: git_rebase_no_changes; took: 0:00:00.000129 DEBUG: Importing rule: git_remote_delete; took: 0:00:00.000197 DEBUG: Importing rule: git_remote_seturl_add; took: 0:00:00.000154 DEBUG: Importing rule: git_rm_local_modifications; took: 0:00:00.000198 DEBUG: Importing rule: git_rm_recursive; took: 0:00:00.000190 DEBUG: Importing rule: git_rm_staged; took: 0:00:00.000171 DEBUG: Importing rule: git_stash; took: 0:00:00.000192 DEBUG: Importing rule: git_stash_pop; took: 0:00:00.000169 DEBUG: Importing rule: git_tag_force; took: 0:00:00.000230 DEBUG: Importing rule: git_two_dashes; took: 0:00:00.000171 DEBUG: Importing rule: go_run; took: 0:00:00.000197 DEBUG: Importing rule: go_unknown_command; took: 0:00:00.000307 DEBUG: Importing rule: gradle_no_task; took: 0:00:00.000401 DEBUG: Importing rule: gradle_wrapper; took: 0:00:00.000188 DEBUG: Importing rule: grep_arguments_order; took: 0:00:00.000159 DEBUG: Importing rule: grep_recursive; took: 0:00:00.000230 DEBUG: Importing rule: grunt_task_not_found; took: 0:00:00.000456 DEBUG: Importing rule: gulp_not_task; took: 0:00:00.000229 DEBUG: Importing rule: has_exists_script; took: 0:00:00.000176 DEBUG: Importing rule: heroku_multiple_apps; took: 0:00:00.000191 DEBUG: Importing rule: heroku_not_command; took: 0:00:00.000207 DEBUG: Importing rule: history; took: 0:00:00.000110 DEBUG: Importing rule: hostscli; took: 0:00:00.000201 DEBUG: Importing rule: ifconfig_device_not_found; took: 0:00:00.000282 DEBUG: Importing rule: java; took: 0:00:00.000222 DEBUG: Importing rule: javac; took: 0:00:00.000178 DEBUG: Importing rule: lein_not_task; took: 0:00:00.000215 DEBUG: Importing rule: ln_no_hard_link; took: 0:00:00.000196 DEBUG: Importing rule: ln_s_order; took: 0:00:00.000208 DEBUG: Importing rule: long_form_help; took: 0:00:00.000142 DEBUG: Importing rule: ls_all; took: 0:00:00.000202 DEBUG: Importing rule: ls_lah; took: 0:00:00.000194 DEBUG: Importing rule: man; took: 0:00:00.000192 DEBUG: Importing rule: man_no_space; took: 0:00:00.000151 DEBUG: Importing rule: mercurial; took: 0:00:00.000245 DEBUG: Importing rule: missing_space_before_subcommand; took: 0:00:00.000171 DEBUG: Importing rule: mkdir_p; took: 0:00:00.000206 DEBUG: Importing rule: mvn_no_command; took: 0:00:00.000215 DEBUG: Importing rule: mvn_unknown_lifecycle_phase; took: 0:00:00.000209 DEBUG: Importing rule: nixos_cmd_not_found; took: 0:00:00.000470 DEBUG: Importing rule: no_command; took: 0:00:00.000276 DEBUG: Importing rule: no_such_file; took: 0:00:00.000137 DEBUG: Importing rule: npm_missing_script; took: 0:00:00.000431 DEBUG: Importing rule: npm_run_script; took: 0:00:00.000193 DEBUG: Importing rule: npm_wrong_command; took: 0:00:00.000255 DEBUG: Importing rule: omnienv_no_such_command; took: 0:00:00.000407 DEBUG: Importing rule: open; took: 0:00:00.000264 DEBUG: Importing rule: pacman; took: 0:00:00.000620 DEBUG: Importing rule: pacman_invalid_option; took: 0:00:00.000384 DEBUG: Importing rule: pacman_not_found; took: 0:00:00.000178 DEBUG: Importing rule: path_from_history; took: 0:00:00.000202 DEBUG: Importing rule: php_s; took: 0:00:00.000252 DEBUG: Importing rule: pip_install; took: 0:00:00.000255 DEBUG: Importing rule: pip_unknown_command; took: 0:00:00.000276 DEBUG: Importing rule: port_already_in_use; took: 0:00:00.000324 DEBUG: Importing rule: prove_recursively; took: 0:00:00.000276 DEBUG: Importing rule: pyenv_no_such_command; took: 0:00:00.000443 DEBUG: Importing rule: python_command; took: 0:00:00.000235 DEBUG: Importing rule: python_execute; took: 0:00:00.000231 DEBUG: Importing rule: python_module_error; took: 0:00:00.000162 DEBUG: Importing rule: quotation_marks; took: 0:00:00.000151 DEBUG: Importing rule: react_native_command_unrecognized; took: 0:00:00.000498 DEBUG: Importing rule: remove_shell_prompt_literal; took: 0:00:00.000378 DEBUG: Importing rule: remove_trailing_cedilla; took: 0:00:00.000319 DEBUG: Importing rule: rm_dir; took: 0:00:00.000452 DEBUG: Importing rule: rm_root; took: 0:00:00.000350 DEBUG: Importing rule: scm_correction; took: 0:00:00.000286 DEBUG: Importing rule: sed_unterminated_s; took: 0:00:00.000251 DEBUG: Importing rule: sl_ls; took: 0:00:00.000145 DEBUG: Importing rule: ssh_known_hosts; took: 0:00:00.000245 DEBUG: Importing rule: sudo; took: 0:00:00.000156 DEBUG: Importing rule: sudo_command_from_user_path; took: 0:00:00.000261 DEBUG: Importing rule: switch_lang; took: 0:00:00.000273 DEBUG: Importing rule: systemctl; took: 0:00:00.000374 DEBUG: Importing rule: terraform_init; took: 0:00:00.000419 DEBUG: Importing rule: test.py; took: 0:00:00.000190 DEBUG: Importing rule: tmux; took: 0:00:00.000276 DEBUG: Importing rule: touch; took: 0:00:00.000322 DEBUG: Importing rule: tsuru_login; took: 0:00:00.000318 DEBUG: Importing rule: tsuru_not_command; took: 0:00:00.000328 DEBUG: Importing rule: unknown_command; took: 0:00:00.000170 DEBUG: Importing rule: unsudo; took: 0:00:00.000139 DEBUG: Importing rule: vagrant_up; took: 0:00:00.000288 DEBUG: Importing rule: whois; took: 0:00:00.000516 DEBUG: Importing rule: workon_doesnt_exists; took: 0:00:00.000317 DEBUG: Importing rule: yarn_alias; took: 0:00:00.000295 DEBUG: Importing rule: yarn_command_not_found; took: 0:00:00.000631 DEBUG: Importing rule: yarn_command_replaced; took: 0:00:00.000538 DEBUG: Importing rule: yarn_help; took: 0:00:00.000327 DEBUG: Importing rule: yum_invalid_operation; took: 0:00:00.000718 DEBUG: Trying rule: path_from_history; took: 0:00:00.000624 DEBUG: Trying rule: cd_cs; took: 0:00:00.000077 DEBUG: Trying rule: dry; took: 0:00:00.000004 DEBUG: Trying rule: git_hook_bypass; took: 0:00:00.000079 DEBUG: Trying rule: git_stash_pop; took: 0:00:00.000041 DEBUG: Trying rule: test.py; took: 0:00:00.000003 DEBUG: Trying rule: adb_unknown_command; took: 0:00:00.000019 DEBUG: Trying rule: ag_literal; took: 0:00:00.000041 DEBUG: Trying rule: aws_cli; took: 0:00:00.000031 DEBUG: Trying rule: az_cli; took: 0:00:00.000034 DEBUG: Trying rule: brew_link; took: 0:00:00.000056 DEBUG: Trying rule: brew_reinstall; took: 0:00:00.000032 DEBUG: Trying rule: brew_uninstall; took: 0:00:00.000028 DEBUG: Trying rule: brew_update_formula; took: 0:00:00.000033 DEBUG: Trying rule: cargo; took: 0:00:00.000003 DEBUG: Trying rule: cargo_no_command; took: 0:00:00.000032 DEBUG: Trying rule: cat_dir; took: 0:00:00.000035 DEBUG: Trying rule: cd_correction; took: 0:00:00.000049 DEBUG: Trying rule: cd_mkdir; took: 0:00:00.000048 DEBUG: Trying rule: cd_parent; took: 0:00:00.000002 DEBUG: Trying rule: chmod_x; took: 0:00:00.000003 DEBUG: Trying rule: composer_not_command; took: 0:00:00.000030 DEBUG: Trying rule: conda_mistype; took: 0:00:00.000029 DEBUG: Trying rule: cp_create_destination; took: 0:00:00.000023 DEBUG: Trying rule: cp_omitting_directory; took: 0:00:00.000034 DEBUG: Trying rule: cpp11; took: 0:00:00.000031 DEBUG: Trying rule: dirty_untar; took: 0:00:00.000026 DEBUG: Trying rule: dirty_unzip; took: 0:00:00.000028 DEBUG: Trying rule: django_south_ghost; took: 0:00:00.000003 DEBUG: Trying rule: django_south_merge; took: 0:00:00.000003 DEBUG: Trying rule: dnf_no_such_command; took: 0:00:00.000054 DEBUG: Trying rule: docker_image_being_used_by_container; took: 0:00:00.000032 DEBUG: Trying rule: docker_login; took: 0:00:00.000026 DEBUG: Trying rule: docker_not_command; took: 0:00:00.000034 DEBUG: Trying rule: fab_command_not_found; took: 0:00:00.000034 DEBUG: Trying rule: fix_alt_space; took: 0:00:00.000023 DEBUG: Trying rule: fix_file; took: 0:00:00.000181 DEBUG: Trying rule: gem_unknown_command; took: 0:00:00.000059 DEBUG: Trying rule: git_add; took: 0:00:00.000038 DEBUG: Trying rule: git_add_force; took: 0:00:00.000027 DEBUG: Trying rule: git_bisect_usage; took: 0:00:00.000026 DEBUG: Trying rule: git_branch_delete; took: 0:00:00.000023 DEBUG: Trying rule: git_branch_delete_checked_out; took: 0:00:00.000031 DEBUG: Trying rule: git_branch_exists; took: 0:00:00.000021 DEBUG: Trying rule: git_branch_list; took: 0:00:00.000026 DEBUG: Trying rule: git_checkout; took: 0:00:00.000040 DEBUG: Trying rule: git_clone_git_clone; took: 0:00:00.000017 DEBUG: Trying rule: git_commit_amend; took: 0:00:00.000015 DEBUG: Trying rule: git_commit_reset; took: 0:00:00.000021 DEBUG: Trying rule: git_diff_no_index; took: 0:00:00.000025 DEBUG: Trying rule: git_diff_staged; took: 0:00:00.000019 DEBUG: Trying rule: git_fix_stash; took: 0:00:00.000015 DEBUG: Trying rule: git_flag_after_filename; took: 0:00:00.000015 DEBUG: Trying rule: git_help_aliased; took: 0:00:00.000015 DEBUG: Trying rule: git_lfs_mistype; took: 0:00:00.000014 DEBUG: Trying rule: git_merge; took: 0:00:00.000019 DEBUG: Trying rule: git_merge_unrelated; took: 0:00:00.000015 DEBUG: Trying rule: git_not_command; took: 0:00:00.000015 DEBUG: Trying rule: git_pull; took: 0:00:00.000014 DEBUG: Trying rule: git_pull_clone; took: 0:00:00.000015 DEBUG: Trying rule: git_pull_uncommitted_changes; took: 0:00:00.000015 DEBUG: Trying rule: git_push; took: 0:00:00.000015 DEBUG: Trying rule: git_push_different_branch_names; took: 0:00:00.000015 DEBUG: Trying rule: git_push_pull; took: 0:00:00.000017 DEBUG: Trying rule: git_push_without_commits; took: 0:00:00.000015 DEBUG: Trying rule: git_rebase_merge_dir; took: 0:00:00.000015 DEBUG: Trying rule: git_rebase_no_changes; took: 0:00:00.000016 DEBUG: Trying rule: git_remote_delete; took: 0:00:00.000023 DEBUG: Trying rule: git_remote_seturl_add; took: 0:00:00.000022 DEBUG: Trying rule: git_rm_local_modifications; took: 0:00:00.000045 DEBUG: Trying rule: git_rm_recursive; took: 0:00:00.000025 DEBUG: Trying rule: git_rm_staged; took: 0:00:00.000029 DEBUG: Trying rule: git_stash; took: 0:00:00.000035 DEBUG: Trying rule: git_tag_force; took: 0:00:00.000027 DEBUG: Trying rule: git_two_dashes; took: 0:00:00.000025 DEBUG: Trying rule: go_run; took: 0:00:00.000032 DEBUG: Trying rule: go_unknown_command; took: 0:00:00.000025 DEBUG: Trying rule: gradle_no_task; took: 0:00:00.000031 DEBUG: Trying rule: gradle_wrapper; took: 0:00:00.000033 DEBUG: Trying rule: grep_arguments_order; took: 0:00:00.000028 DEBUG: Trying rule: grep_recursive; took: 0:00:00.000026 DEBUG: Trying rule: grunt_task_not_found; took: 0:00:00.000027 DEBUG: Trying rule: gulp_not_task; took: 0:00:00.000029 DEBUG: Trying rule: has_exists_script; took: 0:00:00.000053 DEBUG: Trying rule: heroku_multiple_apps; took: 0:00:00.000030 DEBUG: Trying rule: heroku_not_command; took: 0:00:00.000033 DEBUG: Trying rule: hostscli; took: 0:00:00.000040 DEBUG: Trying rule: ifconfig_device_not_found; took: 0:00:00.000040 DEBUG: Trying rule: java; took: 0:00:00.000032 DEBUG: Trying rule: javac; took: 0:00:00.000025 DEBUG: Trying rule: lein_not_task; took: 0:00:00.000047 DEBUG: Trying rule: ln_no_hard_link; took: 0:00:00.000016 DEBUG: Trying rule: ln_s_order; took: 0:00:00.000015 DEBUG: Trying rule: ls_all; took: 0:00:00.000026 DEBUG: Trying rule: ls_lah; took: 0:00:00.000029 DEBUG: Trying rule: man; took: 0:00:00.000027 DEBUG: Trying rule: mercurial; took: 0:00:00.000025 DEBUG: Trying rule: mkdir_p; took: 0:00:00.000019 DEBUG: Trying rule: mvn_no_command; took: 0:00:00.000026 DEBUG: Trying rule: mvn_unknown_lifecycle_phase; took: 0:00:00.000022 DEBUG: Trying rule: no_such_file; took: 0:00:00.001031 DEBUG: Trying rule: npm_missing_script; took: 0:00:00.000066 DEBUG: Trying rule: npm_run_script; took: 0:00:00.000032 DEBUG: Trying rule: npm_wrong_command; took: 0:00:00.000039 DEBUG: Trying rule: open; took: 0:00:00.000032 DEBUG: Trying rule: pacman_invalid_option; took: 0:00:00.000042 DEBUG: Trying rule: php_s; took: 0:00:00.000026 DEBUG: Trying rule: pip_install; took: 0:00:00.000038 DEBUG: Trying rule: pip_unknown_command; took: 0:00:00.000050 DEBUG: Trying rule: port_already_in_use; took: 0:00:00.000741 DEBUG: Trying rule: prove_recursively; took: 0:00:00.000069 DEBUG: Trying rule: pyenv_no_such_command; took: 0:00:00.000053 DEBUG: Trying rule: python_command; took: 0:00:00.000018 DEBUG: Trying rule: python_execute; took: 0:00:00.000023 DEBUG: Trying rule: python_module_error; took: 0:00:00.000003 DEBUG: Trying rule: quotation_marks; took: 0:00:00.000001 DEBUG: Trying rule: react_native_command_unrecognized; took: 0:00:00.000026 DEBUG: Trying rule: remove_shell_prompt_literal; took: 0:00:00.000003 DEBUG: Trying rule: remove_trailing_cedilla; took: 0:00:00.000004 DEBUG: Trying rule: rm_dir; took: 0:00:00.000016 DEBUG: Trying rule: scm_correction; took: 0:00:00.000029 DEBUG: Trying rule: sed_unterminated_s; took: 0:00:00.000030 DEBUG: Trying rule: sl_ls; took: 0:00:00.000003 DEBUG: Trying rule: ssh_known_hosts; took: 0:00:00.000029 DEBUG: Trying rule: sudo; took: 0:00:00.000043 DEBUG: Trying rule: sudo_command_from_user_path; took: 0:00:00.000037 DEBUG: Trying rule: switch_lang; took: 0:00:00.000003 DEBUG: Trying rule: systemctl; took: 0:00:00.000049 DEBUG: Trying rule: terraform_init; took: 0:00:00.000033 DEBUG: Trying rule: tmux; took: 0:00:00.000035 DEBUG: Trying rule: touch; took: 0:00:00.000033 DEBUG: Trying rule: tsuru_login; took: 0:00:00.000037 DEBUG: Trying rule: tsuru_not_command; took: 0:00:00.000026 DEBUG: Trying rule: unknown_command; took: 0:00:00.000705 DEBUG: Trying rule: unsudo; took: 0:00:00.000006 DEBUG: Trying rule: vagrant_up; took: 0:00:00.000056 DEBUG: Trying rule: whois; took: 0:00:00.000038 DEBUG: Trying rule: workon_doesnt_exists; took: 0:00:00.000040 DEBUG: Trying rule: yarn_alias; took: 0:00:00.000030 DEBUG: Trying rule: yarn_command_not_found; took: 0:00:00.000025 DEBUG: Trying rule: yarn_command_replaced; took: 0:00:00.000025 DEBUG: Trying rule: yarn_help; took: 0:00:00.000029 DEBUG: Trying rule: yum_invalid_operation; took: 0:00:00.000045 DEBUG: Trying rule: man_no_space; took: 0:00:00.000002 DEBUG: Trying rule: no_command; took: 0:00:00.000138 DEBUG: Trying rule: missing_space_before_subcommand; took: 0:00:00.042224 DEBUG: Trying rule: long_form_help; took: 0:00:00.000379 fish -ic "git push" [enter/↑/↓/ctrl+c] Aborted DEBUG: Total took: 0:00:02.887527 ```

If the bug only appears with a specific application, the output of that application and its version:

git version 2.33.1

Anything else you think is relevant:

TF_SHELL=fish thefuck git push THEFUCK_ARGUMENT_PLACEHOLDER # does not work
TF_SHELL=bash thefuck git push THEFUCK_ARGUMENT_PLACEHOLDER # works
scorphus commented 2 years ago

Seems to me that this is the history rule yielding different results for different shells, as they have different histories.

septatrix commented 2 years ago

What history rule are you referring to? Is it possible to suppress some rules to check if your suspicion is correct?

scorphus commented 2 years ago

I mean the history rule that "tries to replace command with the most similar command from history". Check the How it works section of the README.

Yes, that's possible. You can also check Settings section of the README for that. This is what you want:

THEFUCK_RULES=history thefuck "echoo ok"

But, thanks to you I just saw that The Fuck still uses the outdated location of the history file:

https://github.com/nvbn/thefuck/blob/841e3f9e13f52747c18319b55c77ece8095df306/thefuck/shells/fish.py#L85-L86

Which must be fixed.

Thanks for filing this issue!

mainrs commented 2 years ago

Thanks for linking me to the issue. It might be that the outdated history file location is the culprit. When I use thefuck it doesn't update my history file. It always shows fuck --yeah.

mainrs commented 2 years ago

@scorphus Do you want to keep backwards compatibility with older fish shells? Or can I simply update the history file location?

septatrix commented 2 years ago

Yes, that's possible. You can also check Settings section of the README for that. This is what you want:

THEFUCK_RULES=history thefuck "echoo ok"

In that case I get No fucks given.

With THEFUCK_EXCLUDE_RULES=history I get multiple suggestions (Corrected commands: CorrectedCommand(script=/usr/bin/nano /bin/sh +1; and echoo ok, side_effect=None, priority=1000), CorrectedCommand(script=echo ok, side_effect=None, priority=3000), CorrectedCommand(script=echo o ok, side_effect=None, priority=4000), CorrectedCommand(script=choom ok, side_effect=None, priority=6000), CorrectedCommand(script=chroot ok, side_effect=None, priority=9000).

When using the my reproduction example with git push I still get fish -ic "git push" when excluding history and No fucks given when only including it. However when excluding long_form_help I get No fucks given instead of the fish -ic "git push"

septatrix commented 2 years ago

Oh I think I found the culprit. git is an alias/wrapper to hub on my machine:

$ type git
git is a function with definition
# Defined via `source`
function git --wraps=hub --description 'Alias for hub, which wraps git to provide extra functionality with GitHub.'
    hub $argv
end
scorphus commented 2 years ago

@scorphus Do you want to keep backwards compatibility with older fish shells? Or can I simply update the history file location?

@mainrs: I thought about that. Then I went checking when that was changed and it's been almost 6 years ago. So I'd say there's no need for that. We might want to support the XDG Base Directory Specification though (XDG_DATA_HOME in this case). In a way that another hardcoded path won't still be compatible.

[...] In that case I get No fucks given.

@septatrix: so it really seems to be the absence of history when using fish.

[...] When using the my reproduction example with git push I still get fish -ic "git push" when excluding history and No fucks given when only including it. However when excluding long_form_help I get No fucks given instead of the fish -ic "git push"

What does type git output?

scorphus commented 2 years ago

Oh I think I found the culprit. git is an alias/wrapper to hub on my machine:

$ type git
git is a function with definition
# Defined via `source`
function git --wraps=hub --description 'Alias for hub, which wraps git to provide extra functionality with GitHub.'
    hub $argv
end

Oh! There we have it! You'll want to set "overridden aliases" in that case.

scorphus commented 2 years ago

Please check this out: https://github.com/nvbn/thefuck/wiki/Shell-aliases#fish

septatrix commented 2 years ago

Yes that solves it, thanks. Out of curiosity why is this necessary? All the other shells do not seem to require this and my first impression was that this is required to execute aliases though to my knowledge eval does not need this...

scorphus commented 2 years ago

Please, have a look into 891fbe7 for the motivation.

One other thing is that I now see that Fish's alias is not so slow as it used to be and might be a better option than parsing the output and caching in The Fuck. More so considering cases where aliases are declared outside of config.fish.

How fast is it for you? i.e.

time set foo (alias)
septatrix commented 2 years ago

Please, have a look into 891fbe7 for the motivation.

Thanks but I actually meant the wrapping with fish -ic "..." which apparently got introduced way back in 9debcdf676a212cc41645acaf4253b7e6e580974. This sets fish apart from other shells and I do not know why. Some comment which got moved around in that commit said that fish does not support aliases but that is from ancient times should that have been the case.

Simply removing that whole logic seems to work fine and I could not detect any wrong behaviour during my short testing:

    def get_aliases(self):
        overridden = set()  # these do not have to be provided anymore
        functions = _get_functions(overridden)
        raw_aliases = _get_aliases(overridden)
        functions.update(raw_aliases)
        return functions

    def _expand_aliases(self, command_script):
        aliases = self.get_aliases()
        binary = command_script.split(' ')[0]
        if binary in aliases:
            return command_script.replace(binary, aliases[binary], 1)
        # note the missing elif
        return command_script

I think I will go with that until I run into some errors at which point I can still switch to the THEFUCK_OVERRIDDEN_ALIASES solution.

One other thing is that I now see that Fish's alias is not so slow as it used to be and might be a better option than parsing the output and caching in The Fuck. More so considering cases where aliases are declared outside of config.fish.

How fast is it for you? i.e.

time set foo (alias)
~ $ time set foo (alias)

________________________________________________________
Executed in    9.00 micros    fish           external
   usr time    9.00 micros    9.00 micros    0.00 micros
   sys time    2.00 micros    2.00 micros    0.00 micros
scorphus commented 2 years ago

I think I will go with that until I run into some errors at which point I can still switch to the THEFUCK_OVERRIDDEN_ALIASES solution.

It might as well work for you.

But that's needed when the command being fixed is in fact a function in Fish. Think of how pyenv works in Fish, or npm, or rbenv. These work as native fish functions that rely on bash scripts. And these scripts are only available in your running shell, unless you configure them to be available system wide — which we often don't do, we use plugins and care none about that.

septatrix commented 2 years ago

Oh I see. Yeah that does indeed seem somewhat tricky... And the other shells simply have nothing comparable to fish -ic or why do they not have something similar?

scorphus commented 2 years ago

They don't need that because they can speak the same language (or mostly the same). Whereas Fish has a different language.

septatrix commented 2 years ago

If I understand correctly you mean functions like python venv's deactivate? Those also do not work with bash and thefuck:

[septatrix@thinkpad-e570 ~]$ function asdf() { echo asdf; }
[septatrix@thinkpad-e570 ~]$ asdf
asdf
[septatrix@thinkpad-e570 ~]$ THEFUCK_DEBUG=true fuck
DEBUG: Run with settings: {'alter_history': True,
 'debug': True,
 'env': {'GIT_TRACE': '1', 'LANG': 'C', 'LC_ALL': 'C'},
 'exclude_rules': [],
 'excluded_search_path_prefixes': [],
 'history_limit': None,
 'instant_mode': False,
 'no_colors': False,
 'num_close_matches': 3,
 'priority': {},
 'repeat': False,
 'require_confirmation': True,
 'rules': [<const: All rules enabled>],
 'slow_commands': ['lein', 'react-native', 'gradle', './gradlew', 'vagrant'],
 'user_dir': PosixPath('/home/septatrix/.config/thefuck'),
 'wait_command': 3,
 'wait_slow_command': 15}
DEBUG: Received output: /bin/sh: line 1: asdf: command not found
scorphus commented 2 years ago

More in the way of the pyenv command in Bash, that turns out to be a function in Fish:

function pyenv
  set cmd $argv[1]
  set -e argv[1]

  switch "$cmd"
  case activate deactivate rehash shell virtualenvwrapper virtualenvwrapper_lazy
    command pyenv "sh-$cmd" $argv | source
  case '*'
    command pyenv "$cmd" $argv
  end
end

So I guess the fact that Fish is much more function-oriented than Bash — in a way that fish users create quite a lot of functions (rather than scripts for bash users) and many things are built with functions — required The Fuck to be aware of functions declared in Fish. And that's why the -i part is required in fish -ic "...", as many of those functions are only loaded during an interactive session of the shell (so non-interactive scripts can be fast, but I digress.)

septatrix commented 2 years ago

Though would that not also apply to other shells like bash or zsh when using oh-my-zsh or similar? They too provide a -i flag to load functions and aliases.

Also this feels more of a step which should be done in to_shell (is this even used?) or at least the expanded command should only be used for get_output and not set as the value for Command.script because to me it seems like the wrapping with fish -ic just confuses every rule which exists.

While at it why not just unconditionally wrap the command with fish -ic instead of spawning fish -ic {functions,aliases} subprocesses just to figure out which functions/aliases exists. Spawning a single interactive session should be slower than spawning two with a potential third.

Sorry if I just overlook some obvious flaw in my reasoning but I really like the fuck and to me it seems like that is just some legacy code which might have been necessary once but probably is not needed anymore.