diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index 4be7bea5..4ea0e6b3 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -91,7 +91,7 @@ segments that you may want to customize right away: "name": "weather", "priority": 50, "args": { - "unit": "f", + "unit": "F", "location_query": "oslo, norway" } }, diff --git a/docs/source/installation/troubleshooting-common.rst b/docs/source/installation/troubleshooting-common.rst index a0142e38..c5b4b2e2 100644 --- a/docs/source/installation/troubleshooting-common.rst +++ b/docs/source/installation/troubleshooting-common.rst @@ -60,3 +60,15 @@ My vim statusline is not displayed completely and has too much spaces * Be sure you have ``ambiwidth`` option set to ``single``. * Alternative: set :ref:`ambiwidth ` to 2, remove fancy dividers (they suck when ``ambiwidth`` is set to double). + +When using `z ` powerline shows wrong number of jobs +------------------------------------------------------------------------------- + +This happens because `z ` is launching some jobs in +the background from ``$POWERLINE_COMMAND`` and these jobs fail to finish before +powerline prompt is run. + +Solution to this problem is simple: be sure that :file:`z.sh` is sourced +strictly after :file:`powerline/bindings/bash/powerline.sh`. This way background +jobs are spawned by `z ` after powerline has done its +job. diff --git a/font/fontpatcher-symbols.sfd b/font/fontpatcher-symbols.sfd deleted file mode 100644 index c65c6490..00000000 --- a/font/fontpatcher-symbols.sfd +++ /dev/null @@ -1,235 +0,0 @@ -SplineFontDB: 3.0 -FontName: PowerlineSymbols -FullName: PowerlineSymbols -FamilyName: PowerlineSymbols -Weight: Medium -Copyright: Created with FontForge 2.0 (http://fontforge.sf.net) -UComments: "2012-12-17: Created." -Version: 001.000 -ItalicAngle: 0 -UnderlinePosition: -100 -UnderlineWidth: 50 -Ascent: 1638 -Descent: 410 -LayerCount: 2 -Layer: 0 0 "Back" 1 -Layer: 1 0 "Fore" 0 -XUID: [1021 211 26716215 11183012] -OS2Version: 0 -OS2_WeightWidthSlopeOnly: 0 -OS2_UseTypoMetrics: 1 -CreationTime: 1355758773 -ModificationTime: 1355865048 -OS2TypoAscent: 0 -OS2TypoAOffset: 1 -OS2TypoDescent: 0 -OS2TypoDOffset: 1 -OS2TypoLinegap: 0 -OS2WinAscent: 0 -OS2WinAOffset: 1 -OS2WinDescent: 0 -OS2WinDOffset: 1 -HheadAscent: 0 -HheadAOffset: 1 -HheadDescent: 0 -HheadDOffset: 1 -OS2Vendor: 'PfEd' -MarkAttachClasses: 1 -DEI: 91125 -Encoding: UnicodeBmp -Compacted: 1 -UnicodeInterp: none -NameList: Adobe Glyph List -DisplaySize: -24 -AntiAlias: 1 -FitToEm: 1 -WinInfo: 0 31 16 -BeginPrivate: 0 -EndPrivate -BeginChars: 65536 8 - -StartChar: uniE0A0 -Encoding: 57504 57504 0 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet -426 -365 m 1 - 150 -365 l 1 - 150 117 l 2 - 150 236.333333333 176.333333333 333.666666667 229 409 c 1 - 265 461.666666667 321.333333333 513 398 563 c 2 - 550 662 l 2 - 610 701.333333333 652.833333333 747.5 678.5 800.5 c 128 - 704.166666667 853.5 717 923.333333333 717 1010 c 2 - 717 1339 l 1 - 508 1339 l 1 - 800 1681 l 1 - 1092 1339 l 1 - 883 1339 l 1 - 883 954 l 2 - 883 826 865.166666667 727.833333333 829.5 659.5 c 128 - 793.833333333 591.166666667 740.333333333 533.666666667 669 487 c 1 - 594 437 l 2 - 532 396.333333333 489.333333333 355 466 313 c 0 - 439.333333333 265.666666667 426 200.333333333 426 117 c 2 - 426 -365 l 1 -426 820 m 1 - 150 642 l 1 - 150 1950 l 1 - 426 1950 l 1 - 426 820 l 1 -EndSplineSet -EndChar - -StartChar: uniE0A1 -Encoding: 57505 57505 1 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet -700 963 m 1 - 700 831 l 1 - 194 831 l 1 - 194 1731 l 1 - 349 1731 l 1 - 349 963 l 1 - 700 963 l 1 -706 750 m 1 - 865 750 l 1 - 865 -150 l 1 - 698 -150 l 1 - 453 435 l 1 - 472 45 l 1 - 472 -150 l 1 - 315 -150 l 1 - 315 750 l 1 - 480 750 l 1 - 727 163 l 1 - 706 592 l 1 - 706 750 l 1 -EndSplineSet -EndChar - -StartChar: uniE0A2 -Encoding: 57506 57506 2 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet -265 0 m 2 - 171 0 124 47 124 141 c 2 - 124 830 l 2 - 124 930.666666667 164.333333333 981 245 981 c 1 - 245 1287 l 2 - 245 1378.33333333 273 1454.33333333 329 1515 c 0 - 383 1573 450 1602 530 1602 c 256 - 610 1602 677 1573 731 1515 c 0 - 787 1454.33333333 815 1378.33333333 815 1287 c 2 - 815 981 l 1 - 895.666666667 981 936 930.666666667 936 830 c 2 - 936 141 l 2 - 936 47 889 0 795 0 c 2 - 265 0 l 2 -530 1472 m 256 - 485.333333333 1472 449.5 1455.33333333 422.5 1422 c 128 - 395.5 1388.66666667 382 1343.66666667 382 1287 c 2 - 382 981 l 1 - 678 981 l 1 - 678 1287 l 2 - 678 1343.66666667 664.5 1388.66666667 637.5 1422 c 128 - 610.5 1455.33333333 574.666666667 1472 530 1472 c 256 -586 236 m 1 - 586 559 l 1 - 631.333333333 582.333333333 654 619.333333333 654 670 c 0 - 654 704 641.833333333 733.166666667 617.5 757.5 c 128 - 593.166666667 781.833333333 564 794 530 794 c 256 - 496 794 466.833333333 781.833333333 442.5 757.5 c 128 - 418.166666667 733.166666667 406 704 406 670 c 0 - 406 619.333333333 428.666666667 582.333333333 474 559 c 1 - 474 236 l 1 - 586 236 l 1 -EndSplineSet -EndChar - -StartChar: uniE0B0 -Encoding: 57520 57520 3 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet -0 1950 m 1 - 1060 788 l 1 - 0 -375 l 1 - 0 1950 l 1 -EndSplineSet -EndChar - -StartChar: uniE0B1 -Encoding: 57521 57521 4 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet --57 1812 m 1 - 39 1907 l 1 - 1060 788 l 1 - 39 -331 l 1 - -57 -236 l 1 - 875 788 l 1 - -57 1812 l 1 -EndSplineSet -EndChar - -StartChar: uniE0B2 -Encoding: 57522 57522 5 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet -1060 -375 m 1 - 0 788 l 1 - 1060 1950 l 1 - 1060 -375 l 1 -EndSplineSet -EndChar - -StartChar: uniE0B3 -Encoding: 57523 57523 6 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet -185 788 m 1 - 1117 -236 l 1 - 1021 -331 l 1 - 0 788 l 1 - 1021 1907 l 1 - 1117 1812 l 1 - 185 788 l 1 -EndSplineSet -EndChar - -StartChar: block -Encoding: 9608 9608 7 -Width: 1060 -Flags: HW -LayerCount: 2 -Fore -SplineSet -0 1950 m 1 - 1060 1950 l 1 - 1060 -375 l 1 - 0 -375 l 1 - 0 1950 l 1 -EndSplineSet -EndChar -EndChars -EndSplineFont diff --git a/font/fontpatcher.py b/font/fontpatcher.py deleted file mode 100755 index e2bbf2a0..00000000 --- a/font/fontpatcher.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8:noet - -import argparse -import sys -import re -import os.path - -try: - import fontforge - import psMat -except ImportError: - sys.stderr.write('The required FontForge modules could not be loaded.\n\n') - if sys.version_info.major > 2: - sys.stderr.write('FontForge only supports Python 2. Please run this script with the Python 2 executable - e.g. "python2 {0}"\n'.format(sys.argv[0])) - else: - sys.stderr.write('You need FontForge with Python bindings for this script to work.\n') - sys.exit(1) - -# Handle command-line arguments -parser = argparse.ArgumentParser(description='Font patcher for Powerline. Requires FontForge with Python bindings. Stores the patched font as a new, renamed font file by default.') -parser.add_argument('target_fonts', help='font files to patch', metavar='font', nargs='+', type=argparse.FileType('rb')) -parser.add_argument('--no-rename', help='don\'t add " for Powerline" to the font name', default=True, action='store_false', dest='rename_font') -parser.add_argument('--source-font', help='source symbol font', metavar='font', dest='source_font', default='{0}/fontpatcher-symbols.sfd'.format(sys.path[0]), type=argparse.FileType('rb')) -args = parser.parse_args() - - -class FontPatcher(object): - def __init__(self, source_font, target_fonts, rename_font=True): - self.source_font = fontforge.open(source_font.name) - self.target_fonts = (fontforge.open(target_font.name) for target_font in target_fonts) - self.rename_font = rename_font - - def patch(self): - for target_font in self.target_fonts: - source_font = self.source_font - target_font_em_original = target_font.em - target_font.em = 2048 - target_font.encoding = 'ISO10646' - - # Rename font - if self.rename_font: - target_font.familyname += ' for Powerline' - target_font.fullname += ' for Powerline' - fontname, style = re.match("^([^-]*)(?:(-.*))?$", target_font.fontname).groups() - target_font.fontname = fontname + 'ForPowerline' - if style is not None: - target_font.fontname += style - target_font.appendSFNTName('English (US)', 'Preferred Family', target_font.familyname) - target_font.appendSFNTName('English (US)', 'Compatible Full', target_font.fullname) - - source_bb = source_font['block'].boundingBox() - target_bb = [0, 0, 0, 0] - target_font_width = 0 - - # Find the biggest char width and height in the Latin-1 extended range and the box drawing range - # This isn't ideal, but it works fairly well - some fonts may need tuning after patching - for cp in range(0x00, 0x17f) + range(0x2500, 0x2600): - try: - bbox = target_font[cp].boundingBox() - except TypeError: - continue - if not target_font_width: - target_font_width = target_font[cp].width - if bbox[0] < target_bb[0]: - target_bb[0] = bbox[0] - if bbox[1] < target_bb[1]: - target_bb[1] = bbox[1] - if bbox[2] > target_bb[2]: - target_bb[2] = bbox[2] - if bbox[3] > target_bb[3]: - target_bb[3] = bbox[3] - - # Find source and target size difference for scaling - x_ratio = (target_bb[2] - target_bb[0]) / (source_bb[2] - source_bb[0]) - y_ratio = (target_bb[3] - target_bb[1]) / (source_bb[3] - source_bb[1]) - scale = psMat.scale(x_ratio, y_ratio) - - # Find source and target midpoints for translating - x_diff = target_bb[0] - source_bb[0] - y_diff = target_bb[1] - source_bb[1] - translate = psMat.translate(x_diff, y_diff) - transform = psMat.compose(scale, translate) - - # Create new glyphs from symbol font - for source_glyph in source_font.glyphs(): - if source_glyph == source_font['block']: - # Skip the symbol font block glyph - continue - - # Select and copy symbol from its encoding point - source_font.selection.select(source_glyph.encoding) - source_font.copy() - - # Select and paste symbol to its unicode code point - target_font.selection.select(source_glyph.unicode) - target_font.paste() - - # Transform the glyph - target_font.transform(transform) - - # Reset the font's glyph width so it's still considered monospaced - target_font[source_glyph.unicode].width = target_font_width - - target_font.em = target_font_em_original - - # Generate patched font - extension = os.path.splitext(target_font.path)[1] - if extension.lower() not in ['.ttf', '.otf']: - # Default to OpenType if input is not TrueType/OpenType - extension = '.otf' - target_font.generate('{0}{1}'.format(target_font.fullname, extension)) - -fp = FontPatcher(args.source_font, args.target_fonts, args.rename_font) -fp.patch() diff --git a/packages/archlinux/python-powerline-git/.gitignore b/packages/archlinux/python-powerline-git/.gitignore deleted file mode 100644 index cc7d5336..00000000 --- a/packages/archlinux/python-powerline-git/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -* -!.gitignore -!PKGBUILD -!*.install -!*.patch diff --git a/packages/archlinux/python-powerline-git/PKGBUILD b/packages/archlinux/python-powerline-git/PKGBUILD deleted file mode 100644 index b49dffbf..00000000 --- a/packages/archlinux/python-powerline-git/PKGBUILD +++ /dev/null @@ -1,74 +0,0 @@ -# Maintainer: Kim Silkebækken - -_gitname=powerline -_gitbranch=develop -pkgname="python-${_gitname}-git" # Workaround for missing split package support in AUR -true && pkgname=("python-${_gitname}-git" "${_gitname}-fontpatcher-git") -pkgbase=powerline -pkgver=822.225ac48 -pkgrel=1 -url='https://github.com/Lokaltog/powerline' -license=('MIT') -arch=('any') -makedepends=('git' 'python-distribute') -provides=('powerline') -conflicts=('python2-powerline-git' - 'powerline-git') -install="${_gitname}.install" -source=("${_gitname}::git://github.com/Lokaltog/${_gitname}.git#branch=${_gitbranch}" - "fontpatcher.py.patch" - "${install}") -sha256sums=('SKIP' - '85576097662ab4203968b5fba1d59ec2653a390cdd4db9cee8ffa7bd4c5a7253' - '7b1257cdacce60e19280f7d918e5f3aa6f13b519dff16ecc6f732c881ef63ca1') - -pkgver() { - cd "${_gitname}" - echo "$(git rev-list --count ${_gitbranch}).$(git rev-parse --short ${_gitbranch})" -} - -prepare() { - cd "${srcdir}/${_gitname}" - patch -p1 < ../fontpatcher.py.patch -} - -package_powerline-fontpatcher-git() { - pkgdesc='OTF/TTF font patcher for Powerline symbols' - depends=('python2' 'fontforge') - - cd "${_gitname}" - - # Font patcher - install -Dm755 "font/fontpatcher.py" "${pkgdir}/usr/bin/powerline-fontpatcher" - install -Dm644 "font/fontpatcher-symbols.sfd" "${pkgdir}/usr/share/$_gitname/fontpatcher-symbols.sfd" -} - -package_python-powerline-git() { - pkgdesc='The ultimate statusline/prompt utility.' - depends=('python>=3.2') - optdepends=('python-psutil: improved system information' - 'python-pygit2: improved git support' - 'zsh: better shell prompt' - 'gvim: vim compiled with Python support') - - cd "${_gitname}" - python setup.py install --root="${pkgdir}" --optimize=1 - - # Fonts - install -dm755 "${pkgdir}/etc/fonts/conf.d" - install -Dm644 "font/PowerlineSymbols.otf" "${pkgdir}/usr/share/fonts/OTF/PowerlineSymbols.otf" - install -Dm644 "font/10-powerline-symbols.conf" "${pkgdir}/etc/fonts/conf.avail/10-powerline-symbols.conf" - ln -s "../conf.avail/10-powerline-symbols.conf" "${pkgdir}/etc/fonts/conf.d/10-powerline-symbols.conf" - - # Vim Plugin - install -Dm644 "powerline/bindings/vim/plugin/powerline.vim" "${pkgdir}/usr/share/vim/vimfiles/plugin/powerline.vim" - - # Zsh Plugin - install -Dm644 "powerline/bindings/zsh/powerline.zsh" "${pkgdir}/usr/share/zsh/site-contrib/powerline.zsh" - - # Tmux Configuration - install -Dm644 "powerline/bindings/tmux/powerline.conf" "${pkgdir}/usr/share/tmux/powerline.conf" - - # License - install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" -} diff --git a/packages/archlinux/python-powerline-git/fontpatcher.py.patch b/packages/archlinux/python-powerline-git/fontpatcher.py.patch deleted file mode 100644 index fb394ce2..00000000 --- a/packages/archlinux/python-powerline-git/fontpatcher.py.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/font/fontpatcher.py b/font/fontpatcher.py -index e2bbf2a..aa172f6 100755 ---- a/font/fontpatcher.py -+++ b/font/fontpatcher.py -@@ -21,7 +21,7 @@ except ImportError: - parser = argparse.ArgumentParser(description='Font patcher for Powerline. Requires FontForge with Python bindings. Stores the patched font as a new, renamed font file by default.') - parser.add_argument('target_fonts', help='font files to patch', metavar='font', nargs='+', type=argparse.FileType('rb')) - parser.add_argument('--no-rename', help='don\'t add " for Powerline" to the font name', default=True, action='store_false', dest='rename_font') --parser.add_argument('--source-font', help='source symbol font', metavar='font', dest='source_font', default='{0}/fontpatcher-symbols.sfd'.format(sys.path[0]), type=argparse.FileType('rb')) -+parser.add_argument('--source-font', help='source symbol font', metavar='font', dest='source_font', default='/usr/share/powerline/fontpatcher-symbols.sfd', type=argparse.FileType('rb')) - args = parser.parse_args() - - diff --git a/packages/archlinux/python-powerline-git/powerline.install b/packages/archlinux/python-powerline-git/powerline.install deleted file mode 100644 index d6644b17..00000000 --- a/packages/archlinux/python-powerline-git/powerline.install +++ /dev/null @@ -1,48 +0,0 @@ -post_install() { - echo "Updating font cache..." - fc-cache -f - - echo " -IMPORTANT -========= - -Powerline requires custom glyphs to work properly. A font with these glyphs has -been installed along with a fontconfig file which enables the glyphs for many -common coding fonts. - -If Powerline doesn't work out of the box on your system, please submit an issue -on GitHub: https://github.com/Lokaltog/powerline/issues - -Consult the documentation for detailed installation instructions and -troubleshooting information: https://powerline.readthedocs.org/en/latest/ - -You may need to update your PYTHONPATH environment variable by adding the -following line to your /etc/profile, .zshrc, etc.: - - export PYTHONPATH=/usr/lib/python3.3/site-packages - -Vim installation ----------------- - -The plugin has been installed and is enabled by default. - -Zsh installation ----------------- - -Add the following line to your ~/.zshrc: - - . /usr/share/zsh/site-contrib/powerline.zsh - -Tmux installation ------------------ - -Add the following line to your ~/.tmux.conf: - - source '/usr/share/tmux/powerline.conf' -" -} - -post_remove() { - echo "Updating font cache..." - fc-cache -f -} diff --git a/packages/archlinux/python2-powerline-git/.gitignore b/packages/archlinux/python2-powerline-git/.gitignore deleted file mode 100644 index cc7d5336..00000000 --- a/packages/archlinux/python2-powerline-git/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -* -!.gitignore -!PKGBUILD -!*.install -!*.patch diff --git a/packages/archlinux/python2-powerline-git/PKGBUILD b/packages/archlinux/python2-powerline-git/PKGBUILD deleted file mode 100644 index e01e70ff..00000000 --- a/packages/archlinux/python2-powerline-git/PKGBUILD +++ /dev/null @@ -1,75 +0,0 @@ -# Maintainer: Kim Silkebækken - -_gitname=powerline -_gitbranch=develop -pkgname="python2-${_gitname}-git" # Workaround for missing split package support in AUR -true && pkgname=("python2-${_gitname}-git" "${_gitname}-fontpatcher-git") -pkgbase=powerline -pkgver=822.225ac48 -pkgrel=1 -url='https://github.com/Lokaltog/powerline' -license=('MIT') -arch=('any') -makedepends=('git' 'python2-distribute') -provides=('powerline') -conflicts=('python-powerline-git') -replaces=('powerline-git') -install="${_gitname}.install" -source=("${_gitname}::git://github.com/Lokaltog/${_gitname}.git#branch=${_gitbranch}" - "fontpatcher.py.patch" - "${install}") -sha256sums=('SKIP' - '85576097662ab4203968b5fba1d59ec2653a390cdd4db9cee8ffa7bd4c5a7253' - 'e8ab7fb51ac7244bfad973a999c9333ba4334fa391aa890489cf8c8f1211c94f') - -pkgver() { - cd "${_gitname}" - echo "$(git rev-list --count ${_gitbranch}).$(git rev-parse --short ${_gitbranch})" -} - -prepare() { - cd "${srcdir}/${_gitname}" - patch -p1 < ../fontpatcher.py.patch -} - -package_powerline-fontpatcher-git() { - pkgdesc='OTF/TTF font patcher for Powerline symbols' - depends=('python2' 'fontforge') - - cd "${_gitname}" - - # Font patcher - install -Dm755 "font/fontpatcher.py" "${pkgdir}/usr/bin/powerline-fontpatcher" - install -Dm644 "font/fontpatcher-symbols.sfd" "${pkgdir}/usr/share/${_gitname}/fontpatcher-symbols.sfd" -} - -package_python2-powerline-git() { - pkgdesc='The ultimate statusline/prompt utility.' - depends=('python2>=2.6') - optdepends=('python2-psutil: improved system information' - 'python2-pygit2: improved git support' - 'mercurial: improved mercurial support' - 'zsh: better shell prompt' - 'gvim: vim compiled with Python support') - - cd "${_gitname}" - python2 setup.py install --root="${pkgdir}" --optimize=1 - - # Fonts - install -dm755 "${pkgdir}/etc/fonts/conf.d" - install -Dm644 "font/PowerlineSymbols.otf" "${pkgdir}/usr/share/fonts/OTF/PowerlineSymbols.otf" - install -Dm644 "font/10-powerline-symbols.conf" "${pkgdir}/etc/fonts/conf.avail/10-powerline-symbols.conf" - ln -s "../conf.avail/10-powerline-symbols.conf" "${pkgdir}/etc/fonts/conf.d/10-powerline-symbols.conf" - - # Vim Plugin - install -Dm644 "powerline/bindings/vim/plugin/powerline.vim" "${pkgdir}/usr/share/vim/vimfiles/plugin/powerline.vim" - - # Zsh Plugin - install -Dm644 "powerline/bindings/zsh/powerline.zsh" "${pkgdir}/usr/share/zsh/site-contrib/powerline.zsh" - - # Tmux Configuration - install -Dm644 "powerline/bindings/tmux/powerline.conf" "${pkgdir}/usr/share/tmux/powerline.conf" - - # License - install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" -} diff --git a/packages/archlinux/python2-powerline-git/fontpatcher.py.patch b/packages/archlinux/python2-powerline-git/fontpatcher.py.patch deleted file mode 100644 index fb394ce2..00000000 --- a/packages/archlinux/python2-powerline-git/fontpatcher.py.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/font/fontpatcher.py b/font/fontpatcher.py -index e2bbf2a..aa172f6 100755 ---- a/font/fontpatcher.py -+++ b/font/fontpatcher.py -@@ -21,7 +21,7 @@ except ImportError: - parser = argparse.ArgumentParser(description='Font patcher for Powerline. Requires FontForge with Python bindings. Stores the patched font as a new, renamed font file by default.') - parser.add_argument('target_fonts', help='font files to patch', metavar='font', nargs='+', type=argparse.FileType('rb')) - parser.add_argument('--no-rename', help='don\'t add " for Powerline" to the font name', default=True, action='store_false', dest='rename_font') --parser.add_argument('--source-font', help='source symbol font', metavar='font', dest='source_font', default='{0}/fontpatcher-symbols.sfd'.format(sys.path[0]), type=argparse.FileType('rb')) -+parser.add_argument('--source-font', help='source symbol font', metavar='font', dest='source_font', default='/usr/share/powerline/fontpatcher-symbols.sfd', type=argparse.FileType('rb')) - args = parser.parse_args() - - diff --git a/packages/archlinux/python2-powerline-git/powerline.install b/packages/archlinux/python2-powerline-git/powerline.install deleted file mode 100644 index d7938d2b..00000000 --- a/packages/archlinux/python2-powerline-git/powerline.install +++ /dev/null @@ -1,43 +0,0 @@ -post_install() { - echo "Updating font cache..." - fc-cache -f - - echo " -IMPORTANT -========= - -Powerline requires custom glyphs to work properly. A font with these glyphs has -been installed along with a fontconfig file which enables the glyphs for many -common coding fonts. - -If Powerline doesn't work out of the box on your system, please submit an issue -on GitHub: https://github.com/Lokaltog/powerline/issues - -Consult the documentation for detailed installation instructions and -troubleshooting information: https://powerline.readthedocs.org/en/latest/ - -Vim installation ----------------- - -The plugin has been installed and is enabled by default. - -Zsh installation ----------------- - -Add the following line to your ~/.zshrc: - - . /usr/share/zsh/site-contrib/powerline.zsh - -Tmux installation ------------------ - -Add the following line to your ~/.tmux.conf: - - source '/usr/share/tmux/powerline.conf' -" -} - -post_remove() { - echo "Updating font cache..." - fc-cache -f -} diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 4e4d52de..16b295b2 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -31,9 +31,7 @@ _powerline_tmux_set_columns() { _powerline_prompt() { local last_exit_code=$? - [[ -z "$POWERLINE_OLD_PROMPT_COMMAND" ]] || - eval $POWERLINE_OLD_PROMPT_COMMAND - PS1="$($POWERLINE_COMMAND shell left -r bash_prompt --last_exit_code=$last_exit_code --jobnum="$(jobs|wc -l)")" + PS1="$($POWERLINE_COMMAND shell left -r bash_prompt --last_exit_code=$last_exit_code --jobnum="$(jobs -p|wc -l)")" _powerline_tmux_set_pwd return $last_exit_code } @@ -42,5 +40,4 @@ trap "_powerline_tmux_set_columns" SIGWINCH _powerline_tmux_set_columns [[ "$PROMPT_COMMAND" != "${PROMPT_COMMAND/_powerline_prompt/}" ]] || - POWERLINE_OLD_PROMPT_COMMAND="$PROMPT_COMMAND" -export PROMPT_COMMAND="_powerline_prompt" + export PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n'"_powerline_prompt;" diff --git a/powerline/lib/file_watcher.py b/powerline/lib/file_watcher.py index bf78b7bb..41e20362 100644 --- a/powerline/lib/file_watcher.py +++ b/powerline/lib/file_watcher.py @@ -54,7 +54,24 @@ class INotifyWatch(INotify): self.modified.pop(path, None) self.last_query.pop(path, None) else: - self.modified[path] = True + if mask & self.ATTRIB: + # The watched file could have had its inode changed, in + # which case we will not get any more events for this + # file, so re-register the watch. For example by some + # other file being renamed as this file. + try: + self.unwatch(path) + except OSError: + pass + try: + self.watch(path) + except OSError as e: + if getattr(e, 'errno', None) != errno.ENOENT: + raise + else: + self.modified[path] = True + else: + self.modified[path] = True def unwatch(self, path): ''' Remove the watch for path. Raises an OSError if removing the watch diff --git a/powerline/lib/vcs/__init__.py b/powerline/lib/vcs/__init__.py index 005edf83..5fa066fe 100644 --- a/powerline/lib/vcs/__init__.py +++ b/powerline/lib/vcs/__init__.py @@ -33,6 +33,15 @@ def file_watcher(): _file_watcher = create_file_watcher() return _file_watcher +_branch_watcher = None + +def branch_watcher(): + global _branch_watcher + if _branch_watcher is None: + from powerline.lib.file_watcher import create_file_watcher + _branch_watcher = create_file_watcher() + return _branch_watcher + branch_name_cache = {} branch_lock = Lock() file_status_lock = Lock() @@ -41,7 +50,7 @@ def get_branch_name(directory, config_file, get_func): global branch_name_cache with branch_lock: # Check if the repo directory was moved/deleted - fw = file_watcher() + fw = branch_watcher() is_watched = fw.is_watched(directory) try: changed = fw(directory) diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py index a28c4588..c6ac15d3 100644 --- a/tests/lib/__init__.py +++ b/tests/lib/__init__.py @@ -76,23 +76,29 @@ def new_module(name, **kwargs): class AttrReplace(object): - def __init__(self, obj, attr, new): + def __init__(self, obj, *args): self.obj = obj - self.attr = attr - self.new = new + self.attrs = args[::2] + self.new = args[1::2] def __enter__(self): - try: - self.old = getattr(self.obj, self.attr) - except AttributeError: - pass - setattr(self.obj, self.attr, self.new) + self.old = {} + for i, attr in enumerate(self.attrs): + try: + self.old[i] = getattr(self.obj, attr) + except AttributeError: + pass + for attr, new in zip(self.attrs, self.new): + setattr(self.obj, attr, new) def __exit__(self, *args): - try: - setattr(self.obj, self.attr, self.old) - except AttributeError: - delattr(self.obj, self.attr) + for i, attr in enumerate(self.attrs): + try: + old = self.old[i] + except KeyError: + delattr(self.obj, attr) + else: + setattr(self.obj, attr, old) replace_attr = AttrReplace diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py new file mode 100644 index 00000000..05db6ab2 --- /dev/null +++ b/tests/test_cmdline.py @@ -0,0 +1,123 @@ +# vim:fileencoding=utf-8:noet + +'''Tests for shell.py parser''' + + +from powerline.shell import get_argparser, finish_args +from tests import TestCase +from tests.lib import replace_attr +import sys +if sys.version_info < (3,): + from io import BytesIO as StrIO +else: + from io import StringIO as StrIO # NOQA + + +class TestParser(TestCase): + def test_main_err(self): + parser = get_argparser() + out = StrIO() + err = StrIO() + def flush(): + out.truncate(0) + err.truncate(0) + with replace_attr(sys, 'stdout', out, 'stderr', err): + for raising_args, raising_reg in [ + ([], 'too few arguments|the following arguments are required: ext'), + (['-r'], 'expected one argument'), + (['shell', '-r'], 'expected one argument'), + (['shell', '-w'], 'expected one argument'), + (['shell', '-c'], 'expected one argument'), + (['shell', '-t'], 'expected one argument'), + (['shell', '-p'], 'expected one argument'), + (['shell', '-R'], 'expected one argument'), + (['shell', '--renderer_module'], 'expected one argument'), + (['shell', '--width'], 'expected one argument'), + (['shell', '--last_exit_code'], 'expected one argument'), + (['shell', '--last_pipe_status'], 'expected one argument'), + (['shell', '--config'], 'expected one argument'), + (['shell', '--theme_option'], 'expected one argument'), + (['shell', '--config_path'], 'expected one argument'), + (['shell', '--renderer_arg'], 'expected one argument'), + (['shell', '--jobnum'], 'expected one argument'), + (['-r', 'zsh_prompt'], 'too few arguments|the following arguments are required: ext'), + (['shell', '--last_exit_code', 'i'], 'invalid int value'), + (['shell', '--last_pipe_status', '1 i'], 'invalid value'), + (['shell', '-R', 'abc'], 'invalid value'), + ]: + self.assertRaises(SystemExit, parser.parse_args, raising_args) + self.assertFalse(out.getvalue()) + self.assertRegexpMatches(err.getvalue(), raising_reg) + flush() + + def test_main_normal(self): + parser = get_argparser() + out = StrIO() + err = StrIO() + with replace_attr(sys, 'stdout', out, 'stderr', err): + for argv, expargs in [ + (['shell'], {'ext': ['shell']}), + (['shell', '-r', 'zsh_prompt'], {'ext': ['shell'], 'renderer_module': 'zsh_prompt'}), + ([ + 'shell', + 'left', + '-r', 'zsh_prompt', + '--last_exit_code', '10', + '--last_pipe_status', '10 20 30', + '--jobnum=10', + '-w', '100', + '-c', 'common.term_truecolor=true', + '-c', 'common.spaces=4', + '-t', 'default.segment_data.hostname.before=H:', + '-p', '.', + '-R', 'smth={"abc":"def"}' + ], { + 'ext': ['shell'], + 'side': 'left', + 'renderer_module': 'zsh_prompt', + 'last_exit_code': 10, + 'last_pipe_status': [10, 20, 30], + 'jobnum': 10, + 'width': 100, + 'config': {'common': {'term_truecolor': True, 'spaces': 4}}, + 'theme_option': { + 'default': { + 'segment_data': { + 'hostname': { + 'before': 'H:' + } + } + } + }, + 'config_path': '.', + 'renderer_arg': {'smth': {'abc': 'def'}}, + }), + (['shell', '-R', 'arg=true'], {'ext': ['shell'], 'renderer_arg': {'arg': True}}), + (['shell', '-t', 'default.segment_info={"hostname": {}}'], { + 'ext': ['shell'], + 'theme_option': { + 'default': { + 'segment_info': { + 'hostname': {} + } + } + }, + }), + (['shell', '-c', 'common={ }'], {'ext': ['shell'], 'config': {'common': {}}}), + ]: + args = parser.parse_args(argv) + finish_args(args) + for key, val in expargs.items(): + self.assertEqual(getattr(args, key), val) + for key, val in args.__dict__.items(): + if key not in expargs: + self.assertFalse(val, msg='key {0} is {1} while it should be something false'.format(key, val)) + self.assertFalse(err.getvalue() + out.getvalue(), msg='unexpected output: {0!r} {1!r}'.format( + err.getvalue(), + out.getvalue(), + )) + + +if __name__ == '__main__': + from tests import main + main() diff --git a/tests/test_lib.py b/tests/test_lib.py index 18326d72..f10ee293 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -54,10 +54,11 @@ class TestFilesystemWatchers(TestCase): w = create_file_watcher(use_stat=False) if w.is_stat_based: raise SkipTest('This test is not suitable for a stat based file watcher') - f1, f2 = os.path.join(INOTIFY_DIR, 'file1'), os.path.join(INOTIFY_DIR, 'file2') + f1, f2, f3 = map(lambda x: os.path.join(INOTIFY_DIR, 'file%d' % x), (1, 2, 3)) with open(f1, 'wb'): with open(f2, 'wb'): - pass + with open(f3, 'wb'): + pass ne = os.path.join(INOTIFY_DIR, 'notexists') self.assertRaises(OSError, w, ne) self.assertTrue(w(f1)) @@ -85,6 +86,13 @@ class TestFilesystemWatchers(TestCase): # Check that deleting a file registers as a change os.unlink(f1) self.do_test_for_change(w, f1) + # Test that changing the inode of a file does not cause it to stop + # being watched + os.rename(f3, f2) + self.do_test_for_change(w, f2) + self.assertFalse(w(f2), 'Spurious change detected') + os.utime(f2, None) + self.do_test_for_change(w, f2) def test_tree_watcher(self): from powerline.lib.tree_watcher import TreeWatcher diff --git a/tests/test_shells/bash.ok b/tests/test_shells/bash.ok index 123b9fd6..a88c8091 100644 --- a/tests/test_shells/bash.ok +++ b/tests/test_shells/bash.ok @@ -1,12 +1,10 @@ -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git -  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & -[1] PID -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s -[1]+ Terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit -exit +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & +[1] PID +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +[1]+ Terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false diff --git a/tests/test_shells/input.bash b/tests/test_shells/input.bash index 9b97dac0..954d6e1a 100644 --- a/tests/test_shells/input.bash +++ b/tests/test_shells/input.bash @@ -11,4 +11,5 @@ bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & false kill `cat pid` ; sleep 1s false +true is the last line exit diff --git a/tests/test_shells/input.zsh b/tests/test_shells/input.zsh index a19bdff4..bcd1a421 100644 --- a/tests/test_shells/input.zsh +++ b/tests/test_shells/input.zsh @@ -12,4 +12,5 @@ bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & false kill `cat pid` ; sleep 1s false +true is the last line exit diff --git a/tests/test_shells/postproc.py b/tests/test_shells/postproc.py index 8cd037d0..5c1832f2 100755 --- a/tests/test_shells/postproc.py +++ b/tests/test_shells/postproc.py @@ -24,9 +24,14 @@ with codecs.open(fname, 'r', encoding='utf-8') as R: if not found_cd: found_cd = ('cd tests/shell/3rd' in line) continue - line = line.replace(pid, 'PID') + if 'true is the last line' in line: + break + line = line.translate({ + ord('\r'): None + }) line = line.replace(hostname, 'HOSTNAME') line = line.replace(user, 'USER') + line = line.replace(pid, 'PID') W.write(line) os.rename(new_fname, fname) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index e5febb8f..f47ab5a5 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -11,21 +11,32 @@ else } fi +check_screen_log() { + diff -u tests/test_shells/${1}.ok tests/shell/screen.log + # Explicit is better then implicit + return $? +} + run_test() { SH="$1" SESNAME="powerline-shell-test-$$" screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \ env LANG=en_US.UTF-8 BINDFILE="$BINDFILE" "$@" screen -S "$SESNAME" -X readreg a tests/test_shells/input.$SH + # Wait for screen to initialize sleep 0.3s screen -S "$SESNAME" -p 0 -X width 300 1 screen -S "$SESNAME" -p 0 -X logfile tests/shell/screen.log screen -S "$SESNAME" -p 0 -X paste a + # Wait for screen to exit (sending command to non-existing screen session + # fails; when launched instance exits corresponding session is deleted) while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do - sleep 1s + sleep 0.1s done ./tests/test_shells/postproc.py tests/shell/screen.log - if ! diff -u tests/test_shells/${SH}.ok tests/shell/screen.log | cat -v ; then + if ! check_screen_log ${SH} ; then + # Repeat the diff to make it better viewable in travis output + check_screen_log ${SH} | cat -v return 1 fi return 0 diff --git a/tests/test_shells/zsh.ok b/tests/test_shells/zsh.ok index 2f7256b4..47eda0f2 100644 --- a/tests/test_shells/zsh.ok +++ b/tests/test_shells/zsh.ok @@ -1,12 +1,11 @@ - -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git -   HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -   HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & -[1] PID -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s -[1] + terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit + +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & +[1] PID +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +[1] + terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false