Hot answers tagged

2

I use a simple function: mpvs() { local file="$1" mpv --sub-file="${file%.*}".srt "$file" } If you want to test for the presence of subtitle files with different extensions, you could use a more complex approach: #!/usr/bin/env bash # Play subtitles for a film if they exist movie="$1" mdir="${movie%/*}" name="${movie##*/}" cd "$mdir" for file in ...


1

If you can set your script up this way #!/bin/bash . config . /path/to/sub-script Any variables initialised in config should become available to the main script and any scripts it sources. Explanation It seems your script was launching a new non-interactive shell process, shell variables initialised in the parent script would not have been available ...


1

You can export your variables: VAR=foo export VAR or: export VAR=foo However, these variables will be visible in the environment of all subprocesses.


1

I would put environment variables in .bash_login or .bash_profile, since they are (when exported) inherited to subshells and don't need to be reset for every shell invocation. Not that resetting them would cost practically anything, but in case I want to set an envvar to something else for the duration of a subshell. That's hard to do if the .bashrc ...


1

Since the question is essentially asking for opinions, you will get different answers. A good design practice, for example, uses as few places as possible to provide a given feature. Some put information like this in the system area to reduce the amount of work done by users to customize their shell environment. In my environment, I use the terminal ...


1

I put PS1 code in bashrc all the time. My code is as follows: export PS1="\[\e[01;37m\][\[\e[0m\]\[\e[01;32m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[01;34m\]\h\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[00;37m\]\t\[\e[0m\]\[\e[01;37m\] \W \e[1;37m(\e[1;32m|\e[1;33m|\e[1;31m|\e[1;37m]\\$ \[\e[0m\]" I use a different PS1 for root (/root/.bashrc) - red username, ...


1

Something like: ssh host; echo "Reconnect?"; while read; do ssh host; echo "Reconnect?"; done in your command should do the job. It connects to your host and when the connection is lost, it asks you for a reconnect. Or just simply as you wanted: ssh host; bash will connect to your host and when the connection ends, it gives you new shell


1

Where to export After having read https://bitbucket.org/padavan/rt-n56u/wiki/EN/UsingCron a good way to export configuration variables for both crontab and shell usage, is to insert the /opt related variables into /opt/etc/profile. Where and how to source To use ("source") the variables in cron it is suggested to: create a shell-wrapper script source ...



Only top voted, non community-wiki answers of a minimum length are eligible