diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..b77e4e6 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 99 +ignore = E221,W503 diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..75bb7ba --- /dev/null +++ b/.pylintrc @@ -0,0 +1,14 @@ +[BASIC] +good-names=i,j,k,n,x,y,ex,Run,_,fm,ui,fg,bg +bad-names=foo,baz,toto,tutu,tata + +[DESIGN] +max-args=6 +max-branches=16 + +[FORMAT] +max-line-length = 99 +disable=locally-disabled,locally-enabled,missing-docstring,duplicate-code,fixme,cyclic-import,redefined-variable-type,stop-iteration-return + +[TYPECHECK] +ignored-classes=ranger.core.actions.Actions diff --git a/README.md b/README.md index f33d71b..60a150b 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,26 @@ colorschemes Usage ----- -You can simply clone this repository into your ranger config directory, usually -`~/.config/ranger`, to get access to all the colorschemes. +First, clone a repo: ```sh -cd ~/.config/ranger -git clone https://github.com/ranger/colorschemes.git +cd ~ # Or wherever you want to put this repo +git clone -b custom https://github.com/ranger/colorschemes.git --single-branch +``` + +Then, to install the colorschemes, run a make command: + +```sh +python install.py scheme # Replace `scheme` with the name of the desired scheme +``` + +This creates symlinks, so that if the colorschemes are updated, you just have to +pull down the new changes using `git pull origin master` and you're set. + +If you want to install copies, run this make command: + +```sh +make cp_scheme # Replace `scheme` with the name of the desired scheme ``` Creating a new colorscheme diff --git a/install.py b/install.py new file mode 100644 index 0000000..0e1e1d1 --- /dev/null +++ b/install.py @@ -0,0 +1,89 @@ +''' + SCRIPT: install.py + VERSION: v1.0 + DESCRIPTION: Install colorschemes in Ranger's colorscheme module + AUTHOR: S. Numerius + LICENSE: GPL-3.0 (found in `LICENSE`) + + Copr. 2018 S. Numerius. Some rights reserved. +''' + +from __future__ import print_function +import argparse +import os +from subprocess import call + +parser = argparse.ArgumentParser( + description='Install colorschemes for the file manager Ranger') +parser.add_argument('scheme', type=str, help='the name of the desired scheme') +parser.add_argument('-c', dest='copy', action='store_true', help='copy files') +parser.add_argument( + '--ranger-config', dest='config', action='store', default=None, + help='set ranger\'s config directory') +args = parser.parse_args() + +if args.copy: + cmd = ['cp'] +else: + cmd = ['ln', '-s'] + +if args.config is not None: + confDir = args.config +else: + confDir = os.environ['HOME'] + '/.config/ranger' + + +def getFolders(choice=None, path=os.path.dirname(os.path.realpath(__file__)), fullPath=True): + listing = os.listdir(path) + res = [] + + if choice == 'all': + choice = None + + for name in listing: + # full_path = os.path.join(path, name) + full_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), path, name) + if os.path.isdir(full_path) and name != '.git': + if choice is not None and name != choice: + continue + + if fullPath: + res.append(full_path) + else: + res.append(name) + + return res + + +schemes = getFolders(choice=args.scheme) +colors = [] +plugins = [] + +for scheme in schemes: + for folder in getFolders(path=scheme, choice='colorschemes'): + colors += [os.path.join(folder, File) for File in os.listdir(folder)] + if 'plugins' in os.listdir(scheme): + for folder in getFolders(path=scheme, choice='plugins'): + plugins += [os.path.join(folder, File) for File in os.listdir(folder)] + +for File in colors: + schemeDir = confDir + '/colorschemes' + + command = cmd.copy() + command.append(File) + command.append(schemeDir) + + verb = 'Copying' if args.copy else 'Linking' + print(verb, 'colorscheme:', File) + call(command) + +for File in plugins: + schemeDir = confDir + '/plugins' + + command = cmd.copy() + command.append(File) + command.append(schemeDir) + + verb = 'Copying' if args.copy else 'Linking' + print(verb, 'plugin:', File) + call(command) diff --git a/zenburn.py b/zenburn/colorschemes/zenburn.py similarity index 100% rename from zenburn.py rename to zenburn/colorschemes/zenburn.py