#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys
import subprocess
import re
import os

BASE_URL = "~/"

def check_args():
    if len(sys.argv) <= 1:
        print ("Missing compressed path argument")
        sys.exit(-1)

    return sys.argv[1]

def build_url(segment):
    return BASE_URL + segment

def shquote(s):
    return s.replace("'", "'\\''")

def ls(path):
    command = "find %s -maxdepth 1 -type d" % (shquote(path))
    folders = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True).decode('utf-8').split("\n")
    return filter(lambda f: len(f) != 0, map(lambda f: f.split("/")[-1], folders))

def startsWith(prefix, value):
    return bool(re.match(prefix, value, re.I))

def build_cd(args):
    cd_cmd = BASE_URL
    prefix = ''
    for letter in args:
        prefix += letter
        all_paths = ls(cd_cmd)
        available_paths = list(filter(lambda p: startsWith(prefix, p), all_paths))
        if len(available_paths) == 0:
            return cd_cmd
        elif len(available_paths) == 1:
            cd_cmd = os.path.join(cd_cmd, available_paths[0])
            prefix = ''
    if len(prefix) != 0:
        print (map(str, available_paths))
        sys.exit(-1)
    return cd_cmd

def main():
    args = check_args()
    cmd = build_cd(args)
    print ("cd " + cmd)

main()

@@ -88,16 +88,49 @@
 mport os
+%0Afrom colorama import Fore, Style
 %0A%0ABASE_U
@@ -737,24 +737,103 @@
 ue, re.I))%0A%0A
+def cprint(color, text):%0A    sys.stderr.write(color + text + Style.RESET_ALL)%0A%0A
 def build_cd
@@ -885,16 +885,19 @@
 %0A    for
+ i,
  letter 
@@ -899,20 +899,31 @@
 tter in 
+enumerate(
 args
+)
 :%0A      
@@ -1089,24 +1089,157 @@
 aths) == 0:%0A
+            if i %3C len(args):%0A                cprint(Fore.YELLOW, %22%5BWARNING%5D: arg %25s not used%5CnMoved to: %25s%5Cn%22 %25 (args%5Bi:%5D, cd_cmd))%0A
             
@@ -1411,22 +1411,36 @@
         
+c
 print
- 
+(Fore.RED, str
 (map(str
@@ -1450,32 +1450,33 @@
 vailable_paths))
+)
 %0A        sys.exi

Send errors and warnings to stderr instead of stdout