Tag Info

New answers tagged

0

re: your solution of a loop every second: you could write to a file in /tmp, instead of in your home directory. And PS1=$(customW)$(< ~/.ps1)\$ ' would save a fork/exec of cat. re: the original question: how to get an async update to PS1: To start an async write to PS1: set PROMPT_COMMAND to a function that checks if the data is available. If it is, ...


1

Use export for environment variables. Environment variables are an operating system feature. Environment variables are inherited by child processes: if you set them in a shell, they're available in all the programs started by this shell. Variables used by many applications or by specific applications other than shells are environment variables. Here are a ...


1

I don't believe it is possible to make the behavior you desire the default / general behavior. Look here for details regarding "base permissions". For files the base permission is 666 or rw-rw-rw while for directories it is 777 or rwxrwxrwx. umask may further restrict base permissions, but cannot grant additional access. In other words, umask cannot be used ...


2

Here is a one liner: read -p "No of Repetitions?" repeat; for i in $(seq $repeat); do echo "This is $i"; done If you want to run this if $SSH_CONNECTION is non-empty: [[ -n $SSH_CONNECTION ]] && read -p "No of Repetitions?" repeat; for i in $(seq $repeat); do echo "This is $i"; done && indicates to run the next command only if the ...


1

See if this helps: #!/bin/bash echo -n "How many times should I run? " read numOfTimes for i in $(seq 1 $numOfTimes);do echo $i done Let's split the explanation into parts: echo -n presents the message in the screen and reads the user's response into variable numOfTimes. A bash for loop has the following structure: for i in [1 2 3 4 ... n ]; do X; done ...


4

The default shell for root on OS X is /bin/sh. Its sh is also a version of bash, but when invoked with the name sh Bash: tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interactive login shell, or as a non-interactive shell with the --login ...


1

The root user will try to execute the .bashrc file instead of the .bash_profile since you are not invoking a login shell. From the bash manual man bash: ~/.bash_profile The personal initialization file, executed for login shells ~/.bashrc The individual per-interactive-shell startup file Note the ~ where the .bashrc file needs ...


1

Because it is not considered as a "login shell" (which is invoked directly from login, or sshd) but simple "interactive shell". See here for example: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html So force su using login option i.e. with -l option: su -l Or put your environment into .bashrc file.


4

If your terminal is still open, type env: it will display all your environment variables. If it's a fresh install or if you never made any change, the most important variables are PATH (this one always exist) and LD_LIBRARY_PATH (may not exists, I'm not used to osx). For instance: $ env ... PATH=/usr/bin:/bin:/home/user/bin:/sbin ... It's also a common ...


2

You seem to be implicitly asking if there is a place in RAM where the contents of this file are stored. The answer is, "no." The file is simply read and executed during shell startup, then discarded. No Unix shell needs continuous access to its startup script(s). Some of the file's contents are still retrievable, per apaul's answer. There is a tiny chance ...


1

bash does read ~/.bashrc though even when non-interactive when invoked over ssh (a misfeature IMO, but would come handy to you here). So you could add to the top of ~/.bashrc on the remote host: if [ -n "$SSH_CLIENT" ] && [ "$SHLVL" = 0 ] && [ -n "${-##*[il]*}" ]; then . /etc/profile . ~/.bash_profile fi



Top 50 recent answers are included