Posts for: #PHP

A Simple Bash Style With Git Branch Detection

Files

This could go into .bashrc, .bash_profile or .zshrc - your respective shell config file.

Args

Some aliases for easier handling

# alias shortcuts
alias lla="ls -la"
alias ll="ls -l"
alias l="ls"

Then we need a function which parses the current git branch (git has to be installed)…

# Git branch in prompt.
parse_git_branch() 
{
    git branch 2> /dev/null |sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

…and input the branch unto your PS1 (current theme) like so:

Read more

Find the Htaccess Location

Especially when working on foreign systems/servers it might be hard to determine where the .htpasswd file would go if you need an access restricted area while developing the website without taking the server offline.

Here is a short PHP script on how to find it:

*Info: Save this as findHtPasswd.php and run it on the host like https://this.host.com/findHtPasswd.php, copy the code and create a simple .htaccess file pointing to the correct location.

Read more