Questions tagged [interactive]

89 questions
105
votes
3 answers

Why does bashrc check whether the current shell is interactive?

On my Arch install, /etc/bash.bashrc and /etc/skel/.bashrc contain these lines: # If not running interactively, don't do anything [[ $- != *i* ]] && return On Debian, /etc/bash.bashrc has: # If not running interactively, don't do anything [ -z…
terdon
  • 234,489
  • 66
  • 447
  • 667
23
votes
7 answers

Run script in a non interactive shell?

I have a cron job that is running a script. When I run the script via an interactive shell (ssh'ed to bash) it works fine. When the script runs by itself via cron it fails. My guess is that it is using some of the environmental variables set in the…
cwd
  • 44,479
  • 71
  • 146
  • 167
14
votes
8 answers

How can I disable the new history feature in Python 3.4?

Since upgrading to Python 3.4, all interactive commands are logged to ~/.python_history. I don't want Python to create or write to this file. Creating a symlink to /dev/null does not work, Python removes the file and recreates it. The documentation…
Lekensteyn
  • 20,173
  • 18
  • 71
  • 111
13
votes
1 answer

How would I detect a non-login shell? (In Zsh)

I want to create a script that runs when a Zsh instance starts, but only if the instance is: Non-login. Interactive I think I'm right to say .zshrc runs for all interactive shell instances, .zprofile and .zlogin run for all login shells, and…
Geeb
  • 2,061
  • 2
  • 16
  • 17
11
votes
2 answers

Zsh clear scrollback buffer

With Bash CtrlL will clear the screen but not scrollback buffer. In the past I have worked around this by using: tput reset However I have noticed that this command will not clear the scrollback buffer with Zsh. So, how is it done?
user327359
11
votes
2 answers

How to read user input when using script in pipe

General problem I want to write a script that interacts with the user even though it is in the middle of a chain of pipes. Concrete example Concretely, it takes a file or stdin, displays lines (with line numbers), asks the user to input a selection…
jmc
  • 408
  • 4
  • 13
11
votes
3 answers

How to do a text replacement in a big folder hierarchy?

I want to search and replace some text in a large set of files excluding some instances. For each line, I want a prompt asking me if I need to replace that line or not. Something similar to vim's :%s/from/to/gc (with the c to prompt for…
balki
  • 4,327
  • 5
  • 30
  • 44
10
votes
3 answers

Invoke a command/script disconnected from the controlling terminal?

I'm investigating the behaviour of a script that is normally run as an automated process (e.g. cron, Jenkins). The script can (eventually) invoke commands that behave differently (seeking user input) when run interactively; for example, patch will…
ecatmur
  • 245
  • 2
  • 9
10
votes
2 answers

Displaying usage comments in functions intended to be used interactively

I have a number of functions defined in my .bashrc, intented to be used interactively in a terminal. I generally preceded them with a comment describing its intended usage: # Usage: foo [bar] # Foo's a bar into a baz foo() { ... } This is fine…
dimo414
  • 1,727
  • 1
  • 16
  • 37
8
votes
2 answers

Is possible to define a bash script to run interactively by default?

I have written some scripts and stored them in my ~/bin folder. I'm already able to run them just by calling their title during a shell session. However, they aren't running interactively (I mean, my ~/.bashrc aliases are not loaded). Is there a way…
artu-hnrq
  • 267
  • 4
  • 14
7
votes
4 answers

How can I make rm -rf ask for confirmation just once at the directory level?

If I use rm -rfi, this asks me every time each file is deleted. If I have a list of rm -rf commands, how can I make it so that the machine asks me for confirmation just once (when trying to delete the directory itself)
chintogtokh
  • 171
  • 1
  • 3
6
votes
3 answers

Is there some interactive analogue of `mktemp` that helps to organize throw-away directories?

I often want a temporary directly where I can unpack some archive (or create a temporary project), see around some files. It is unpredictable in advance for how much time a particular directory may be needed. Such directories are often clutter home…
Vi.
  • 5,528
  • 7
  • 34
  • 68
6
votes
1 answer

Why does bash treat commandlines starting with dots specially?

I tried searching online for an answer, but the answer (if exists) is overshadowed by other applications of dot in shell scripting. So here goes. EDIT: Turns out it's related to Fedora's default configuration of command_not_found_handle, so it's not…
loa_in_
  • 388
  • 1
  • 9
5
votes
1 answer

Prompt for confirmation for every command

I'm writing a pretty ad-hoc install script for some thing. No much control constructs, basically just a list of commands. I'd like the user to confirm each command before it gets executed. Is there a way to let bash do that, without prefixing every…
MvG
  • 4,361
  • 2
  • 28
  • 42
5
votes
2 answers

Why no such non-interactive version of bashrc?

From what I understanding, a daemon is a background process, but daemon requires unique config file to set the environment variable. E.g. Hadoop daemon require hadoop-env.sh to set environment variable JAVA_HOME, you can't simply get the variable…
林果皞
  • 4,946
  • 2
  • 29
  • 45
1
2 3 4 5 6