Difference between revisions of "BASH Shortcuts"
Line 5: | Line 5: | ||
than this page applies to you; if not, see the [[TCSH Shortcuts]] page. | than this page applies to you; if not, see the [[TCSH Shortcuts]] page. | ||
+ | |||
+ | == Required .bash_profile File == | ||
If you are a bash shell user, you will also need to have a <code>.bash_profile</code> in your CIFS home directory (the ~ directory) for the shortcuts to work. The contents of the profile should be: | If you are a bash shell user, you will also need to have a <code>.bash_profile</code> in your CIFS home directory (the ~ directory) for the shortcuts to work. The contents of the profile should be: | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 20: | Line 22: | ||
</source> | </source> | ||
− | == | + | == Main Shortcuts == |
− | + | These are the two shortcuts people in the Fall 2015 EGR 103 class copied during week 6. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == <code>latex</code> and <code>dvipdf</code> in One Command == | + | === <code>latex</code> and <code>dvipdf</code> in One Command === |
Now that you need to run both <code>latex</code> and <code>dvipdf</code> to get a PDF file for [[evince]] to look at, you may want to have a shorter way than having to type | Now that you need to run both <code>latex</code> and <code>dvipdf</code> to get a PDF file for [[evince]] to look at, you may want to have a shorter way than having to type | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 68: | Line 64: | ||
latex FILE.tex | latex FILE.tex | ||
dvidf FILE.dvi | dvidf FILE.dvi | ||
− | |||
=== Add, Commit, and Push to Git All In One! === | === Add, Commit, and Push to Git All In One! === | ||
− | If you want | + | If you want a short command that you can use to change to your EGR103 folder, add files to a repository, commit them all, and push them, here's a shortcut for that: |
<source lang="bash"> | <source lang="bash"> | ||
− | + | gitpush103() { | |
+ | cd ~/EGR103 | ||
git add . | git add . | ||
if [[ -n $1 ]] | if [[ -n $1 ]] | ||
Line 84: | Line 80: | ||
} | } | ||
</source> | </source> | ||
− | You | + | You could include a message when using this; for instance, |
<source lang="bash"> | <source lang="bash"> | ||
− | + | gitpush103 'My Message' | |
</source> | </source> | ||
If you do not, the default message is <code>no message</code> | If you do not, the default message is <code>no message</code> | ||
+ | |||
+ | == Others == | ||
+ | === Stayin' Alive === | ||
+ | There is currently a 10-minute inactivity timeout on remote logins. In order to eliminate this, add the following line to your <code>.bashrc</code> file: | ||
+ | <source lang="bash"> | ||
+ | xeyes -geometry 1x1-1-1 & | ||
+ | </source> | ||
+ | This will start the <code>xeyes</code> program off screen and in the background. With this program running, however, your session will not time out. If that puts an xeyes window on your screen, try | ||
+ | xeyes -geometry 1x1-1-100 & | ||
+ | instead. |
Revision as of 15:30, 29 September 2015
The following is a list of shortcuts Pratt students may want to add to their .bashrc
profile. This, first of all, assumes that they are using the bash shell. To check this, type
echo $SHELL
If the result is
/bin/bash
than this page applies to you; if not, see the TCSH Shortcuts page.
Contents
Required .bash_profile File
If you are a bash shell user, you will also need to have a .bash_profile
in your CIFS home directory (the ~ directory) for the shortcuts to work. The contents of the profile should be:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
Main Shortcuts
These are the two shortcuts people in the Fall 2015 EGR 103 class copied during week 6.
latex
and dvipdf
in One Command
Now that you need to run both latex
and dvipdf
to get a PDF file for evince to look at, you may want to have a shorter way than having to type
latex FILE.tex
dvipdf FILE.dvi
every time. To make a /bin/bash shortcut for that, add the following to your .bashrc
file:
ltx() {
MyFile=$1
MyFile=${MyFile%%.*}
latex $MyFile.tex
dvipdf $MyFile.dvi
}
Note that to use it, you do not need to include the ".tex" at the end of your file name, but you can. The script will automatically take the extension off whatever you gave as an input.
If you want a version that does some basic error-checking, use this one:
ltx() {
MyFile=$1;
MyFile=${MyFile%%.*}
if [[ -f $MyFile.tex ]]
then
latex $MyFile.tex
dvipdf $MyFile.dvi
else
echo "*ERROR*: '$MyFile.tex' not found"
fi
}
From that point on, once the .bashrc
runs to start your session, you can simply type
ltx FILE
or
ltx FILE.tex
and it will run
latex FILE.tex dvidf FILE.dvi
Add, Commit, and Push to Git All In One!
If you want a short command that you can use to change to your EGR103 folder, add files to a repository, commit them all, and push them, here's a shortcut for that:
gitpush103() {
cd ~/EGR103
git add .
if [[ -n $1 ]]
then
git commit -a -m $1
else
git commit -a -m 'no message'
fi
git push
}
You could include a message when using this; for instance,
gitpush103 'My Message'
If you do not, the default message is no message
Others
Stayin' Alive
There is currently a 10-minute inactivity timeout on remote logins. In order to eliminate this, add the following line to your .bashrc
file:
xeyes -geometry 1x1-1-1 &
This will start the xeyes
program off screen and in the background. With this program running, however, your session will not time out. If that puts an xeyes window on your screen, try
xeyes -geometry 1x1-1-100 &
instead.