Tag Info

New answers tagged

2

I recommend just manually creating the prompt yourself. All you have to do is set up a few variables, and then your code for setting the prompt becomes readable. In my bashrc file, I have this: #Set variables for foreground colors fgRed=$(tput setaf 1) ; fgGreen=$(tput setaf 2) ; fgBlue=$(tput setaf 4) fgMagenta=$(tput setaf 5) ; fgYellow=$(tput ...


0

Geeqie and Thunar both use functions that utilize g_get_home_dir() from GNOME's glib. Quoting from g_get_home_dir() in the API Reference: Gets the current user's home directory. As with most UNIX tools, this function will return the value of the HOME environment variable if it is set to an existing absolute path name, falling back to the passwd file in ...


2

You can check whether the current is interactive by searching for i in $-: if expr "$-" : '.*i' >/dev/null; then echo interactive fi


1

You can test if the output of the script (i.e. rc file) is a terminal if not; if it is it should be safe to output text, and if not a terminal don't output anything: if [ -t 0 ]; then # check your jobs here and print any info you want to see fi


2

Try the following two commands and see what you get: echo "$(printf 'a')" echo '$(printf 'a')' Essentially, single quotes will give you your "original raw string", while anything in double quotes will be evaluated before being assigned to your alias. However, you might notice that the single quotes around 'a' are missing from the output of second ...


3

Notice that the command substitution $(printf ....) is inside double-quotes: alias catvu="LC_ALL=C sed \"$(printf 's/[^\t -\176\200-\377]/^&/g')\"|LC_ALL=C tr '\0-\10\13-\37\177' '@-HK-_?'" Consequently, the command substitution $(printf ....) is executed before the alias is defined. Let's take a simpler example that illustrates the same point. ...


1

In XTerm, you can use the control sequences in your .bashrc or such. Like: if tty -s; then case $HOSTNAME in server1) echo -e '\e]11;darkgray\a\e]10;black\a' ;; server2) echo -e '\e]11;darkblue\a\e]10;gray\a' ;; esac fi Other terminal emulators have similar features. In Putty, you can configure the color directly, not sure if these control ...


1

You can try piping through a sed command that replaces the beginning of line (^) with whatever prefix you want (|), e.g.: some_command | sed 's/^/| /' This will work for simpler commands, but will fail as more complex applications position the cursor in some nontrivial ways, and will also delay the output of several commands (since they switch from line ...



Top 50 recent answers are included