Tag Info

Hot answers tagged

7

I have a script ~/bin/setprompt that is executed by my .bashrc, which contains: RESET="\[\017\]" NORMAL="\[\033[0m\]" RED="\[\033[31;1m\]" YELLOW="\[\033[33;1m\]" WHITE="\[\033[37;1m\]" SMILEY="${WHITE}:)${NORMAL}" FROWNY="${RED}:(${NORMAL}" SELECT="if [ \$? = 0 ]; then echo \"${SMILEY}\"; else echo \"${FROWNY}\"; fi" # Throw it all together ...


6

I use a simple two-liner: [\w]\n\u@\h> or [\w]\n\u@\h# if root. People look at me like I'm crazy for using a two-line prompt, but I hate only seeing the last part of the current path, and I work with paths that are too long to put the whole thing on the same line as the input area.


6

Use a heredoc: ssh host.domain.com /bin/bash << EOF big ugly commands lots of them EOF


5

That script makes my eye bleed. Get rid of all of the variables storing fragments of the command (and the unnecessary input redirect on the grep), and see where that gets you. The quoting is almost certainly screwed up in ways you don't even want to imagine. In bourne shell, I'd write something like this: today="$(date +"%m\/%d\/%y")" filetoday="$(date ...


4

Use key-based logins, not password-based. Then you can add a (list of) "forced command(s)" to your public ssh key (in the "options" field in case of SSH1) which is installed on the server (in ~/.ssh/authorized_keys file for SSH1, ~/.ssh2/authorization for SSH2). Make your forced command so that your desired shell is called... More: You can associate at ...


4

The same way. From bash(1): If a command is terminated by the control operator &, the shell exe- cutes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0.


4

This, however, is the most awesomest one I've ever seen: PS1='\[\033[0m\]\[\033[0;31m\].:\[\033[0m\]\[\033[1;30m\][\[\033[0m\]\[\033[0;28m\]Managing \033[1;31m\]\j\[\033[0m\]\[\033[1;30m\]/\[\033[0m\]\[\033[1;31m\]$(ps ax | wc -l | tr -d '\'' '\'')\[\033[0m\]\[\033[1;30m\] \[\033[0m\]\[\033[0;28m\]jobs.\[\033[0m\]\[\033[1;30m\]] ...


4

sh is just a standard executable, which is always a specific shell. There is no magic to detect which shell to use. % whereis sh sh: /bin/sh % ls -l /bin/sh lrwxrwxrwx 1 root root 4 Mar 29 11:53 /bin/sh -> dash On Ubuntu systems, /bin/sh is (by default) a symlink to dash, which is a minimal POSIX shell intended for non-interative use. If you run sh ...


4

Generally, your shell will prefer its own builtin over any external program. One notable gotcha in regards to this is when you've defined an alias for the command.


3

I don't believe this is possible, at least with openssh-based systems. If you have the ability, a better solution might be to sftp up a shell-script file, and then execute it with the method you posted. It would have the advantage of minimizing the amount of escaping needed, but would leave a file behind that would have to be removed (perhaps as the last ...


3

I'm a fan of the default Cygwin bash prompt: PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ ' or without colors: PS1='\n\u@\h \n\$ ' looks like: username@hostname $ ls -l


2

I like including the time in mine. Gives me sort of a built in time around my commands: PS1="[\t \u@\h:\w]$ " Though after seeing a few of these, it makes me want to make mine a little smarter!


2

Here's mine (scroll to the right to see more interesting bit): '-------------------------------------------------------------------------------\n${debian_chroot:+($debian_chroot)}[\w]\n\u@\h\[\033[1;33m\]\[\033[0m\]($(__git_ps1 "%s")$(parse_git_dirty))$ Here's the result: ------------------------------------------------------------------------------- ...


1

Similar to chaos's answer, I kind of like \u@\h:\w\n\u@\h:\$ which gives me root@host-10548:/var/www/site.org root@host-10548:$ By including the user/host on the first line, I can easily copy that entire path line when I am using SCP, or rsync to send some files to that directory.


1

In ksh: In my .profile, I set the following var (so this var is only set once per session ever, no matter how many 'su's I do: PCH=\> In my .kshrc I have: if let "${SPID:-0} != $$"; then PCHS="$PCHS$PCH" fi I become root with the following alias, rather than "su" (kroot is a root user with a ksh shell instead of sh (solaris) or bash (linux): ...


1

I have a prompt that is simple, but uses colors to give some extra info: drewble:~$ The color of the hostname (drewble, in this case) is different on each machine - when I get a new machine that I work on, I choose an arbitrary color for that machine. That way, when I have a lot of terminals open, it's easy to tell which machine they're SSHed into and ...


1

It isn't a shell prompt, but it is a customization that might fit the spirit of what you are asking. I set the following environment variable: if [ -z "$PROMPT_COMMAND" ]; then export PROMPT_COMMAND='history -a' else export PROMPT_COMMAND="history -a;$PROMPT_COMMAND" fi This way, if I have multiple terminals open via screen or whatever, I won't ...


1

export PS1="\[`if [[ $? = 0 ]]; then echo '\e[32m\h\e[0m'; else echo '\e[31m\h\e[0m' ; fi`:\w\n$ " This displays: hostname:~ $ With 'hostname' in green if the last executed command return code was '0' and red if it was > '0'.


1

Probably a better way to write this logically, but I think this might do it: #!/usr/bin/perl use strict; use warnings; my $previous_line = ''; while(<>) { if ( /pattern/ ) { if ( (! ($previous_line =~ /^#/)) && (! ($previous_line =~ /pattern/))) { print $previous_line; } } elsif (! ($previous_line =~ ...


1

It's backgrounding "nothing". The ampersand also functions as a command delimiter like ;. You'll find that ; echo 'hi there' does (in this case) essentially the same thing. These, however, are different: sleep 10 ; echo 'hi' & echo 'there' sleep 10 ; echo 'hi' ; echo 'there'


1

check this one out http://stackoverflow.com/questions/3288344/cshell-tab-completion-case-insensitive i usually don't use csh, mostly bash in which things like this are much easier.


1

Csh's builtin echo doesn't support this feature, so you'll need to type the path to the system's echo command. Additionally, you need to either add an additional backslash or put the backslash in quotes. Either of these should work. /usr/bin/echo test\\ttest > test or /usr/bin/echo 'test\ttest' > test Contrary to what I posted before, you do not ...


1

This command: rm /root/.history should do what you're after, though it may be getting written back out when you logout. If you simply want history never stored, you could do this: echo > /root/.history chflags schg /root/.history which empties the file then sets it immutable.


1

Not 100% sure if HISTSIZE variable exists in (t)csh, but it might. So try with setenv HISTSIZE 0 rm -f /root/.history And see if it helps.


1

This might works for you too not sure for (t)csh shell history -w OR rm .bash_history



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