Difference between revisions of "BASH Shortcuts"

From PrattWiki
Jump to navigation Jump to search
Line 29: Line 29:
 
instead.
 
instead.
  
== AFS Directory Shortcut ==
+
== <code>latex</code> and <code>dvipdf</code> in One Command ==
If you are in a class that is using the AFS space (specifically so that permission can be set and such), you may want to add a line to your <code>.bashrc</code> file to get there more efficiently.  The information on that is at the [[AFS Course Space]] page, specifically in the [[AFS_Course_Space#For_.2Fbin.2Fbash_.28newer_users.29|/bin/bash]] users section.
+
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 that having to type
 
 
== <code>latex</code> and <code>dvips</code> in One Command ==
 
Now that you need to run both <code>latex</code> and <code>dvips</code> to get a PostScript file for [[evince]] to look at, you may want to have a shorter way that having to type
 
 
<source lang="bash">
 
<source lang="bash">
 
latex FILE.tex
 
latex FILE.tex
dvips -t FILE.dvi
+
dvipdf FILE.dvi
 
</source>
 
</source>
 
every time.  To make a /bin/bash shortcut for that, add the following to your <code>.bashrc</code> file:
 
every time.  To make a /bin/bash shortcut for that, add the following to your <code>.bashrc</code> file:
Line 42: Line 39:
 
ltx() {
 
ltx() {
 
   latex $1.tex
 
   latex $1.tex
   dvips -t letter $1
+
   dvipdf $1
 
}
 
}
 
</source>
 
</source>
Line 58: Line 55:
 
then
 
then
 
   latex $1.tex
 
   latex $1.tex
   dvips -t letter $1
+
   dvipdf $1
 
else
 
else
 
   echo "ERROR: '$1.tex' not found"
 
   echo "ERROR: '$1.tex' not found"
Line 68: Line 65:
 
and it will run
 
and it will run
 
  latex FILE.tex
 
  latex FILE.tex
  dvips -t letter FILE.dvi
+
  dvidf FILE.dvi
 +
 
 +
 
 +
== Add, Commit, and Push to Git All In One! ===
 +
If you want t a short command that you can use to add files to a repository, commit them all, and push them, here's a shortcut for that:
 +
<source lang="bash">
 +
gitdone() {
 +
git add .
 +
git commit -a -m $1
 +
git push
 +
}
 +
</source>
 +
You must include a message when using this; for instance,
 +
<source lang="bash">
 +
gitdone 'My Message'
 +
<source>

Revision as of 20:41, 13 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.

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

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.

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 that 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() {
   latex $1.tex
   dvipdf $1
}

If you want a version that does some basic error-checking, use this one:

ltx() {
if [[ $1 = *.* ]]
then
  echo "ERROR: '$1' has dots.  ltx does not want dots"
  return
fi

if [[ -f $1.tex ]]
then
   latex $1.tex
   dvipdf $1
else
  echo "ERROR: '$1.tex' not found"
fi
}

From that point on, once the .bashrc runs to start your session, you can simply type

ltx FILE

and it will run

latex FILE.tex
dvidf FILE.dvi


Add, Commit, and Push to Git All In One! =

If you want t a short command that you can use to add files to a repository, commit them all, and push them, here's a shortcut for that:

gitdone() {
git add .
git commit -a -m $1
git push
}

You must include a message when using this; for instance, <source lang="bash"> gitdone 'My Message' <source>