Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bash]

Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead.

5
votes
0answers
485 views

Assign both menu-complete and dynamic-complete-history to TAB

Is there a way for me to assign both menu-complete and dynamic-complete-history to Tab (or one to Tab and the other to Tab-Tab) in .inputrc? I'm thinking there might be a way to setup a function and ...
4
votes
0answers
125 views

xmodmap key bindings reset when I open a new tab in the shell

When I open a shell in ranger with shift-s, open vim and then open a shell with :sh or open a new shell tab with ctrl-shift-t, my xmodmap keybindings (swapped caps lock and escape keys) are reset. ...
4
votes
0answers
426 views

How to bind to ctrl+x in bash?

I appear to be using GNU bash, version 4.4.12, though it's possible my organization has modified it from HEAD. I'm trying to bind ctrl+x: $ bind -x '"\C-t": "echo testing"' <I press ctrl+t> ...
4
votes
0answers
149 views

is it possible to colors the prompt for (reverse-i-search) context menu?

I am using fedora 25 but I think this is a general behavior on unix system. When I ctrl+r in a command-line environment I can start to type in and anything I type will get to be matched backward in ...
4
votes
0answers
161 views

Exported bash functions sometimes visible from Perl

My Redhat 9, OpenBSD 4.9, FreeBSD 10, Macos X, LinuxMint 17.3, and Ubuntu 14.04.4 all print OK when running this: myfunc() { echo OK; } export -f myfunc perl -e open\(\$fh,\"\|-\",\"@ARGV\"\)\;close\$...
4
votes
0answers
3k views

“-bash: /root/.bashrc: Permission denied” when logging in

I have this server running Centos 7. Every time I log in (remotely or locally) with every user I get an error. If I log in as root I get -bash: /root/.bashrc: Permission denied If I log in as a ...
4
votes
0answers
270 views

Replacing a running binary on read-only file system

I have a simple updater bash script, which replaces files by removing the incident old files and copying new files from an archive to the running embedded target root file system. This way, the script ...
4
votes
0answers
633 views

Understanding inotifywait, pipes and buffers

I want to monitor every file change in a directory with inotifywait. inotifywait shall write to a FIFO buffer, which then can be read, leisurely. While experimenting with relatively huge amounts of ...
4
votes
0answers
282 views

Bash command not found due to stray garbage characters

What is the cause of this behavior? $ cd ../ $ bash: $'\210\210cd': command not found This happens sometimes (rarely) when I enter a command, there is no visible character preceding the cd, still it ...
3
votes
0answers
62 views

XFCE - Blank text in terminal

I've just performed a fresh install of Arch Linux on my laptop (ThinkPad A485, though that's probably not relevant here), and installed XFCE4. Everything seems to be working with the exception of one ...
3
votes
0answers
41 views

Pasting into terminal including comments issue

This is somehow a follow-up to my last question: Pasting multiple commands into terminal stops at user input Pasting the following to the terminal works as expected: ( echo test1 # some comment echo ...
3
votes
0answers
30 views

Log background jobs started in all the manually started shells?

Sometimes I accidentally killed all the background jobs in a shell, for example, because The window of a Window's program running under Wine is not in the front by default. I know I can use ...
3
votes
0answers
284 views

Bash 4.4 change color vi mode

I am using +~ $ bash --version GNU bash, version 4.4.0(1)-release (x86_64-unknown-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://...
3
votes
0answers
471 views

How to set the default color of output / things typed in Bash

When I am typing or viewing text on my terminal, the color is white. Any command after I type my prompt is white, and the default output (stdout) is white. I looked and my terminal emulator does not ...
3
votes
0answers
248 views

Control characters in a terminal with an active foreground process

Say I have a process running in a terminal in the foreground. While it is active I can type commands, hit return, and those will be executed once the process is done. Now say furthermore I would like ...
3
votes
0answers
81 views

Why does bash appear faster on an Ubuntu VM than on the host MacOS?

This is the laptop sitting in front of me right now: On it is installed VMWare Fusion 8.5.3 with an Ubuntu 16.04 64 bit VM. I ran the following little test to compare performance between bash on the ...
3
votes
0answers
867 views

bash parent and child signal handling

Quick summary: parent and child in a loop, each can either trap or not trap signals. I don't understand why, if the child traps and the parent doesn't, the parent is not terminated. The detail: I ...
3
votes
0answers
1k views

MSYS2: ulimit: max user processes: cannot modify limit: Invalid arguments

I was a victim of a fork bomb of my own construction, and I couldn't figure out how to stop it short of logging off. (Tools like ProcMon were too slow to get ahead of the newly started processes). ...
3
votes
0answers
64 views

How to resize images to fit all content on minimal canvas?

I'm trying to quickly check for differences between separate iterations of a web site using ImageMagick's compare. But it refuses to compare images of different size, and doesn't seem to have an ...
3
votes
0answers
795 views

Unable to type apostrophe in the terminal

I'm unable to type the character ' in urxvt. Nothing happens if I press the button to type it. If I copy something to the clipboard that contains ', and paste it with shift+insert, the text is ...
3
votes
0answers
353 views

How do I execute a program in Xfce and make it use another xfwm4 theme other than the default one?

I want to run a python script (the one in the answer to Python - how to make transparent window with gtk.Window but not with Gtk.) that displays a transparent window. I'm running it from a bash script ...
3
votes
0answers
910 views

gnome-terminal cmd leaving processes open after closing parent window

The following simple command should demonstrate my issue: gnome-terminal --tab -t "Tab 1" -e "/bin/bash" --tab -t "Tab 2" -e "/bin/bash" This should open a new window with two tabs and an active ...
2
votes
0answers
27 views

Change output width (columns) of processes created by gnu parallel

I'm trying to save the output of a command into files and it seems to work fine. However, when opening one of the files, I can see that output was limited to 80 characters width. How can I ensure that ...
2
votes
0answers
30 views

Clear the kill ring in Bash (or kill an empty string with Ctrl-k)

In Bash and other shells in emacs mode, there are these awesome kill/yank shortcuts (see man readline), for example: Ctrl+k: "kill-line": this deletes (and save into a cut buffer) all the current ...
2
votes
0answers
43 views

Using killall with -u and -o options

I wanted to confirm some details with the killall -o option. I tested it on some ssh connections I created under the user rick. First I printed a list of all of ricks ssh connections along with the ...
2
votes
0answers
68 views

Legitimate reasons for a program to intercept, internally handle and ignore SIGINT signal

We know that - aside from SIGKILL and SIGSTOP - a program can intercept IPC signals, and run its internal handler circumventing the operation of the default handler. I can think of at least one very ...
2
votes
0answers
32 views

vi mode of bash 5: How to invoke plain editor instead of fc?

Apparently since the release of bash v. 5 some weeks ago (witnessed on Archlinux and Debian Buster), the default behaviour of invoking the editor in vi mode has changed. set -o vi <Esc>v bash ...
2
votes
0answers
57 views

How can I properly use an American flag emoji in my bash prompt?

I want to use an American flag emoji in my bash prompt (i.e. PS1 environment variable). However, the American flag emoji causes the terminal cursor to offset an extra character to the right. 🇺🇸 is ...
2
votes
0answers
52 views

autocomplete with inline variable setting

I use bash version 4.4.19(1)-release (x86_64-apple-darwin17.3.0) on my Mac with MacOS (10.13.6) For example, I have autocomplete set up for the AWS CLI, via complete -C '/Users/jstoner/Library/...
2
votes
0answers
55 views

Knowing when bash is done running a command through a FIFO pipe

I'm trying to link a web-based terminal with bash. My current attempt to do so is spawning a shell pointing a FIFO pipe to its input, like this: Terminal 1 $ mkfifo pipe $ bash <> pipe file1 ...
2
votes
0answers
73 views

Difference between closing terminal and closing shell on child processes

Opening a new terminal and typing the command firefox& inside, ps -l gives : 4 R 1000 23132 23104 99 80 0 - 2177945 - pts/27 00:00:07 firefox If the shell is closed with the command ...
2
votes
0answers
222 views

lftp mirror error

I have a problem with a script that I am trying to write. Ideally, the script should compress the folders and then send the zipped files to the ftp server creating the folder as the name of the ...
2
votes
0answers
101 views

how to avoid writing failed bash commands to bash_history

I'm looking for a nuanced history behavior I haven't seen anywhere. During a terminal session, I want every command, regardless of exit status, to be appended to the in-memory history. Upon exiting ...
2
votes
0answers
81 views

Ulimit not respected in GNU bash OSX

I am seeing a strange issue with gnu bash in OSX. The value of ulimit -f is being changed by the bash itself. Small reproducible code: #!/usr/local/bin/bash ulimit -f 1 echo "Value: $(ulimit -f)" ...
2
votes
0answers
119 views

history -c does not reset $HISTCMD to 1

TL;DR: If your history begins to truncate (e.g., your HISTSIZE is 400 but your history number is 500), resetting your history with history -c will clear HISTSIZE or fewer lines from your history, and ...
2
votes
0answers
152 views

How do I call current “.bash_history” from a script?

There is a program called "thefuck" that you can install and it uses python to take the last command you ran and give you ...what you probably meant. It's a cool program. I wanted to create a script ...
2
votes
0answers
196 views

Dropdown menu in Bash

How can I make Bash show a typical Web-style dropdown menu when typing the argument to a custom-made command? (Making it work with builtins or Standard Unix commands is secondary.) The crucial parts ...
2
votes
0answers
52 views

Bash search prompt overlapping value

Running a docker alpine container, my PS1 is: PS1="\u@\h:\w\$ " So when logging into the container, you get root@worker:/$ So if I type in something like root@worker:/$ cd /tmp/dir/path And then ...
2
votes
0answers
92 views

bash tab auto-complete for java keytool

Can anyone point me to a bash tab autocomplete for the java keytool command? Learning & writing this seems not simple, and I presume that someone has felt this pain before.
2
votes
0answers
111 views

How to highlight output from diff command and make them side by side?

I have two files $ cat file1.txt UUXX:1 UUXX:2 $ cat file2.txt UUXX:3 UUXX:1 I want to use this command $ diff --old-group-format=$'\e[0;31m%<\e[0m' --new-group-format=$'\e[0;31m%>\e[0m' --...
2
votes
0answers
82 views

How to find out which process is deleting a file without root permissions?

I am manually running a program in a cluster by copying the executable file to each node, running it and them copying back the output to the server node. Suddenly, I noticed that a file that takes ...
2
votes
0answers
67 views

What are the contexts where Bash doesn't perform word splitting and globbing?

Bash doesn't perform word splitting in globbing in these cases: LHS or RHS of an assignment, except for indexed arrays var=$value # simple variable declare -A hash key=...
2
votes
0answers
285 views

Background task in bash script

I'm trying to write a "while true" bash script that responds to events. (It's a webhook for git push notifications, but that's not very relevant at this point.) I could block, waiting for the next ...
2
votes
0answers
61 views

osx dtruss doesn't report opening ~/.bash_profile while tracing bash?

Let's assume I have this line at the start of my ~/.bash_profile: echo "*** THIS IS ~/.bash_profile RUNNING ***" On a Linux machine (Ubuntu 14.04), I can inspect which files bash loads at startup ...
2
votes
0answers
142 views

Shell job-control: possible to “rename” a running job?

In the shell (I'm using Bash), I frequently use Ctrl-Z and fg to suspend one job and foreground another. An example would be suspending a running instance of Vim and foregrounding a previously ...
2
votes
0answers
55 views

Git-Branch status

In my .bashrc file, I have those two blocks : 1- # get current branch in git repo function parse_git_branch() { BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` ...
2
votes
0answers
126 views

Non-anchored history substring search in bash

There are 2 existing ways to get something like this easily: zsh's history-substring-search plugin bash's ctrl+r mode The problem with zsh is that it's not on many systems. The problem with bash's ...
2
votes
0answers
121 views

bash custom tab completion with wildcards

I have a script (let's call it myscript) and I want to enable autocomplete arguments for files with a specific extension (e.g. .txt). I can do this simply with: complete -f -X '!*.txt' myscript Then,...
2
votes
0answers
218 views

“gnome-terminal -e tmux ./” keeps opening terminals forever

I recently asked this question. I won't ever use the first method. gnome-terminal -e tmux ./ if I put that in .zshrc or .bashrc (both shells, same problem). If I use that, the terminal will keep ...
2
votes
0answers
237 views

Stream audio from bash cgi script

I have a bash script which I would like to call as cgi to stream audio. The script looks like this: #!/bin/bash echo "Content-type: audio/wav" echo "" rtl_fm -f 89.9M -M fm -s 170k -A std -l 0 -E ...