Originally posted by: n0cmonkey
I don't. Generally. I move between systems that I don't necessarily own/run often enough that if I got used to an alias it would screw me up somewhere else.
# /etc/skel/.bashrc:
#Drag's Bash startup settings for interactive situations.
# colors for ls, etc.
alias ls="ls --color=auto"
alias gamex="X -layout Gaming :1.0"
#consule colors!
RED="\[\033[0;31m\]"
LRED="\[\033[1;31m\]"
GRN="\[\033[0;32m\]"
LGRN="\[\033[1;32m\]"
BLU="\[\033[0;34m\]"
LBLU="\[\033[1;34m\]"
PUR="\[\033[0;35m\]"
LPUR="\[\033[1;35m\]"
CYA="\[\033[0;36m\]"
LCYA="\[\033[1;36m\]"
YEL="\[\033[0;33m\]"
LYEL="\[\033[1;33m\]"
BRN="\[\033[0;33m\]"
GRY="\[\033[1;30m\]"
LGRY="\[\033[0;37m\]"
WHT="\[\033[1;37m\]"
NON="\[\033[0m\]"
# backgroundcolors
BGRY="\[\033[40m\]"
BRED="\[\033[41m\]"
BGRN="\[\033[42m\]"
BYEL="\[\033[43m\]"
BBLU="\[\033[44m\]"
BPUR="\[\033[45m\]"
BCYA="\[\033[46m\]"
BWHT="\[\033[47m\]"
# Things BASH understands:
# \a an ASCII bell character (07)
# \d the date in "Weekday Month Date" format
# \e an ASCII escape character (033)
# \h the hostname up to the first `.'
# \H the hostname
# \j the number of jobs currently managed by the shell
# \l the basename of the shell's terminal device
# \n newline
# \r carriage return
# \t the current time in 24-hour HH:MM:SS format
# \T the current time in 12-hour HH:MM:SS format
# \@ the current time in 12-hour am/pm format
# \u the username of the current user
# \v the version of bash (e.g., 2.00)
# \V the release of bash, version + patchlevel
# \w the current working directory
# \W the basename of the current working dir
# \! the history number of this command
# \# the command number of this command
# \$ if the effective UID is 0, a #, otherwise a $
# \\ a backslash
PS1="\n-{$RED\u$LGRN@$GRN\h$NON}-$PUR \t$GRN\n$BRED\w >:$NON "
export PS1
set -o vi
#! /bin/bash
# drag's jtry script
if javac $1 ; then
java $1
else
echo "error"
mv $1 ${1//.java/}
fi
Originally posted by: drag
That would probably entail a script.
I am not sure what your talking about with java and javac. Not to familar with java. But a bash script to do something like that would be easy to do. Then you stick it in a path (I use ~/bin for my scripts).
Something like:
#! /bin/bash
# drag's jtry script
if javac $1 ; then
java $1
else
echo "error"
mv $1 ${1//.java/}
fi
Something like that. Make that executable, stick it in a folder in your PATH.
Then say if you wanted to run cowpower.java then you would go:
jtry cowpower.java
And I think that will work, I haven't tested it any though.
When you run a script, arguments get assigned to 1, 2, 3, etc (thru 9) variables.
The ${variable//string/replacementstring} you can use to replace a string of text in a variable with a different string.
Also the
if commandname
is a test, if the command runs and returns with a 0 (means it ran successfully) then bash will run the command in then "then" statement, otherwise it will run the command in the "else" statement if it exists.
So on and so forth. Bash is fairly powerfull scripting language, although for complex things your usually better off using something like perl or python.
# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/login.defs
#umask 022
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# the rest of this file is commented out.
# set PATH so it includes user's private bin if it exists
#if [ -d ~/bin ] ; then
# PATH=~/bin:"${PATH}"
#fi
# do the same with MANPATH
#if [ -d ~/man ]; then
# MANPATH=~/man:
# export MANPATH