{"thread":{"id":"63363","subject":"Re: [PATCH] Fix early wrapping of the command line when using git-prompt.sh","startedAt":"2025-04-28T12:58:19Z","lastAt":"2025-04-28T12:58:19Z","messageCount":1,"participants":["Richard Quadling"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"516891","messageId":"CAKUjMCULZLBCG0CMiiZBRMmqz+YRXJyOL7U9_1i2tRGeq2nnHA@mail.gmail.com","threadId":"63363","inReplyTo":null,"subject":"Re: [PATCH] Fix early wrapping of the command line when using git-prompt.sh","fromName":"Richard Quadling","fromEmail":"rquadling@gmail.com","sentAt":"2025-04-28T12:58:07Z","receivedAt":"2025-04-28T12:58:19Z","isPatch":true,"sender":{"key":"rquadling@gmail.com","avatar":"https://gravatar.com/avatar/4c385f24d4f13c86b9c3e54c61b2532189c1ffb3099a8e63738fd75de90b20ba?d=mp&s=160"},"body":"As an example:\n\nThe following is my prompt whilst in a Git Repo:\n\n$ echo $PS1 | hexdump -C\n00000000  5c 30 30 31 24 28 63 6f  64 65 3d 24 7b 3f 23 23  |\\001$(code=${?##|\n00000010  30 7d 3b 65 63 68 6f 20  24 7b 63 6f 64 65 3a 2b  |0};echo ${code:+|\n00000020  24 28 74 70 75 74 20 73  65 74 61 66 20 39 29 5c  |$(tput setaf 9)\\|\n00000030  30 30 32 28 24 7b 63 6f  64 65 7d 29 5c 20 7d 29  |002(${code})\\ })|\n00000040  5c 30 30 31 24 28 74 70  75 74 20 73 67 72 30 29  |\\001$(tput sgr0)|\n00000050  5c 30 30 32 5c 30 30 31  24 28 74 70 75 74 20 73  |\\002\\001$(tput s|\n00000060  65 74 61 66 20 36 29 5c  30 30 32 24 7b 50 53 31  |etaf 6)\\002${PS1|\n00000070  5f 53 48 45 4c 4c 53 5f  49 4e 3a 30 3a 24 53 48  |_SHELLS_IN:0:$SH|\n00000080  4c 56 4c 7d 5c 30 30 31  24 28 74 70 75 74 20 73  |LVL}\\001$(tput s|\n00000090  65 74 61 66 20 31 34 29  5c 30 30 32 24 53 48 4c  |etaf 14)\\002$SHL|\n000000a0  56 4c 5c 30 30 31 24 28  74 70 75 74 20 73 65 74  |VL\\001$(tput set|\n000000b0  61 66 20 36 29 5c 30 30  32 24 7b 50 53 31 5f 53  |af 6)\\002${PS1_S|\n000000c0  48 45 4c 4c 53 5f 4f 55  54 3a 20 2d 24 53 48 4c  |HELLS_OUT: -$SHL|\n000000d0  56 4c 7d 20 5c 30 30 31  24 28 74 70 75 74 20 73  |VL} \\001$(tput s|\n000000e0  67 72 30 29 5c 30 30 32  24 28 65 63 68 6f 20 2d  |gr0)\\002$(echo -|\n000000f0  65 20 24 7b 41 57 53 43  52 45 44 53 7d 29 5c 30  |e ${AWSCREDS})\\0|\n00000100  30 31 24 28 74 70 75 74  20 73 65 74 61 66 20 35  |01$(tput setaf 5|\n00000110  29 5c 30 30 32 5c 44 7b  25 59 2d 25 6d 2d 25 64  |)\\002\\D{%Y-%m-%d|\n00000120  20 25 48 3a 25 4d 3a 25  53 7d 20 5c 30 30 31 24  | %H:%M:%S} \\001$|\n00000130  28 74 70 75 74 20 73 67  72 30 29 5c 30 30 32 5c  |(tput sgr0)\\002\\|\n00000140  30 30 31 24 28 74 70 75  74 20 73 65 74 61 66 20  |001$(tput setaf |\n00000150  36 29 5c 30 30 32 5c 75  5c 30 30 31 24 28 74 70  |6)\\002\\u\\001$(tp|\n00000160  75 74 20 73 67 72 30 29  5c 30 30 32 5c 30 30 31  |ut sgr0)\\002\\001|\n00000170  24 28 74 70 75 74 20 73  65 74 61 66 20 38 29 5c  |$(tput setaf 8)\\|\n00000180  30 30 32 40 5c 30 30 31  24 28 74 70 75 74 20 73  |002@\\001$(tput s|\n00000190  67 72 30 29 5c 30 30 32  5c 30 30 31 24 28 74 70  |gr0)\\002\\001$(tp|\n000001a0  75 74 20 73 65 74 61 66  20 32 29 5c 30 30 32 5c  |ut setaf 2)\\002\\|\n000001b0  68 5c 30 30 31 24 28 74  70 75 74 20 73 67 72 30  |h\\001$(tput sgr0|\n000001c0  29 5c 30 30 32 5c 30 30  31 24 28 74 70 75 74 20  |)\\002\\001$(tput |\n000001d0  73 65 74 61 66 20 38 29  5c 30 30 32 3a 5c 30 30  |setaf 8)\\002:\\00|\n000001e0  31 24 28 74 70 75 74 20  73 67 72 30 29 5c 30 30  |1$(tput sgr0)\\00|\n000001f0  32 5c 30 30 31 24 28 74  70 75 74 20 73 65 74 61  |2\\001$(tput seta|\n00000200  66 20 33 29 5c 30 30 32  5c 77 5c 30 30 31 24 28  |f 3)\\002\\w\\001$(|\n00000210  74 70 75 74 20 73 67 72  30 29 5c 30 30 32 5c 30  |tput sgr0)\\002\\0|\n00000220  30 31 24 28 5b 5b 20 24  63 6f 75 6e 74 20 2d 67  |01$([[ $count -g|\n00000230  74 20 31 20 5d 5d 20 26  26 20 65 63 68 6f 20 22  |t 1 ]] && echo \"|\n00000240  5c 30 30 32 20 5b 24 50  53 31 5f 50 41 54 48 5f  |\\002 [$PS1_PATH_|\n00000250  43 4f 55 4e 54 5d 5c 30  30 31 29 22 29 5c 30 30  |COUNT]\\001)\")\\00|\n00000260  32 20 28 01 1b 5b 33 32  6d 02 24 7b 5f 5f 67 69  |2 (..[32m.${__gi|\n                   ^^                 ^^\n00000270  74 5f 70 73 31 5f 62 72  61 6e 63 68 5f 6e 61 6d  |t_ps1_branch_nam|\n00000280  65 7d 01 1b 5b 30 6d 02  20 01 1b 5b 31 3b 33 34  |e}..[0m. ..[1;34|\n                ^^             ^^     ^^\n00000290  6d 02 24 01 1b 5b 30 6d  02 3e 29 20 5c 5c 24 0a  |m.$..[0m.>) \\\\$.|\n                   ^^              ^^\n000002a0\n\nWith the fix\n\n$ echo $PS1 | hexdump -C\n00000000  5c 30 30 31 24 28 63 6f  64 65 3d 24 7b 3f 23 23  |\\001$(code=${?##|\n00000010  30 7d 3b 65 63 68 6f 20  24 7b 63 6f 64 65 3a 2b  |0};echo ${code:+|\n00000020  24 28 74 70 75 74 20 73  65 74 61 66 20 39 29 5c  |$(tput setaf 9)\\|\n00000030  30 30 32 28 24 7b 63 6f  64 65 7d 29 5c 20 7d 29  |002(${code})\\ })|\n00000040  5c 30 30 31 24 28 74 70  75 74 20 73 67 72 30 29  |\\001$(tput sgr0)|\n00000050  5c 30 30 32 5c 30 30 31  24 28 74 70 75 74 20 73  |\\002\\001$(tput s|\n00000060  65 74 61 66 20 36 29 5c  30 30 32 24 7b 50 53 31  |etaf 6)\\002${PS1|\n00000070  5f 53 48 45 4c 4c 53 5f  49 4e 3a 30 3a 24 53 48  |_SHELLS_IN:0:$SH|\n00000080  4c 56 4c 7d 5c 30 30 31  24 28 74 70 75 74 20 73  |LVL}\\001$(tput s|\n00000090  65 74 61 66 20 31 34 29  5c 30 30 32 24 53 48 4c  |etaf 14)\\002$SHL|\n000000a0  56 4c 5c 30 30 31 24 28  74 70 75 74 20 73 65 74  |VL\\001$(tput set|\n000000b0  61 66 20 36 29 5c 30 30  32 24 7b 50 53 31 5f 53  |af 6)\\002${PS1_S|\n000000c0  48 45 4c 4c 53 5f 4f 55  54 3a 20 2d 24 53 48 4c  |HELLS_OUT: -$SHL|\n000000d0  56 4c 7d 20 5c 30 30 31  24 28 74 70 75 74 20 73  |VL} \\001$(tput s|\n000000e0  67 72 30 29 5c 30 30 32  24 28 65 63 68 6f 20 2d  |gr0)\\002$(echo -|\n000000f0  65 20 24 7b 41 57 53 43  52 45 44 53 7d 29 5c 30  |e ${AWSCREDS})\\0|\n00000100  30 31 24 28 74 70 75 74  20 73 65 74 61 66 20 35  |01$(tput setaf 5|\n00000110  29 5c 30 30 32 5c 44 7b  25 59 2d 25 6d 2d 25 64  |)\\002\\D{%Y-%m-%d|\n00000120  20 25 48 3a 25 4d 3a 25  53 7d 20 5c 30 30 31 24  | %H:%M:%S} \\001$|\n00000130  28 74 70 75 74 20 73 67  72 30 29 5c 30 30 32 5c  |(tput sgr0)\\002\\|\n00000140  30 30 31 24 28 74 70 75  74 20 73 65 74 61 66 20  |001$(tput setaf |\n00000150  36 29 5c 30 30 32 5c 75  5c 30 30 31 24 28 74 70  |6)\\002\\u\\001$(tp|\n00000160  75 74 20 73 67 72 30 29  5c 30 30 32 5c 30 30 31  |ut sgr0)\\002\\001|\n00000170  24 28 74 70 75 74 20 73  65 74 61 66 20 38 29 5c  |$(tput setaf 8)\\|\n00000180  30 30 32 40 5c 30 30 31  24 28 74 70 75 74 20 73  |002@\\001$(tput s|\n00000190  67 72 30 29 5c 30 30 32  5c 30 30 31 24 28 74 70  |gr0)\\002\\001$(tp|\n000001a0  75 74 20 73 65 74 61 66  20 32 29 5c 30 30 32 5c  |ut setaf 2)\\002\\|\n000001b0  68 5c 30 30 31 24 28 74  70 75 74 20 73 67 72 30  |h\\001$(tput sgr0|\n000001c0  29 5c 30 30 32 5c 30 30  31 24 28 74 70 75 74 20  |)\\002\\001$(tput |\n000001d0  73 65 74 61 66 20 38 29  5c 30 30 32 3a 5c 30 30  |setaf 8)\\002:\\00|\n000001e0  31 24 28 74 70 75 74 20  73 67 72 30 29 5c 30 30  |1$(tput sgr0)\\00|\n000001f0  32 5c 30 30 31 24 28 74  70 75 74 20 73 65 74 61  |2\\001$(tput seta|\n00000200  66 20 33 29 5c 30 30 32  5c 77 5c 30 30 31 24 28  |f 3)\\002\\w\\001$(|\n00000210  74 70 75 74 20 73 67 72  30 29 5c 30 30 32 5c 30  |tput sgr0)\\002\\0|\n00000220  30 31 24 28 5b 5b 20 24  63 6f 75 6e 74 20 2d 67  |01$([[ $count -g|\n00000230  74 20 31 20 5d 5d 20 26  26 20 65 63 68 6f 20 22  |t 1 ]] && echo \"|\n00000240  5c 30 30 32 20 5b 24 50  53 31 5f 50 41 54 48 5f  |\\002 [$PS1_PATH_|\n00000250  43 4f 55 4e 54 5d 5c 30  30 31 29 22 29 5c 30 30  |COUNT]\\001)\")\\00|\n00000260  32 20 28 5c 30 30 31 1b  5b 33 32 6d 5c 30 30 32  |2 (\\001.[32m\\002|\n                                                                ^^^^     ^^^^\n00000270  24 7b 5f 5f 67 69 74 5f  70 73 31 5f 62 72 61 6e  |${__git_ps1_bran|\n00000280  63 68 5f 6e 61 6d 65 7d  5c 30 30 31 1b 5b 30 6d  |ch_name}\\001.[0m|\n                                                                     ^^^^\n00000290  5c 30 30 32 20 5c 30 30  31 1b 5b 31 3b 33 34 6d  |\\002 \\001.[1;34m|\n                                                             ^^^^ ^^^^\n000002a0  5c 30 30 32 24 5c 30 30  31 1b 5b 30 6d 5c 30 30  |\\002$\\001.[0m\\00|\n                                                             ^^^^ ^^^^\n000002b0  32 3e 29 20 5c 5c 24 0a                           |2>) \\\\$.|\n000002b8\n"}]}