diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2016-05-02 16:27:59 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2016-05-02 16:27:59 +0200 |
| commit | 3b4c9a9fa744cce02f17eebe1335610c955cc569 (patch) | |
| tree | ba1f7bd9575715781c0d90e9918da1227dc6cf9b /setup.py | |
| parent | 5a19b2cf7bdacdd38927486df755456ff9635889 (diff) | |
| download | dotfiles-3b4c9a9fa744cce02f17eebe1335610c955cc569.tar.gz dotfiles-3b4c9a9fa744cce02f17eebe1335610c955cc569.zip | |
change my fish setup to use fisherman
1) remove my plugin submodules and let fisherman handle them
2) add fishfile
3) remove my prompt -> use bobthefish
4) change setup.py
+ targets are now lists containing tuples of file paths or functions
+ add fish_config functions that downloads and installs fisherman
+ other little cosmetic tweaks
Diffstat (limited to 'setup.py')
| -rw-r--r-- | setup.py | 96 |
1 files changed, 73 insertions, 23 deletions
@@ -5,36 +5,86 @@ import sys home_dir = os.getenv("HOME") -targets = {"vimrc": ("vimrc", home_dir + "/.vimrc"), - "vim.d": ("vim", home_dir + "/.vim"), - "ssh-config": ("ssh/config", home_dir + "/.ssh/config"), - "xinitrc": ("xinitrc", home_dir + "/.xinitrc"), - "Xresources": ("Xresources", home_dir + "/.Xresources"), - "muttrc": ("muttrc", home_dir + "/.muttrc"), - "zshrc": ("zshrc", home_dir + "/zshrc"), - "i3-config": ("i3", home_dir + "/.i3"), - "dir_colors": ("dir_colors", home_dir + "/.dir_colors"), - "fish-config": ("config/fish/config.fish", home_dir + "/.config/fish/config.fish"), - "terminator-config": ("config/terminator/config", home_dir + "/.config/terminator/config")} - -git_submodules_for = ["vim.d", "fish-config"] +def fish_config(quiet): + """install and run fisherman""" + # download fisherman + import urllib.request + import subprocess + + if not quiet: + print("Installing fisherman, see: https://github.com/fisherman/fisherman") + with urllib.request.urlopen("https://git.io/fisherman") as f: + fisher = f.read().decode("utf-8") + + dir_path = home_dir+"/.config/fish/functions/" + # install fisherman at $fish_config/functions/ + if not os.path.exists(dir_path): + os.mkdir(dir_path) + else: + if not os.path.exists(dir_path+"fisher.fish"): + file = open(dir_path+"fisher.fish", 'w') + file.write(fisher) + else: + if not quiet: + print("fisherman all ready installed") + return + + if not quiet: + print("Installed fisherman -> execute fisher to pull plugins") + + subprocess.run(["fish", dir_path+"fisher.fish"]) + +# targets are a list of tuples<file name, link destination> and/or functions + +targets = {"vimrc": [("vimrc", home_dir + "/.vimrc")], + "vim.d": [("vim", home_dir + "/.vim")], + "ssh-config": [("ssh/config", home_dir + "/.ssh/config")], + "xinitrc": [("xinitrc", home_dir + "/.xinitrc")], + "Xresources": [("Xresources", home_dir + "/.Xresources")], + "muttrc": [("muttrc", home_dir + "/.muttrc")], + "zshrc": [("zshrc", home_dir + "/zshrc")], + "i3-config": [("i3", home_dir + "/.i3")], + "dir_colors": [("dir_colors", home_dir + "/.dir_colors")], + "fish-config": [("config/fish/config.fish", home_dir + "/.config/fish/config.fish"), + ("config/fish/fishfile", home_dir + "/.config/fish/fishfile"), fish_config], + "terminator-config": [("config/terminator/config", home_dir + "/.config/terminator/config")]} + +git_submodules_for = ["vim.d"] def install_target(target, quiet): """Install a target""" - target_files = targets[target] if not quiet: - print("Installing", target, "to", target_files[1]) - if os.path.exists(target_files[0]): - try: - os.symlink(target_files[0], target_files[1]) - except FileExistsError as e: - print(e) - else: - print("Can't find", target_files[0]+". Please make sure you are in the right directory.") + print("Installing", target, "...") + + for instruction in targets[target]: + if isinstance(instruction, tuple): + if not quiet: + print("Installing", instruction[0], "to", instruction[1]) + if os.path.exists(instruction[0]): + try: + os.symlink(instruction[0], instruction[1]) + except FileExistsError as e: + print(e, file=sys.stderr) + else: + print("Can't find", instruction[0] + + ". Please make sure you are in the right directory.", file=sys.stderr) + elif callable(instruction): + if not quiet: + print("Running function", instruction) + res = instruction(quiet) + if res: + if not quiet: + print("The instruction", instruction, "of", target, "failed with", str(res) + ".") + print("This can leaf your installation in a broken state") + print("ABORTING to prevent failures.") + exit(res) + else: + print("I don't understand", instruction, + "\nThe instruction musst be a tuple or a function.\nSKIPPING IT") if target in git_submodules_for: - choice = input(target + "uses git submodules want to pull them ? (Y/n)") + choice = input(target + " uses git submodules want to pull them ? (Y/n) ") if choice in ["Y", "y", ""]: import subprocess subprocess.run(["git", "submodule", "update", "--init"]) |
