From df16f05bcce2f5d2a6d589b052e4d07ae85f0650 Mon Sep 17 00:00:00 2001 From: Saturnus Numerius Date: Wed, 22 Aug 2018 10:43:40 -0400 Subject: [PATCH 1/2] Add installation method --- .flake8 | 3 + .pylintrc | 14 +++ README.md | 31 +++++++ install.py | 89 +++++++++++++++++++ zenburn.py => zenburn/colorschemes/zenburn.py | 0 5 files changed, 137 insertions(+) create mode 100644 .flake8 create mode 100644 .pylintrc create mode 100644 install.py rename zenburn.py => zenburn/colorschemes/zenburn.py (100%) 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..f6a2713 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ colorschemes Usage ----- +There are two ways of doing things. + +### Simple method + You can simply clone this repository into your ranger config directory, usually `~/.config/ranger`, to get access to all the colorschemes. @@ -12,6 +16,33 @@ cd ~/.config/ranger git clone https://github.com/ranger/colorschemes.git ``` +> ***NOTE***: This method may change or become deprecated in the future due to +> more complex colorschemes being added that require files in multiple locations. + +### More customizable method + +First, clone a repo: + +```sh +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 From ccd09baa6e46bc98f958f986bca1825c71ed1320 Mon Sep 17 00:00:00 2001 From: Saturnus Numerius Date: Tue, 4 Sep 2018 19:58:54 -0400 Subject: [PATCH 2/2] Delete deprecated section from README --- README.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/README.md b/README.md index f6a2713..60a150b 100644 --- a/README.md +++ b/README.md @@ -4,23 +4,6 @@ colorschemes Usage ----- -There are two ways of doing things. - -### Simple method - -You can simply clone this repository into your ranger config directory, usually -`~/.config/ranger`, to get access to all the colorschemes. - -```sh -cd ~/.config/ranger -git clone https://github.com/ranger/colorschemes.git -``` - -> ***NOTE***: This method may change or become deprecated in the future due to -> more complex colorschemes being added that require files in multiple locations. - -### More customizable method - First, clone a repo: ```sh