From 7324910ead042ddff47daff5c08897bdabb27741 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sat, 2 Jun 2018 21:40:50 +0000 Subject: [PATCH] renamed /:bash => /:cht.sh --- lib/get_answer.py | 9 ++++++--- share/{bash.txt => cht.sh.txt} | 0 share/help.txt | 10 +++++----- 3 files changed, 11 insertions(+), 8 deletions(-) rename share/{bash.txt => cht.sh.txt} (100%) diff --git a/lib/get_answer.py b/lib/get_answer.py index aac54b0..aebdf7b 100644 --- a/lib/get_answer.py +++ b/lib/get_answer.py @@ -24,6 +24,7 @@ import beautifier from globals import MYDIR, PATH_TLDR_PAGES, PATH_CHEAT_PAGES, PATH_CHEAT_SHEETS, COLOR_STYLES from adapter_learnxiny import get_learnxiny, get_learnxiny_list, is_valid_learnxy from languages_data import LANGUAGE_ALIAS, SO_NAME +from colorize_internal import colorize_internal # pylint: enable=wrong-import-position,wrong-import-order REDIS = redis.StrictRedis(host='localhost', port=6379, db=0) @@ -31,7 +32,7 @@ REDIS = redis.StrictRedis(host='localhost', port=6379, db=0) MAX_SEARCH_LEN = 20 INTERNAL_TOPICS = [ - ':bash', + ':cht.sh', ':bash_completion', ':emacs', ':emacs-ivy', @@ -174,7 +175,6 @@ def get_topic_type(topic): # pylint: disable=too-many-locals,too-many-branches,t #def registered_answer_getter(func): # REGISTERED_ANSWER_GETTERS.append(funct) # return cls - def _get_internal(topic): if '/' in topic: topic_type, topic_name = topic.split('/', 1) @@ -194,7 +194,10 @@ def _get_internal(topic): return _get_stat()+"\n" if topic in INTERNAL_TOPICS: - return open(os.path.join(MYDIR, "share", topic[1:]+".txt"), "r").read() + if topic[1:] == 'intro': + return colorize_internal(open(os.path.join(MYDIR, "share", topic[1:]+".txt"), "r").read()) + else: + return open(os.path.join(MYDIR, "share", topic[1:]+".txt"), "r").read() return "" diff --git a/share/bash.txt b/share/cht.sh.txt similarity index 100% rename from share/bash.txt rename to share/cht.sh.txt diff --git a/share/help.txt b/share/help.txt index 011af3b..4072487 100644 --- a/share/help.txt +++ b/share/help.txt @@ -27,14 +27,14 @@ Special pages: :help this page :list list all cheat sheets :post how to post new cheat sheet - :bash shell client + :cht.sh shell client (cht.sh) :bash_completion bash function for tab completion :styles list of color styles :styles-demo show color styles usage examples Shell client: - $ curl https://cht.sh/:bash > ~/bin/cht.sh + $ curl https://cht.sh/:cht.sh > ~/bin/cht.sh $ chmod +x ~/bin/cht.sh $ cht.sh python :learn $ cht.sh --shell @@ -42,9 +42,9 @@ Shell client: Tab completion: $ mkdir -p ~/.bash.d/ - $ curl cheat.sh/:bash_completion > ~/.bash.d/cheat.sh - $ . ~/.bash.d/cheat.sh - $ echo '. ~/.bash.d/cheat.sh' >> ~/.bashrc + $ curl cheat.sh/:bash_completion > ~/.bash.d/cht.sh + $ . ~/.bash.d/cht.sh + $ echo '. ~/.bash.d/cht.sh' >> ~/.bashrc Editor integration: