Questions tagged [escape-characters]
Escape sequences such as encodings of terminal commands and function keys
480 questions
0
votes
2
answers
80
views
How can I read a single key press from a user if it's either the Escape key or a function key?
I'm writing a shell script that's aimed to be as portable and POSIX-compatible as possible, so usage of bash-only commands or high-level input libraries is undesirable.
I'm looking for a way to read a ...
1
vote
1
answer
102
views
DECCRM console code in Linux
For Linux terminals in general - whether it's the virtual console (tty), GNU Screen, xterm, SSH, etc., is there any situation where the console code DECCRM from man 4 console_codes does something?
...
1
vote
1
answer
167
views
How to test that my terminal can report progress with OSC 9;4; sequences?
OSC (“Operating System Commands”) 9;4;x;y sequences are codes that inform the terminal of the progress of any task.
Each software has to implement this support to report the progress, and the terminal ...
3
votes
6
answers
461
views
How can I use sed to chain append lines from a text file, add it as a suffix to the text on the same lines numbers on another file, and so on?
I've tried using sed for this. I've tried putting the lines of interest in variables as well.
I have two examples I want to achieve for now. Lets say I have thousands of urls in a file called links....
0
votes
1
answer
212
views
Need Help Understanding script that reads output of cursor position ANSI escape code
I have this code, which does what I want, but I don't entirely understand it:
#!/usr/bin/env bash
echo -ne "\033[6n" # Ask the terminal to print out the cursor's position
...
1
vote
1
answer
209
views
Multiline command substitution - syntax errors with mysterious `+1`
I'm trying to break a long command substitution on to multiple lines, as discussed in this answer.
In a plain command pipeline, both explicit (\) and implicit line continuation work fine:
$ echo 'blah ...
9
votes
3
answers
943
views
How to delete buffered text written to terminal during script execution
Let's say hypothetically I'm executing a long-running bash script, and while it's running, I accidentally right click on the terminal and paste a sensitive password (freshly copied out of a password ...
1
vote
1
answer
118
views
Zsh’s autocompletion options from variable
General overview
I have to set a values auto-completion in zsh for a command (in the following minimal example, I will show it with testcmd).
So my current code work quiet well with hardcoded values:
...
8
votes
2
answers
1k
views
Why does the special character `?` need to be escaped in grep, but not `.` or `*`?
The only file in my current working directory is called test.txt and its content is simply:
This is a little test file.
Executing
grep -in * -e 'te.?t file'
gives no match.
But escaping ? works:
grep ...
3
votes
2
answers
2k
views
How to generate double quoted JSON string with escaped double quotes?
I sometimes need to write JSON strings containing a string value that is itself a JSON string. e.g. In the following JSON object:
echo '{"rec" : " {\"id\": 1, \"name\&...
0
votes
1
answer
150
views
Does the RESTORE CURSOR escape sequence also restore formatting?
When using the save/restore cursor escape sequences \e7 & \e8, I find that it not only restores the cursor position, but it also restores the text formatting (colors).
I've tried under WSL, vscode ...
0
votes
0
answers
45
views
When using backspace you can see prompt flicker in custom REPL
I'm not sure if this is the right place to ask this. Or should I ask on StackOverflow and show my code. But maybe someone will be able to tell my by just looking at the symptoms.
I have a custom REPL ...
-1
votes
2
answers
280
views
How to interpret escape characters in a string and display them as newlines, color etc
i grep something like:
str='"a\nb"'
echo ${str} | grep -E -o '".*"'
and got:
"a\nb"
i wish the result displays like:
a
b
how could this be done? thanks
p.s. actually, ...
0
votes
0
answers
43
views
Bash misinterpreting lenght of PS1 when using ANSI escape sequences [duplicate]
if i use the following
export PS1='\033[36m$ \033[0m'
Bash misunderstands the length of the prompt and starts line-wrapping too early. My assumption was that it is counting every character, but ...
0
votes
0
answers
167
views
Node.js recently started emitting all stderr in red text. How to handle this cleanly?
I use ANSI colorized text output in logs and other output that I emit on stderr in some of my programs. Since I've been doing this kind of thing for years, I am pretty familiar with the capabilities.
...