Get the keyboard layout in bash
I started doing some noscripting, but I need to get the current keyboard layout. I use 3 keyboards: Russian, Portuguese and English (Colemak). I already have them mapped to alt space, but I can't seem to get the current layout. I am using DWM as my window manager. Void is my distro.
https://redd.it/wf4hty
@r_bash
I started doing some noscripting, but I need to get the current keyboard layout. I use 3 keyboards: Russian, Portuguese and English (Colemak). I already have them mapped to alt space, but I can't seem to get the current layout. I am using DWM as my window manager. Void is my distro.
https://redd.it/wf4hty
@r_bash
reddit
Get the keyboard layout in bash
I started doing some noscripting, but I need to get the current keyboard layout. I use 3 keyboards: Russian, Portuguese and English (Colemak). I...
Determine if the term/console supports UTF8?
I'm trying to automatically determine if a terminal supports UTF8 is order to pick the appropriate characters (i.e. using ASCII instead of UTF8).
The UTF8 increases readability, but on terms that don't support it it causes a mess and harms readability.
Right now I have a switch for picking utf8 or ascii, but I'd really like it to be automatic.
"Solutions" I've found that haven't helped:
- Check the
- This just shows environment variables and has nothing to do with terminal ability.
- Just use a different terminal
- The entire point is to have this work on different terminals / consoles.
- print something to the term and look at it.
- That's not automated.
- Testing
- Only tests
Hackishly works:
- Check
- If the
- Does not explicitly list utf8 support.
- Does not take into account a variety of other terms than don't support utf8.
If there's a better way I'd love to know it. Otherwise it'll be just adding TERMs to ascii as I run across them.
Thanks,
Whale
https://redd.it/wfbf3w
@r_bash
I'm trying to automatically determine if a terminal supports UTF8 is order to pick the appropriate characters (i.e. using ASCII instead of UTF8).
The UTF8 increases readability, but on terms that don't support it it causes a mess and harms readability.
Right now I have a switch for picking utf8 or ascii, but I'd really like it to be automatic.
"Solutions" I've found that haven't helped:
- Check the
locale command or the $LC_.... variables.- This just shows environment variables and has nothing to do with terminal ability.
- Just use a different terminal
- The entire point is to have this work on different terminals / consoles.
- print something to the term and look at it.
- That's not automated.
- Testing
echo supports utf8.- Only tests
echo and bash internals, not the terminal.Hackishly works:
- Check
$TERM - If the
$TERM is linux (local console) it uses ascii, else utf8.- Does not explicitly list utf8 support.
- Does not take into account a variety of other terms than don't support utf8.
If there's a better way I'd love to know it. Otherwise it'll be just adding TERMs to ascii as I run across them.
Thanks,
Whale
https://redd.it/wfbf3w
@r_bash
reddit
Determine if the term/console supports UTF8?
I'm trying to automatically determine if a terminal supports UTF8 is order to pick the appropriate characters (i.e. using ASCII instead of...
What does this bit of code mean?
This part:
https://redd.it/wfky2q
@r_bash
log () {
echo -e "$(basename $0) [$$]: $*" >&2 || :
}
This part:
>&2 || :https://redd.it/wfky2q
@r_bash
reddit
What does this bit of code mean?
``` log () { echo -e "$(basename $0) [$$]: $*" >&2 || : } ``` This part: `>&2 || :`
Can someone translate this line of code from BASH to Windows CMD
I need this line of code to run on Windows CMD (or powershell), preferably one line if possible. If anyone can help me please
https://redd.it/wg2xyp
@r_bash
I need this line of code to run on Windows CMD (or powershell), preferably one line if possible. If anyone can help me please
LC_ALL=C </dev/urandom tr -dc 'A-Za-z0-9!"#$%&()*+,-./:;<=>?@[\]^_`{|}~' | head -c 50 > secret.txt
https://redd.it/wg2xyp
@r_bash
reddit
Can someone translate this line of code from BASH to Windows CMD
I need this line of code to run on Windows CMD (or powershell), preferably one line if possible. If anyone can help me please ``` LC_ALL=C...
How to unify parsing arguments --key=value -key=value -k=value -k value in bash
Hi guys, i'm developing an toolkit for linux engineers and have some issues with auto completions due all my parsing logic depend on one string argument parsing and should contain "=" after key, i want to unify it such way it parse value after -k with space delimeter(or without delimeter at all) and also $ARG1 should not declaring if there "-k some_value" in arguments is there some simple and common way to achieve that?
this is my current implementation which works only -one_string=argument
cat > /tmp/testnoscript.sh << 'EOL'
#!/bin/bash
#Filter arguments by regex for security reasons
CLDOPTS="$(expr "$(tr '\n' ' ' <<< "${@}")" : '\(A-Za-z0-9/ :.,@_=+^*-\+\)' 2>/dev/null | tr ' ' '\n')"
#Simple parsing arguments
for i in ${CLDOPTS}
do
case $i in
-k=|-key=|--key=) KEY="${i#=}" ;;
-f=|-foo=|--foo=) BAR="${i#=}" ;;
-j|-json|--json) JSON=1 ;;
-) ;;
) let ii++; declare ARG$ii=${i} ;;
esac
done
#Print variables
echo key: $KEY
echo foo: $BAR
echo json: $JSON
echo ARG1: $ARG1
EOL
chmod 755 /tmp/testnoscript.sh
how it works:
$ /tmp/testnoscript.sh -k=testkey -f=bar -j arg1
key: testkey
foo: bar
json: 1
ARG1: arg1
how i want it work
$ /tmp/testnoscript.sh -f=bar -k testkey -j arg1
key: testkey
foo: bar
json: 1
ARG1: arg1
any ideas how to refactor argument parsing but save the current use cases logic? Thank you!
https://redd.it/whvgpt
@r_bash
Hi guys, i'm developing an toolkit for linux engineers and have some issues with auto completions due all my parsing logic depend on one string argument parsing and should contain "=" after key, i want to unify it such way it parse value after -k with space delimeter(or without delimeter at all) and also $ARG1 should not declaring if there "-k some_value" in arguments is there some simple and common way to achieve that?
this is my current implementation which works only -one_string=argument
cat > /tmp/testnoscript.sh << 'EOL'
#!/bin/bash
#Filter arguments by regex for security reasons
CLDOPTS="$(expr "$(tr '\n' ' ' <<< "${@}")" : '\(A-Za-z0-9/ :.,@_=+^*-\+\)' 2>/dev/null | tr ' ' '\n')"
#Simple parsing arguments
for i in ${CLDOPTS}
do
case $i in
-k=|-key=|--key=) KEY="${i#=}" ;;
-f=|-foo=|--foo=) BAR="${i#=}" ;;
-j|-json|--json) JSON=1 ;;
-) ;;
) let ii++; declare ARG$ii=${i} ;;
esac
done
#Print variables
echo key: $KEY
echo foo: $BAR
echo json: $JSON
echo ARG1: $ARG1
EOL
chmod 755 /tmp/testnoscript.sh
how it works:
$ /tmp/testnoscript.sh -k=testkey -f=bar -j arg1
key: testkey
foo: bar
json: 1
ARG1: arg1
how i want it work
$ /tmp/testnoscript.sh -f=bar -k testkey -j arg1
key: testkey
foo: bar
json: 1
ARG1: arg1
any ideas how to refactor argument parsing but save the current use cases logic? Thank you!
https://redd.it/whvgpt
@r_bash
GitHub
GitHub - classicdevops/cld: Infrastructure Management System
Infrastructure Management System. Contribute to classicdevops/cld development by creating an account on GitHub.
How can I create window-like GUIs without Gtk? Like raspi-config. I mean, this isn't all echos and colors, right?
https://redd.it/wjclpb
@r_bash
https://redd.it/wjclpb
@r_bash
making folders from read var with spaces in them
Hi, I have this snippet, and I can't figure out how to avoid creating several folders when the input i give has spaces in it.
Ie. I type in "house one on housestreet" and I get four folders rather than just one.
I guess that the var created is probably just a string and thusly is treated as such, getting split and all but I've tried to "isolate" in various ways putting (),{},'' around the var in all kinds of crazy ways, but no such luck...
How do I make the bloody thing understand that I just want a single folder with spaces in it's name? :)
#!/bin/bash
echo 'enter folder name:'
read -e thisnewfolder
mkdir -vp $thisnewfolder
https://redd.it/wjjprd
@r_bash
Hi, I have this snippet, and I can't figure out how to avoid creating several folders when the input i give has spaces in it.
Ie. I type in "house one on housestreet" and I get four folders rather than just one.
I guess that the var created is probably just a string and thusly is treated as such, getting split and all but I've tried to "isolate" in various ways putting (),{},'' around the var in all kinds of crazy ways, but no such luck...
How do I make the bloody thing understand that I just want a single folder with spaces in it's name? :)
#!/bin/bash
echo 'enter folder name:'
read -e thisnewfolder
mkdir -vp $thisnewfolder
https://redd.it/wjjprd
@r_bash
reddit
making folders from *read* var with spaces in them
Hi, I have this snippet, and I can't figure out how to avoid creating several folders when the input i give has spaces in it. Ie. I type in...
Whats the easiest way to pull this idea off ? sed ? is it even possible ?
https://redd.it/wlr9m6
@r_bash
https://redd.it/wlr9m6
@r_bash
splitting a string that contains single and double quoted strings without eval, possible?
I don't want to used eval to split a string as it may have errors in it and I don't want it to be run. The code below exemplifies what I want.
Any idea? other pitfalls I should think about?
direct=("abc" 'single ss quoted' "cd - e" not_quoted) ;
declare -p direct
gives: declare -a direct=([0\]="abc" [1\]="single ss quoted" [2\]="cd - e" [3\]="not_quoted")
​
s='"abc" '"'"'single ss quoted'"'"' "cd - e" not_quoted' ;
test_1=($s)
declare -p test_1
gives erroneous : declare -a test_1=([0\]="\\"abc\\"" [1\]="'single" [2\]="ss" [3\]="quoted'" [4\]="\\"cd" [5\]="-" [6\]="e\\"" [7\]="not_quoted")
eval "test_2=($s)"
declare -p test_2
gives: declare -a test_2=([0\]="abc" [1\]="single ss quoted" [2\]="cd - e" [3\]="not_quoted")
https://redd.it/wn83rz
@r_bash
I don't want to used eval to split a string as it may have errors in it and I don't want it to be run. The code below exemplifies what I want.
Any idea? other pitfalls I should think about?
direct=("abc" 'single ss quoted' "cd - e" not_quoted) ;
declare -p direct
gives: declare -a direct=([0\]="abc" [1\]="single ss quoted" [2\]="cd - e" [3\]="not_quoted")
​
s='"abc" '"'"'single ss quoted'"'"' "cd - e" not_quoted' ;
test_1=($s)
declare -p test_1
gives erroneous : declare -a test_1=([0\]="\\"abc\\"" [1\]="'single" [2\]="ss" [3\]="quoted'" [4\]="\\"cd" [5\]="-" [6\]="e\\"" [7\]="not_quoted")
eval "test_2=($s)"
declare -p test_2
gives: declare -a test_2=([0\]="abc" [1\]="single ss quoted" [2\]="cd - e" [3\]="not_quoted")
https://redd.it/wn83rz
@r_bash
reddit
splitting a string that contains single and double quoted strings...
I don't want to used eval to split a string as it may have errors in it and I don't want it to be run. The code below exemplifies what I want. ...
bash help: open the installed text editor
Hi, fairly new to bash here. need to open a plaintext file depending upon the installed editor.
if gedit is installed - open gedit, otherwise open the available editor, e.g. xed
which of the following would be the best practice (for the .bash_aliases file)
if -f /usr/bin/xed ; then
alias gedit="xed"
fi
or
if command -v xed &> /dev/null
then
alias gedit="xed"
fi
or better- open among the first available editor ("gedit" or "xed" or leafpad ..)
any room for improvements ? thanks (System is Linux mint cinnamon)
https://redd.it/wo7jr3
@r_bash
Hi, fairly new to bash here. need to open a plaintext file depending upon the installed editor.
if gedit is installed - open gedit, otherwise open the available editor, e.g. xed
which of the following would be the best practice (for the .bash_aliases file)
if -f /usr/bin/xed ; then
alias gedit="xed"
fi
or
if command -v xed &> /dev/null
then
alias gedit="xed"
fi
or better- open among the first available editor ("gedit" or "xed" or leafpad ..)
any room for improvements ? thanks (System is Linux mint cinnamon)
https://redd.it/wo7jr3
@r_bash
reddit
bash help: open the installed text editor
Hi, fairly new to bash here. need to open a plaintext file depending upon the installed editor. if gedit is installed - open gedit, otherwise...
output hex data from xattr to create icns file
I'm trying to extract the icon from an xattr of a file. Using xattr to get the "com.apple.ResourceFork" in hex format i use:
xattr -px com.apple.ResourceFork file
and save the output to a variable
var="$(xattr -px com.apple.ResourceFork file)"
then using variable expansion i remove the first bytes until i reach 69 (icns magic number is 69 63 6E 73)
var=${var#*69 63 6E 73}
next i output the variable and append "69 63 6E 73" to the beginning to restore the magic number.
echo "69 63 6E 73$var" > output.txt
if i take the hex data from the output.txt and insert it into a hexeditor to save it then it works and the .icns is created.
i want to do this programmatically in bash/zsh without having to save it manually.
tried using
touch icon.icns
to create an empty file then
echo "69 63 6E 73$var" > icon.icns
just transforms the output file into an ASCII file.
i'm not stuck to my method, any working method is acceptable to me.
​
Edit: ive posted the same question on [stackoverflow](https://stackoverflow.com/questions/73354927/output-hex-data-from-xattr-to-create-icns-file) and including the link here for future users.
https://redd.it/wogoce
@r_bash
I'm trying to extract the icon from an xattr of a file. Using xattr to get the "com.apple.ResourceFork" in hex format i use:
xattr -px com.apple.ResourceFork file
and save the output to a variable
var="$(xattr -px com.apple.ResourceFork file)"
then using variable expansion i remove the first bytes until i reach 69 (icns magic number is 69 63 6E 73)
var=${var#*69 63 6E 73}
next i output the variable and append "69 63 6E 73" to the beginning to restore the magic number.
echo "69 63 6E 73$var" > output.txt
if i take the hex data from the output.txt and insert it into a hexeditor to save it then it works and the .icns is created.
i want to do this programmatically in bash/zsh without having to save it manually.
tried using
touch icon.icns
to create an empty file then
echo "69 63 6E 73$var" > icon.icns
just transforms the output file into an ASCII file.
i'm not stuck to my method, any working method is acceptable to me.
​
Edit: ive posted the same question on [stackoverflow](https://stackoverflow.com/questions/73354927/output-hex-data-from-xattr-to-create-icns-file) and including the link here for future users.
https://redd.it/wogoce
@r_bash
Stack Overflow
output hex data from xattr to create icns file
I'm trying to extract the icon from an xattr of a file.
Using xattr to get the "com.apple.ResourceFork" in hex format i use:
xattr -px com.apple.ResourceFork file
and save the output to a
Using xattr to get the "com.apple.ResourceFork" in hex format i use:
xattr -px com.apple.ResourceFork file
and save the output to a
BASH programming video: user input, looping and text splitting with IFS/read
https://www.youtube.com/watch?v=baN8_IscVSY
https://redd.it/wq284v
@r_bash
https://www.youtube.com/watch?v=baN8_IscVSY
https://redd.it/wq284v
@r_bash
YouTube
Programming BASH #2
Continuing our journey into BASH programming, we'll handle user input, loop through data in different ways and make use of BASH's powerful built-in text splitting feature.
This episode covers:
- outputting text using echo and printf
- handling user input…
This episode covers:
- outputting text using echo and printf
- handling user input…
Running Script As Other User - Inside Script
I have a bash noscript that I wrote that is designed to be run as a user, but that will be executed as root (on a Mac via MDM). Running this noscript using sudo -i -u user bash --rcfile /Folder/noscript.sh works and runs all aspects of the noscript as the user. But my preference would be to not actually run it like that but to have everything, including switching to the user, within the noscript. I've done some searching and found instructions on the opposite problem, being a user and trying to run a noscript as root, but not my issue of being root and wanting to run as a user. Ideally, I would detect first if a user is logged in (using
https://redd.it/wqxoxe
@r_bash
I have a bash noscript that I wrote that is designed to be run as a user, but that will be executed as root (on a Mac via MDM). Running this noscript using sudo -i -u user bash --rcfile /Folder/noscript.sh works and runs all aspects of the noscript as the user. But my preference would be to not actually run it like that but to have everything, including switching to the user, within the noscript. I've done some searching and found instructions on the opposite problem, being a user and trying to run a noscript as root, but not my issue of being root and wanting to run as a user. Ideally, I would detect first if a user is logged in (using
$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )) and then run the noscript as that logged in user. I played around with things like sudo -i -u user without success. Hoping that someone here might have a better idea. Thank you!https://redd.it/wqxoxe
@r_bash
reddit
Running Script As Other User - Inside Script
I have a bash noscript that I wrote that is designed to be run as a user, but that will be executed as root (on a Mac via MDM). Running this noscript...
I want real world examples of what do you actually use Bash for.
Hi, it seems like everyone is recommending me to learn Bash but no one really explain me why.
When I asked them what do you use it for, they said "everything" and that's it.
​
Could you guys give me 1-2 examples of what do you use it for, in your daily life.
How does it make you life easier?
​
P.S. Sorry for my English.
https://redd.it/wrb25x
@r_bash
Hi, it seems like everyone is recommending me to learn Bash but no one really explain me why.
When I asked them what do you use it for, they said "everything" and that's it.
​
Could you guys give me 1-2 examples of what do you use it for, in your daily life.
How does it make you life easier?
​
P.S. Sorry for my English.
https://redd.it/wrb25x
@r_bash
reddit
I want real world examples of what do you actually use Bash for.
Hi, it seems like everyone is recommending me to learn Bash but no one really explain me why. When I asked them what do you use it for, they said...
bashflix - Bash noscript that combines several open source tools to stream video on MacOS and Linux.
https://github.com/andretavare5/bashflix
https://redd.it/wtg24n
@r_bash
https://github.com/andretavare5/bashflix
https://redd.it/wtg24n
@r_bash
GitHub
GitHub - andretavare5/bashflix: Video streaming on MacOS and Linux.
Video streaming on MacOS and Linux. Contribute to andretavare5/bashflix development by creating an account on GitHub.
Entering an interactive CLI loop
I have an application with an interactive CLI. Fairly simple c++ using stdIO with an infinite loop and command parsing. Works really well in a terminal.
I can call this program fine from a noscript like this:
printf "cmd1 cmd2 cmd3 printstatus cmd4 cmd5" | ./myprog
I want to be able to call this program and then take actions from it in a noscript, like:
./myprog -args
#magic missing step
printf "cmd1"
printf "cmd2"
result= printf "printstatus"
if( $result == "active")
printf exit
fi
Etc.
Is there an easy way to create this?
https://redd.it/wtdejn
@r_bash
I have an application with an interactive CLI. Fairly simple c++ using stdIO with an infinite loop and command parsing. Works really well in a terminal.
I can call this program fine from a noscript like this:
printf "cmd1 cmd2 cmd3 printstatus cmd4 cmd5" | ./myprog
I want to be able to call this program and then take actions from it in a noscript, like:
./myprog -args
#magic missing step
printf "cmd1"
printf "cmd2"
result= printf "printstatus"
if( $result == "active")
printf exit
fi
Etc.
Is there an easy way to create this?
https://redd.it/wtdejn
@r_bash
reddit
Entering an interactive CLI loop
I have an application with an interactive CLI. Fairly simple c++ using stdIO with an infinite loop and command parsing. Works really well in a...
Filling an associative Array inside a function using a nameref variable
Hello guys,
I have a question for you. I'm writing a noscript that's supposed to check certain PCs over ssh. To achieve this, I have an associative array `declare -A test_results` outside the function. Inside the function, I try to fill it with strings that are supposed to be printed to stdout in the end of the noscript. Like this:
function check_pc{
# $1 = Room name, $2 = pc number, $3 = Array test_results
local -n result=$3
if ! ssh $SSH_OPTIONS $SSH_USER@$1-pc$2.$DOMAIN echo test >/dev/null; then
result[$1-pc$2]="$1-pc$2 is unreachable\n"
# V_ECHO contains "echo" if run with -v option
$V_ECHO "[Debug] In function check_pc - Content of result varibale for $1-pc$2: >>> ${result[$1-pc$2]} <<< [SSH]"
return 1
fi
}
Imagine my room name is n040 and pc number is 10. Inside the function it'll output `${result[n040-pc10]}` just fine: "n040-pc10 is unreachable\\n". Outside of the function though, `$test_results[n040-pc10]` is empty.
This function is being called in a loop with many machines simultaneously like this:
...
declare -A test_results
...
for (( pc_count=0; $pc_count<=${PC[$lab_count]}; pc_count=pc_count+1 )); do
printf -v PC_COUNT "%02d" $pc_count
check_pc ${LAB[$lab_count]} $PC_COUNT test_results &
done
...
Why is `$test_results` empty? Can anyone help me out here pls? Maybe there are smarter ways of doing this?
pls no roasting, constructive criticism is welcome. I'm not experienced with bash noscripts.
Thank you :)
https://redd.it/wvq8fo
@r_bash
Hello guys,
I have a question for you. I'm writing a noscript that's supposed to check certain PCs over ssh. To achieve this, I have an associative array `declare -A test_results` outside the function. Inside the function, I try to fill it with strings that are supposed to be printed to stdout in the end of the noscript. Like this:
function check_pc{
# $1 = Room name, $2 = pc number, $3 = Array test_results
local -n result=$3
if ! ssh $SSH_OPTIONS $SSH_USER@$1-pc$2.$DOMAIN echo test >/dev/null; then
result[$1-pc$2]="$1-pc$2 is unreachable\n"
# V_ECHO contains "echo" if run with -v option
$V_ECHO "[Debug] In function check_pc - Content of result varibale for $1-pc$2: >>> ${result[$1-pc$2]} <<< [SSH]"
return 1
fi
}
Imagine my room name is n040 and pc number is 10. Inside the function it'll output `${result[n040-pc10]}` just fine: "n040-pc10 is unreachable\\n". Outside of the function though, `$test_results[n040-pc10]` is empty.
This function is being called in a loop with many machines simultaneously like this:
...
declare -A test_results
...
for (( pc_count=0; $pc_count<=${PC[$lab_count]}; pc_count=pc_count+1 )); do
printf -v PC_COUNT "%02d" $pc_count
check_pc ${LAB[$lab_count]} $PC_COUNT test_results &
done
...
Why is `$test_results` empty? Can anyone help me out here pls? Maybe there are smarter ways of doing this?
pls no roasting, constructive criticism is welcome. I'm not experienced with bash noscripts.
Thank you :)
https://redd.it/wvq8fo
@r_bash
reddit
Filling an associative Array inside a function using a nameref...
Hello guys, I have a question for you. I'm writing a noscript that's supposed to check certain PCs over ssh. To achieve this, I have an associative...
How do I copy data from a USB port into a file ? $cat <port> , but for binary ?
I need to send a command to an oscilloscope via a USB port. I need to put the binary reply into a file.
Right now I am using this:
echo ":SYST:UTIL:READ? 1,33554432" > /dev/usbtmc0; cat /dev/usbtmc0 > reply.bin
It works well for text replies but seems to mess up binary replies. How do I put the binary reply that comes from /dev/usbtmc0 into a file ?
Thanks
Solution
$cat actually works in this situation. There was a problem with the downstream file processing that led me to say that $cat wasn't working. I was wrong.
​
​
https://redd.it/wvyaue
@r_bash
I need to send a command to an oscilloscope via a USB port. I need to put the binary reply into a file.
Right now I am using this:
echo ":SYST:UTIL:READ? 1,33554432" > /dev/usbtmc0; cat /dev/usbtmc0 > reply.bin
It works well for text replies but seems to mess up binary replies. How do I put the binary reply that comes from /dev/usbtmc0 into a file ?
Thanks
Solution
$cat actually works in this situation. There was a problem with the downstream file processing that led me to say that $cat wasn't working. I was wrong.
​
​
https://redd.it/wvyaue
@r_bash
reddit
How do I copy data from a USB port into a file ? $cat <port> , but...
I need to send a command to an oscilloscope via a USB port. I need to put the binary reply into a file. Right now I am using this: echo...
I created bash noscripts to automate and simplify getting my homelab up and running.
https://github.com/rishavnandi/Boiler_plates
https://redd.it/wwjchw
@r_bash
https://github.com/rishavnandi/Boiler_plates
https://redd.it/wwjchw
@r_bash
GitHub
GitHub - rishavnandi/Boiler_plates: Docker Compose Boilerplates
Docker Compose Boilerplates. Contribute to rishavnandi/Boiler_plates development by creating an account on GitHub.
Can you add features such as Syntax highlighting and Auto-suggestions to Bash?
Recently I've started to experiment with Bash and I have one question. Is their a way to add Syntax highlighting and Autosuggestions to Bash? The one thing I LOVE about the Fish shell is it's out-of-the-box autosuggestion feature that not only tries to auto-complete commands, but also suggests from your command history, this is the one thing I think Fish dose better than any other shell and I'm hoping that I can replicate it on Bash.
I know it's challenging to implement autosuggestions in Bash because it's a limitation of GNU readline - Bash uses readline for entering and editing text, but this means you're limited to using readline features for dynamic line editing. E.g you cannot dynamically change the color of text a user inputs using readline (limiting the implementation of Fish-like syntax highlighting).
Do any workarounds exist to make syntax highlighting and autosuggestions work in Bash? Any help would be much appreciated.
https://redd.it/wylaoj
@r_bash
Recently I've started to experiment with Bash and I have one question. Is their a way to add Syntax highlighting and Autosuggestions to Bash? The one thing I LOVE about the Fish shell is it's out-of-the-box autosuggestion feature that not only tries to auto-complete commands, but also suggests from your command history, this is the one thing I think Fish dose better than any other shell and I'm hoping that I can replicate it on Bash.
I know it's challenging to implement autosuggestions in Bash because it's a limitation of GNU readline - Bash uses readline for entering and editing text, but this means you're limited to using readline features for dynamic line editing. E.g you cannot dynamically change the color of text a user inputs using readline (limiting the implementation of Fish-like syntax highlighting).
Do any workarounds exist to make syntax highlighting and autosuggestions work in Bash? Any help would be much appreciated.
https://redd.it/wylaoj
@r_bash
reddit
Can you add features such as Syntax highlighting and...
Recently I've started to experiment with Bash and I have one question. Is their a way to add Syntax highlighting and Autosuggestions to Bash? The...
How to interpret ANSI escape characters in a file?
Is there an easy way to read a text file (presumably a log of a previously executed command) and interpret any escape sequences so that
EDIT: Figured it out
https://redd.it/wzk2ly
@r_bash
Is there an easy way to read a text file (presumably a log of a previously executed command) and interpret any escape sequences so that
cat'ing the new log file is equivalent to viewing it in a text editor? For example, if the output of the command sends the letter A, a backspace, and then the letter E, the log file (after being interpreted) should only contain the character E and nothing else.EDIT: Figured it out
https://redd.it/wzk2ly
@r_bash
Unix & Linux Stack Exchange
How to convert escape sequences to text while preserving display format?
I have a text file that contains (ANSI ?) escape sequences:
When I cat the file I get formatted output:
How do I save / pipe the output of the text file to a new file so that the control codes are
When I cat the file I get formatted output:
How do I save / pipe the output of the text file to a new file so that the control codes are