Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 99
ignore = E221,W503
14 changes: 14 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -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
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
89 changes: 89 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
'''
SCRIPT: install.py
VERSION: v1.0
DESCRIPTION: Install colorschemes in Ranger's colorscheme module
AUTHOR: S. Numerius <[email protected]>
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)
File renamed without changes.