Stack Exchange Network

Stack Exchange network consists of 174 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
479 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
91 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
357 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
137 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
157 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
259 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
278 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
110 views

dnf tab completion hangs

Tab completion is hanging when attempting to complete package names. eg dnf info fire[TAB]. How can I fix this? It works in general for bash, and also for completing dnf options, but not for package ...
3
votes
0answers
39 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
263 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
453 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
236 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
78 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
748 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
923 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
61 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
752 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
599 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 ...
3
votes
0answers
350 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
873 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
21 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
47 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
47 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
36 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
67 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
144 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
83 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
65 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
93 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
146 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
133 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
48 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
97 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
78 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
60 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
248 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
53 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
132 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
54 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
111 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
114 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
207 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
219 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 ...
2
votes
0answers
612 views

Getting number of failed login attempts sins last successful login / CentOS 7

Trying to create a custom login statistical welcome for SSH login session but would like to keep the original message too, which is : Last failed login: Sun Feb 19 03:52:25 CET 2017 from 125.x.x.x ...
2
votes
0answers
24 views

What configuration is loaded at login after user config?

I’m trying to bootstrap Gentoo Prefix and I’m hitting a snag because Prefix insists that LD_LIBRARY_PATH is unset in a login shell. So I put unset LD_LIBRARY_PATH at the very end of both my ~/....
2
votes
0answers
108 views

How to explicitly set the tabname of a new gnome-terminal?

I want to explicity rename a tab in gnome-terminal on startup of the tab. I don't want to use gnome-terminal --title flag as that gets reset by my systems bashrc file after whatever else is supposed ...
2
votes
0answers
491 views

How to reliably detect stdin pipe in Bash in batch mode?

I need a way to test whether input to my Bash script has been piped to stdin when the script is run in batch mode. The method I use when I run the script interactively (the test [ -p /dev/stdin ]) ...
2
votes
0answers
546 views

How to time the execution of parallel commands

I am trying to write a bash script that launches n commands in the background and then waits for each command to finish. I can easily get the time it took to execute all the commands using time sh ...