When I move around to different directories in terminal, I end up with really long prompts with the full directory path of my current working directory. This is a lot of extra clutter when I really just want an active terminal in that directory and can remember where I am. How do I modify what is shown in the prompt? I'm going to find out!
Current:
xxxxx@xxxxx:/xxxxx/xxxxxxxxx/xxxx/xxxxxxxx/xxxxxxxx$
What I'd like is probably just the name of the current directory without the full path.
It turns out that the prompt is very easy to modify! You just edit your .bashrc to add a line:
cd
gedit .bashrc (I'm not on board with emacs yet)
Here are some cool options I found on various forums:
This one removes all directory information and makes the prompt be an arrow:
export PS1="-->"
This one prints the full path, but then gives you a new line with a simple > for the prompt:
export PS1="\w\n>"
This does exactly what I want! I'm so used to the $ as a prompt that I want to keep it, but this gives me just the current directory without the full path! I also learned that the part of the path I am interested in is called the "basename of the current working directory."
export PS1="\W$"
New prompt:
xxxxxxxxx$
I might decide that I want the xxxxxx@xxxxx part back in the prompt, but for now, I'll keep the prompt short.
source:
http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
Wednesday, April 10, 2013
Friday, April 5, 2013
ipython went and changed the way they do configuration files
When I start ipython, I get a much longer returned message than I should:
ipython
/usr/lib/python2.7/dist-packages/IPython/utils/path.py:420: UserWarning: Found old IPython config file u'/home/rperry/.ipython/ipy_user_conf.py' (modified by user)
warnings.warn("Found old IPython config file %r (modified by user)"%f)
/usr/lib/python2.7/dist-packages/IPython/utils/path.py:420: UserWarning: Found old IPython config file u'/home/rperry/.ipython/ipythonrc' (modified by user)
warnings.warn("Found old IPython config file %r (modified by user)"%f)
/usr/lib/python2.7/dist-packages/IPython/utils/path.py:432: UserWarning:
The IPython configuration system has changed as of 0.11, and these files will
be ignored. See http://ipython.github.com/ipython-doc/dev/config for details
of the new config system.
To start configuring IPython, do `ipython profile create`, and edit
`ipython_config.py` in <ipython_dir>/profile_default.
If you need to leave the old config files in place for an older version of
IPython and want to suppress this warning message, set
`c.InteractiveShellApp.ignore_old_config=True` in the new config.
`c.InteractiveShellApp.ignore_old_config=True` in the new config.""")
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
So the problem here is that when I had an older version of ipython, I made some config files-- apparently ipy_user_conf.py, and ipythonrc which are not outdated by my current ipython 0.12.1. What were those configuration files doing anyways? How do I change the configurations in the current version? I'll find out!
ipy_user_conf.py seems to be all factory settings. I removed it:
rm -r ipy_user_conf.py
ipythonrc seems to be all factory settings. I removed it:
rm -r ipythonrc
Now when I start ipython, I don't get so much text returned!
ipythonPython 2.7.3 (default, Aug 1 2012, 05:14:39)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
But, what configurations can I modify if I want to? Following the directions from the original, lengthy printout to the screen:
ipython profile create
creates
~/.ipython/profile_default/ipython_config.py which can be modified
there is also a startup directory in which you can place python scripts that you want run every time you start ipython!
~/.ipython/profile_default/startup (there is a README there explaining)
I put a script there that says:
import holopy as hp
this will make startup slower, but I won't have to type that again!!! Plus, if I just want a python session to use as a simple calculator, then I can always just run:
python instead of ipython.
You can make non-default configurations as well... for now, I'll just stick to the one. Hopefully I won't be bothered by the extra time it takes to start ipython.
ipython
/usr/lib/python2.7/dist-packages/IPython/utils/path.py:420: UserWarning: Found old IPython config file u'/home/rperry/.ipython/ipy_user_conf.py' (modified by user)
warnings.warn("Found old IPython config file %r (modified by user)"%f)
/usr/lib/python2.7/dist-packages/IPython/utils/path.py:420: UserWarning: Found old IPython config file u'/home/rperry/.ipython/ipythonrc' (modified by user)
warnings.warn("Found old IPython config file %r (modified by user)"%f)
/usr/lib/python2.7/dist-packages/IPython/utils/path.py:432: UserWarning:
The IPython configuration system has changed as of 0.11, and these files will
be ignored. See http://ipython.github.com/ipython-doc/dev/config for details
of the new config system.
To start configuring IPython, do `ipython profile create`, and edit
`ipython_config.py` in <ipython_dir>/profile_default.
If you need to leave the old config files in place for an older version of
IPython and want to suppress this warning message, set
`c.InteractiveShellApp.ignore_old_config=True` in the new config.
`c.InteractiveShellApp.ignore_old_config=True` in the new config.""")
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
So the problem here is that when I had an older version of ipython, I made some config files-- apparently ipy_user_conf.py, and ipythonrc which are not outdated by my current ipython 0.12.1. What were those configuration files doing anyways? How do I change the configurations in the current version? I'll find out!
ipy_user_conf.py seems to be all factory settings. I removed it:
rm -r ipy_user_conf.py
ipythonrc seems to be all factory settings. I removed it:
rm -r ipythonrc
Now when I start ipython, I don't get so much text returned!
ipythonPython 2.7.3 (default, Aug 1 2012, 05:14:39)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
But, what configurations can I modify if I want to? Following the directions from the original, lengthy printout to the screen:
ipython profile create
creates
~/.ipython/profile_default/ipython_config.py which can be modified
there is also a startup directory in which you can place python scripts that you want run every time you start ipython!
~/.ipython/profile_default/startup (there is a README there explaining)
I put a script there that says:
import holopy as hp
this will make startup slower, but I won't have to type that again!!! Plus, if I just want a python session to use as a simple calculator, then I can always just run:
python instead of ipython.
You can make non-default configurations as well... for now, I'll just stick to the one. Hopefully I won't be bothered by the extra time it takes to start ipython.
Thursday, April 4, 2013
Latex symbols with other meanings
% is the character to start a comment in LaTex, so I always have to look up how to include the actual % in the text of my document. It's simple:
\%
\%
Latex/Revtex problems
I'm writing a paper that has to follow revtex style. I'm getting errors about the citations when I try to compile (but the output looks fine). Let me try to get the most recent version of texlive:
apt-get install texlive
tex --version
TeX 3.1415926 (TeX Live 2009/Debian) kpathsea version 5.0.0 Copyright 2009 D.E. Knuth. There is NO warranty. Redistribution of this software is covered by the terms of both the TeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the TeX source. Primary author of TeX: D.E. Knuth.
hrm. This might be too outdated.
solved! see update in comment.
Python, oh how you care about spaces and tabs, and intro to Emacs
Python is really picky about indentation (spaces and tabs). Because of this, the resulting code is very readable. The internet seems to somewhat agree that 4 spaces = one indent level. I would like to be able to make my tabs always be 4 spaces so that I don't have to hit the space bar so much.
I have been using gedit, so I'll figure out how to do it there!
Edit--> Preferences--> Editor--> Insert spaces instead of tabs
and change the Tab width to 4
oooh, Display line numbers! That's an option I'll select as well. Gedit shows you the current row and column at the bottom of the window, but I'll see how I like always seeing the line numbers.
Ok, but really, I should graduate to Emacs... I find Emacs very intimidating for all it's shortcut keys and how it doesn't use the microsoft-era shortcut keys I'm used to. One step at a time though.
Dash Home --> type Emacs, Enter
Now I'm going to lock it to my toolbar. What a commitment!
The tutorial is telling me that two main keys are Control and Alt (Meta). The abbreviations for these are C and M.
C-<chr> means the same thing as Ctrl+<chr> (in all the programs I'm used to)
M-<chr> means Alt+<chr>
To quit:
C-x C-c
It worked! Hrm, but that exited my session, okay, starting it back up to get back to the tutorial.
C-g quits a command partway through typing it
There are three major commands for paging up and down a text document:
C-v see one screenful further down
M-v see one screenful further up
C-l center the screenful on your current cursor (just top to bottom, not left to right)
Continuing to type C-l moves the line with the cursor in it progressively to the
1 time: center
2 times: top
3 times: bottom
and it keeps cycling through.
That's enough for now! C-x C-c
I have been using gedit, so I'll figure out how to do it there!
Edit--> Preferences--> Editor--> Insert spaces instead of tabs
and change the Tab width to 4
oooh, Display line numbers! That's an option I'll select as well. Gedit shows you the current row and column at the bottom of the window, but I'll see how I like always seeing the line numbers.
Ok, but really, I should graduate to Emacs... I find Emacs very intimidating for all it's shortcut keys and how it doesn't use the microsoft-era shortcut keys I'm used to. One step at a time though.
Dash Home --> type Emacs, Enter
Now I'm going to lock it to my toolbar. What a commitment!
The tutorial is telling me that two main keys are Control and Alt (Meta). The abbreviations for these are C and M.
C-<chr> means the same thing as Ctrl+<chr> (in all the programs I'm used to)
M-<chr> means Alt+<chr>
To quit:
C-x C-c
It worked! Hrm, but that exited my session, okay, starting it back up to get back to the tutorial.
C-g quits a command partway through typing it
There are three major commands for paging up and down a text document:
C-v see one screenful further down
M-v see one screenful further up
C-l center the screenful on your current cursor (just top to bottom, not left to right)
Continuing to type C-l moves the line with the cursor in it progressively to the
1 time: center
2 times: top
3 times: bottom
and it keeps cycling through.
That's enough for now! C-x C-c
Bzr, what revision number are you at?
In a terminal in the directory where your branch is,
bzr log -r-1
You can increment the number to see the most recent commit messages and revision numbers (bzr log -r-1, bzr log -r-2, etc.).
Wednesday, April 3, 2013
Bazaar version control, commit messages
I use Bazaar for version control with the team I wrote code with. This team likes Bazaar so much that we even use it for Latex documents in which we are writing up papers. Today when I went to commit changes I got an error about my commit message being empty even though I hadn't had any time to edit it yet! I learned a work around:
bzr commit -m "Type message here"
alternatively, this should work if you have a saved text file of the commit message:
bzr commit -F commitmessage.txt
bzr commit -m "Type message here"
alternatively, this should work if you have a saved text file of the commit message:
bzr commit -F commitmessage.txt
Subscribe to:
Posts (Atom)