From 46fae629dc7c7e7ed39d308714346517c8a06917 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Fri, 30 Dec 2016 19:11:18 +0100 Subject: [PATCH] Updated scripts for new installer, bugfixes --- lib/config.php | 2 +- lib/vartype.php | 11 +++++++---- share/INSTALLER.md | 5 +++++ share/powerline.bash | 9 +++++++++ powerline.fish => share/powerline.fish | 0 share/setup-bash.sh | 21 +++++++++++++++++++++ share/setup-fish.sh | 25 +++++++++++++++++++++++++ 7 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 share/INSTALLER.md create mode 100644 share/powerline.bash rename powerline.fish => share/powerline.fish (100%) create mode 100644 share/setup-bash.sh create mode 100644 share/setup-fish.sh diff --git a/lib/config.php b/lib/config.php index 7c6b4e1..f00799a 100644 --- a/lib/config.php +++ b/lib/config.php @@ -327,4 +327,4 @@ function demo($item) { return call_user_func("_{$item[1]}", array_merge($defs,$attr)); -} \ No newline at end of file +} diff --git a/lib/vartype.php b/lib/vartype.php index c94c2be..ce67a41 100644 --- a/lib/vartype.php +++ b/lib/vartype.php @@ -13,6 +13,13 @@ class VarType public static function bindType($type, callable $valid, callable $caster) { + $cn = ucwords($type)."Var"; + $def = "class {$cn} extends VarType {". + "function __construct(\$def=null,\$conf=null) { ". + "parent::__construct(".var_export($type,true).",\$def,\$conf);". + "}}"; + + eval($def); self::$TYPES[$type] = [ $valid, $caster ]; } @@ -69,10 +76,6 @@ public function getDefault() return $this->def; } - public function getNullable() - { - return $this->nullable; - } } VarType::bindType("int", "is_numeric", "intval"); diff --git a/share/INSTALLER.md b/share/INSTALLER.md new file mode 100644 index 0000000..2862876 --- /dev/null +++ b/share/INSTALLER.md @@ -0,0 +1,5 @@ +Welcome to the new PHPL Installer! + +This installer will install or upgrade PHPL including modules and themes. If there are local changes to any of the themes, they should not be overwritten. It is still recommended that you copy the theme file when editing, and then edit the copy. + +You will be prompted to configure your shell automatically. Currently bash and fish can be configured. diff --git a/share/powerline.bash b/share/powerline.bash new file mode 100644 index 0000000..cd228c9 --- /dev/null +++ b/share/powerline.bash @@ -0,0 +1,9 @@ + + +function _updateprompt { + export LAST=$? + export BASH_CWD="$(pwd)" + export PS1="$(phpl-generate -s $LAST -d $BASH_CWD) " +} + +export PROMPT_COMMAND="_updateprompt" diff --git a/powerline.fish b/share/powerline.fish similarity index 100% rename from powerline.fish rename to share/powerline.fish diff --git a/share/setup-bash.sh b/share/setup-bash.sh new file mode 100644 index 0000000..ff79a94 --- /dev/null +++ b/share/setup-bash.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +OPERATION="$1" +DESTINATION="$2" + +case "$1" in + "install") + echo "Copying powerline.sh to $DESTINATION" + test -e "${DESTINATION}/powerline.sh" || cp "powerline.bash" "${DESTINATION}/powerline.sh" + # Install into ~/.bashrc if not present + grep "powerline.sh" ~/.bashrc &>/dev/null + if [ $? != 0 ]; then + echo "source ${DESTINATION}/powerline.sh" >> ~/.bashrc + echo "Added phpl to .bashrc" + else + echo "phpl appears to already be added to your .bashrc" + fi + ;; + *) + # Do nothing for anything else for now, uninstalling +esac diff --git a/share/setup-fish.sh b/share/setup-fish.sh new file mode 100644 index 0000000..262c4f9 --- /dev/null +++ b/share/setup-fish.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +OPERATION="$1" +DESTINATION="$2" + +_FISH_FUNCS="${HOME}/.config/fish/functions" +_FISH_PROMPT="${_FISH_FUNCS}/fish_prompt.fish" +_TEMPLATE="./powerline.fish" + +case "$1" in + "install") + if [ -f "${_FISH_PROMPT}" ]; then + mv "${_FISH_PROMPT}" "${_FISH_PROMPT}.old" + fi + echo "Installing into ${_FISH_PROMPT}" + cp "${_TEMPLATE}" "${_FISH_PROMPT}" + ;; + "uninstall") + echo "Removing ${_FISH_PROMPT}" + if [ -f "${_FISH_PROMPT}" ]; then + mv "${_FISH_PROMPT}" "~/fish_prompt.old" + fi + ;; +esac +