编辑

编辑

我很确定这是我的 SSH 客户端(Windows 版 RoyalTS)的一些缺陷,但是,在刚刚安装并更改为 Fish shell 后,我的提示符前面有两个深灰色âŽ字符。

它似乎没有在 PuTTY 中执行,只是在这个使用 Rebex 插件的特定客户端中执行。

鱼常见问题解答讨论了随机字符并提到了一个fish_title函数,它告诉您如何清空,但这似乎没有什么区别。

我确信它们只是某种编码错误的控制字符,但我只是想弄清楚这两个字符是什么、它们的用途以及如何摆脱它们。

编辑

根据要求,自安装以来,输出fish_prompt没有改变,并且是:

function fish_prompt --description 'Write out the prompt'
    # Just calculate this once, to save a few cycles when displaying the prompt
    if not set -q __fish_prompt_hostname
            set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
    end

    set -l color_cwd
    set -l suffix
    switch $USER
    case root toor
            if set -q fish_color_cwd_root
                    set color_cwd $fish_color_cwd_root
            else
                    set color_cwd $fish_color_cwd
            end
            set suffix '#'
    case '*'
            set color_cwd $fish_color_cwd
            set suffix '>'
    end

    echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
end

...和fish_prompt | xxd​​:

0000000: 726f 6f74 4063 616e 6463 2d77 6230 3170  root@candc-wb01p
0000010: 2d6c 201b 5b33 316d 2f1b 5b33 306d 1b28  -l .[31m/.[30m.(
0000020: 421b 5b6d 2320                           B.[m#

...和functions -an​​:

# functions -an
., N_, _, __fish_append, __fish_bind_test1, __fish_bind_test2, 
__fish_command_not_found_setup, __fish_commandline_test, 
__fish_complete_abook_formats, __fish_complete_ant_targets, 
__fish_complete_atool, __fish_complete_atool_archive_contents, 
__fish_complete_aura, __fish_complete_bittorrent, 
__fish_complete_cabal, __fish_complete_cd, __fish_complete_command, 
__fish_complete_convert_options, __fish_complete_diff, 
__fish_complete_directories, __fish_complete_file_url, 
__fish_complete_ftp, __fish_complete_grep, __fish_complete_groups, 
__fish_complete_list, __fish_complete_lpr, __fish_complete_lpr_option, 
__fish_complete_ls, __fish_complete_lsusb, __fish_complete_man, 
__fish_complete_mime, __fish_complete_pacman, __fish_complete_path, 
__fish_complete_pgrep, __fish_complete_pids, __fish_complete_ppp_peer, 
__fish_complete_proc, __fish_complete_python, 
__fish_complete_service_actions, __fish_complete_setxkbmap, 
__fish_complete_ssh, __fish_complete_subcommand, 
__fish_complete_subcommand_root, __fish_complete_suffix, 
__fish_complete_svn, __fish_complete_svn_diff, __fish_complete_tar, 
__fish_complete_tex, __fish_complete_unrar, __fish_complete_users, 
__fish_complete_vi, __fish_complete_wvdial_peers, __fish_complete_xsum, 
__fish_config_interactive, __fish_contains_opt, __fish_crux_packages, 
__fish_cursor_konsole, __fish_cursor_xterm, 
__fish_default_command_not_found_handler, __fish_describe_command, 
__fish_filter_ant_targets, __fish_filter_mime, __fish_git_prompt, 
__fish_gnu_complete, __fish_hg_prompt, __fish_is_first_token, 
__fish_is_token_n, __fish_list_current_token, 
__fish_make_completion_signals, __fish_man_page, __fish_move_last, 
__fish_no_arguments, __fish_not_contain_opt, 
__fish_number_of_cmd_args_wo_opts, __fish_paginate, __fish_ports_dirs, 
__fish_print_abook_emails, __fish_print_addresses, 
__fish_print_arch_daemons, __fish_print_cmd_args, 
__fish_print_cmd_args_without_options, __fish_print_commands, 
__fish_print_debian_services, __fish_print_encodings, 
__fish_print_filesystems, __fish_print_function_prototypes, 
__fish_print_help, __fish_print_hostnames, __fish_print_interfaces, 
__fish_print_lpr_options, __fish_print_lpr_printers, 
__fish_print_lsblk_columns, __fish_print_make_targets, 
__fish_print_mounted, __fish_print_packages, 
__fish_print_service_names, __fish_print_svn_rev, __fish_print_users, 
__fish_print_xdg_mimeapps, __fish_print_xdg_mimetypes, 
__fish_print_xrandr_modes, __fish_print_xrandr_outputs, 
__fish_print_xwindows, __fish_prt_no_subcommand, __fish_prt_packages, 
__fish_prt_ports, __fish_prt_use_package, __fish_prt_use_port, 
__fish_pwd, __fish_reconstruct_path, __fish_reload_key_bindings, 
__fish_repaint, __fish_repaint_root, __fish_restore_status, 
__fish_seen_subcommand_from, __fish_systemctl_automounts, 
__fish_systemctl_devices, __fish_systemctl_mounts, 
__fish_systemctl_scopes, __fish_systemctl_service_paths, 
__fish_systemctl_services, __fish_systemctl_slices, 
__fish_systemctl_snapshots, __fish_systemctl_sockets, 
__fish_systemctl_swaps, __fish_systemctl_targets, 
__fish_systemctl_timers, __fish_test_arg, __fish_urlencode, 
__fish_use_subcommand, __fish_winch_handler, __terlar_git_prompt, abbr, 
alias, cd, contains_seq, cp, delete-or-exit, dirh, dirs, 
down-or-search, eval, export, fish_config, fish_default_key_bindings, 
fish_indent, fish_mode_prompt, fish_prompt, fish_sigtrap_handler, 
fish_update_completions, fish_vi_cursor, fish_vi_key_bindings, 
fish_vi_mode, funced, funcsave, grep, help, history, hostname, isatty, 
la, ll, ls, man, math, mcd, mimedb, mv, nextd, nextd-or-forward-word, 
open, popd, prevd, prevd-or-backward-word, prompt_pwd, psub, pushd, rm, 
seq, setenv, sgrep, trap, type, umask, up-or-search, vared,

答案1

我确信它们只是某种编码错误的控制字符,但我只是想弄清楚这两个字符是什么,

âŽ当显示\xc2 \x8e使用 Windows 代码页 1252 解码的传输的八位字节时,会发生这种情况。您的终端仿真器正在使用单字节字符集。

解码为 UTF-8,确切地说,这是SS2控制字符。

所以你有:主机端认为它需要发送 ISO 2022 控制序列来切换 7 位字符集,即使(相当讽刺的是)它以 UTF-8 编码这些控制序列;以及一个不支持 UTF-8 的终端模拟器。

您十六进制转储的提示字符串中还有更多 ISO 2022。 \x1b \x28 \x42是您的 shell(显然在其set_color normal命令中)发送 ISO 2022-JP 序列以切换到 ASCII 的位置。

最简单的解决办法是:让你的终端模拟器使用 UTF-8。停止您的主机程序认为它们需要进行任何类型的 ISO 2022 字符集切换根本不并告诉他们也只使用 UTF-8。

您可能还想检查您的终端类型。您的终端类型(最初从终端仿真程序发送到您的主机)必须与终端仿真程序的实际行为相匹配。制作“但它是xterm,对吗?”决策,或者只是选择任意终端类型,很少能奏效。

PuTTY 的正确终端类型实际上类似于putty或者putty-256color或者putty-sco例如。

相关内容