djl / vcprompt Goto Github PK
View Code? Open in Web Editor NEWVersion control information in your prompt
License: BSD 3-Clause "New" or "Revised" License
Version control information in your prompt
License: BSD 3-Clause "New" or "Revised" License
Since 3ecd930, specifying a timeout actually causes vcprompt to run for exactly that many milliseconds. Tested on Python 2.7.1 in OS X. Patch based on 6a10066:
diff --git a/bin/vcprompt b/bin/vcprompt
index e8880f1..9e1dbb6 100755
--- a/bin/vcprompt
+++ b/bin/vcprompt
@@ -235,6 +235,7 @@ def main():
output = vcprompt(options)
if options.newline:
output += '\n'
+ timer.cancel()
return output
When I added vcprompt to my prompt, I keep seeing this error
File "/home/nomad/bin/vcprompt", line 541
from __future__ import with_statement
SyntaxError: from __future__ imports must occur at the beginning of the file
The README should be updated to https://github.com/xvzf/vcprompt/raw/master/bin/vcprompt for the curl example. The difference is the "https" protocol. Otherwise, curl gives you this:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/0.7.67</center>
</body>
</html>
As the title suggests, whenever I cd into a directory that has version control in it, my prompt never updates to reflect that. I've followed the Install instructions verbatim:
$ curl -sL https://github.com/xvzf/vcprompt/raw/master/bin/vcprompt > ~/bin/vcprompt
$ chmod 755 ~/bin/vcprompt
$ export PS1="$(vcprompt) $PS1"
I then cd into any project directory covered by svn, git, or hg (I've tried all three). Just running the command correctly tells me any information:
$ vcprompt
svn:trunk
However, my prompt still stays as $
. If I wait to run the export PS1="$(vcprompt) $PS1"
line until I'm in a project directory already, then the prompt is correctly updated to be svn:trunk $
. However, that svn:trunk
stays in the front frozen like that no matter what I cd into from that point on. So even moving to my home directory still shows svn:trunk $
as my prompt.
This occurs both on my OSX and Ubuntu workstations. Both are running Python version 2.6.x. Both are using bash as the shell. To prevent any conflicts, I've made sure that the only line in my .bash_profile
or .bashrc
has been adding ~/bin
to my $PATH
.
Do you have any idea what might be causing this?
In line 249 both modified and untracked are initialized as options.unknown. But they never get overwritten if the repo has no modifications and no untracked files. These two variables should have a default value of the empty string, and only be set to options.unknown if returncode != 0.
Changeset 24c1c70 introduced the following code:
os.path.relpath(...)
But os.path.relpath
is only available since Python version 2.6 according to the documentation.
Is it possible to change the code to be compatible with Python 2.5 and 2.4, e.g. using code similar to what can be found in hg-tools or this blog post/BareNecessitites?
Or should the README just be updated to state that you need at least Python 2.6?
but currently vcprompt checks if a line starts with M
you have the man pages… you have the install script… beautiful things could happen here, people.
Today, when I update my Ubuntu 12.10 x64, I receive this message:
Traceback (most recent call last):
File "/bin/vcprompt", line 672, in <module>
prompt = main()
File "/bin/vcprompt", line 226, in main
output = vcprompt(options)
File "/bin/vcprompt", line 179, in vcprompt
conf = vcs(options)
File "/bin/vcprompt", line 621, in svn
process = Popen(command.split(), stdout=PIPE, stderr=PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
My prompt is: PS1="\n\u@\h:\w $(vcprompt -f '%b%m%u')\n> "
Anyway, thanks.
diff --git a/bin/vcprompt b/bin/vcprompt
index 9e1dbb6..48e45ef 100755
--- a/bin/vcprompt
+++ b/bin/vcprompt
@@ -572,7 +572,7 @@ def hg(options):
}
-@vcs([".svn/entries"])
+@vcs([".svn/entries", ".svn/wc.db"])
def svn(options):
"""
Subversion
if you have "subdir" in .gitignore, shouldn't vcprompt stay quiet if you cd $repo/subdir?
I have been using a git-specific prompt for a few months, but am now trying out vcprompt as I want this info for other vcs as well, especially when I am in a subversion checkout within a git directory as then the git-only prompt gets confusing. So thanks for creating/expanding this!
One thing in vcprompt that I am missing from the git-specific prompt, is information on files that are staged and changes that have not yet been pushed upstream. This might be useful for other distributed vcs as well. See this example:
mauritsvanrees@procyon:Products.CMFPlone (master u=) $ # launch editor, make changes
mauritsvanrees@procyon:Products.CMFPlone (master * u=) $ git st
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: docs/CHANGES.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
mauritsvanrees@procyon:Products.CMFPlone (master * u=) $ git add docs/CHANGES.txt
mauritsvanrees@procyon:Products.CMFPlone (master + u=) $ git ci -m "history"
[master 617259c] history
1 files changed, 3 insertions(+), 0 deletions(-)
mauritsvanrees@procyon:Products.CMFPlone (master u+1) $ git st
# On branch master
# Your branch is ahead of 'plone/master' by 1 commit.
#
nothing to commit (working directory clean)
So there is a *
when there are unstaged changes, a +
when there are staged changes, and a +1
(or +2
etc) when there are commits that have not been pushed upstream.
With vcprompt there is only a '+' when there are unstaged changes. For the record, I have VCPROMPT_FORMAT=' (%s:%b%m%u)
The git-specific prompt is from this gist: https://gist.github.com/1240533
Would you consider adding that information? I might create a pull request if I feel up to the task, but I should not let myself get distracted from other programming tasks. ;-)
Thanks.
I get this when I try to use vcprompt
[code]
File "/usr/bin/vcprompt", line 284
with open(file, 'r') as f:
^
SyntaxError: invalid syntax
[/code]
To see this problem simply do the following:
mkdir vctest
cd vctest
git init
vcprompt
Here's the error:
~/S/P/test ♪ vcprompt
Traceback (most recent call last):
File "/Users/bjeanes/.config/misc/vcprompt.py", line 676, in <module>
print main()
File "/Users/bjeanes/.config/misc/vcprompt.py", line 298, in main
systems=options.systems, unknown=options.unknown)
File "/Users/bjeanes/.config/misc/vcprompt.py", line 234, in vcprompt
prompt = vcs(path, format, unknown)
File "/Users/bjeanes/.config/misc/vcprompt.py", line 524, in git
with open(hash_file, 'r') as f:
IOError: [Errno 2] No such file or directory: '/Users/bjeanes/Sites/Personal/test/.git/refs/heads/master'
From svn st --help:
Second column: Modifications of a file's or directory's properties
' ' no modifications
'C' Conflicted
'M' Modified
I realize it's debatable whether a changed property is a modification, but I lean towards calling it a modification since this indicates there is something in the working copy that should be checked-in.
In git, another important local status is whether there is something in the stash. Unfortunately, forgetting this status is all too easy...
My thoughts would be that when inside a submodule, vcprompt should show the status of the submodule git repo, not the parent.
Notable test case: https://github.com/mozilla/mozilla-central
This has been mentioned before other places, but I wonder if there is any way for vcprompt to auto-detect when it's "taking too long". I would rather not have to try to modify my ps1
depending on the directory.
1589 glind ~/gits/mozilla-central [git:master?] $ time vcprompt
[git:master?]
real 0m3.476s
user 0m0.421s
sys 0m1.610s
1590 glind ~/gits/mozilla-central [git:master?] $ time git status
real 0m6.032s
user 0m0.556s
sys 0m1.389s
Here is an excerpt from my prompt. I am using Mac OS X 10.8.5 with a slightly customized prompt in .basrc
.
Last login: Sun Sep 22 13:48:13 on ttys000
!me@~/t:someotherbranch+? !> brew list
autoconf git libtool pkg-config
automake libgpg-error libyaml readline
bash-completion libksba openssl vcprompt
!me@~/t:someotherbranch+? !> git --version
git version 1.8.4
!me@~ !> cd t
!me@~/t !> source ~/.bashrc
!me@~/t:master+? !> git checkout -b someotherbranch
M a1.txt
Switched to a new branch 'someotherbranch'
!me@~/t:master+? !> source ~/.bashrc
!me@~/t:someotherbranch+? !>
.bashrc
PS1="\n!\u@\w$(vcprompt -f ":%b%m%u") !> "
PS2=" !> "
PS3=" !> "
PS4=" !> "
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
On Mac OS X 10.6 with stock python (2.6.1):
e.g.:
$ vcprompt --format "%s:%b" # In a non-versioned folder, with format
[m:"
$ vcprompt --format "%s:%b" # In a versioned folder, with format
[m:"git:master
$ vcprompt # In a versioned folder, without format
git:master
thanks for this great tool.
it was nice and easy for me to clone the repo and use easy_install to install vcprompt -- maybe the readme should mention this option.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.