You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
241 lines
5.1 KiB
241 lines
5.1 KiB
7 years ago
|
function big-chromium () {
|
||
|
chromium --force-device-scale-factor=$1
|
||
|
}
|
||
|
|
||
|
function big-new-chromium () {
|
||
|
chromium-snapshot-bin --force-device-scale-factor=$1
|
||
|
}
|
||
|
|
||
|
# make xclip work as I would expect. Copy to clipboard if piped data. Paste from otherwise
|
||
6 years ago
|
function clip(){
|
||
7 years ago
|
if command -v /usr/bin/xclip 1>/dev/null; then
|
||
|
if [[ -p /dev/stdin ]] ; then
|
||
|
# stdin is a pipe
|
||
|
# stdin -> clipboard
|
||
|
/usr/bin/xclip -i -selection clipboard
|
||
|
else
|
||
|
# stdin is not a pipe
|
||
|
# clipboard -> stdout
|
||
|
/usr/bin/xclip -o -selection clipboard
|
||
|
fi
|
||
|
else
|
||
|
echo "Remember to install xclip"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
#Swap two files
|
||
|
function swap() {
|
||
|
mv $1 $1._tmp;
|
||
|
mv $2 $1;
|
||
|
mv $1._tmp $2;
|
||
|
}
|
||
|
|
||
|
function old() {
|
||
|
mv "$1" "$1.old"
|
||
|
}
|
||
|
|
||
7 years ago
|
function mycd() {
|
||
|
cd "$@" 2> /dev/null
|
||
|
if [ $? = 0 ]; then
|
||
|
# If we get here cd was successful
|
||
7 years ago
|
#if [ ! $TMUX ]; then
|
||
|
# pwd > ~/.current-folder
|
||
|
#fi
|
||
7 years ago
|
ls
|
||
|
else
|
||
|
# If we get here, cd was not successful
|
||
|
if [ -f "$1" ]; then
|
||
7 years ago
|
$EDITOR "$1"
|
||
7 years ago
|
else
|
||
|
echo "Can't cd"
|
||
|
fi
|
||
7 years ago
|
fi
|
||
6 years ago
|
updatePath
|
||
7 years ago
|
}
|
||
7 years ago
|
alias cd="mycd"
|
||
7 years ago
|
|
||
|
function mkcd() {
|
||
|
mkdir -p "$1"
|
||
|
cd "$1"
|
||
|
}
|
||
|
|
||
|
function createLetter(){
|
||
|
if [ "$1" ]; then
|
||
|
if [ "$2" ]; then
|
||
|
newFile="$2"
|
||
|
else
|
||
|
newFile="$1"
|
||
|
newFile="${newFile%.*}.pdf"
|
||
|
fi
|
||
|
pandoc --template template-letter.tex $1 -o $newFile
|
||
|
else
|
||
|
echo "Oops. You need to suply a file"
|
||
|
return 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
7 years ago
|
function createFPLreport(){
|
||
|
if [ "$1" ]; then
|
||
|
if [ "$2" ]; then
|
||
|
newFile="$2"
|
||
|
else
|
||
|
newFile="$1"
|
||
|
newFile="${newFile%.*}.pdf"
|
||
|
fi
|
||
6 years ago
|
pandoc --template fellowship.latex --listings --highlight-style=pygments --pdf-engine=xelatex $1 -o $newFile
|
||
7 years ago
|
else
|
||
|
echo "Oops. You need to suply a file"
|
||
|
return 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
7 years ago
|
#Takes you to the parent theme
|
||
|
function ptheme() {
|
||
6 years ago
|
public_html=${${PWD%/public_html*}%/wiki*}/public_html
|
||
7 years ago
|
if [ -d $public_html ]; then
|
||
|
if [ -d $public_html/wp ]; then
|
||
|
wpPath=$public_html/wp;
|
||
|
else
|
||
|
wpPath=$public_html;
|
||
|
fi
|
||
6 years ago
|
domain="$(basename $(dirname $public_html ) ).local.jh"
|
||
|
theme=$(dirname $(wp --path="$wpPath" --url="$domain" theme path $(wp --path="$wpPath" --url="$domain" theme list 2> /dev/null | grep "parent" | awk '{print $1}') 2> /dev/null ))
|
||
7 years ago
|
if [ -d $theme ]; then
|
||
|
if [ -d "$theme" ]; then
|
||
|
cd $theme
|
||
|
else
|
||
|
echo " Can't find theme folder "
|
||
|
fi
|
||
|
else
|
||
|
echo " Can't find theme folder "
|
||
|
fi
|
||
|
else
|
||
|
echo " Can't find public_html folder."
|
||
|
fi
|
||
|
}
|
||
|
|
||
6 years ago
|
|
||
|
#Takes you to the child theme
|
||
|
function theme() {
|
||
6 years ago
|
if [ ! -z "$1" ]; then
|
||
6 years ago
|
ctheme=$(getthemepath "$1" 2> /dev/null)
|
||
6 years ago
|
else
|
||
6 years ago
|
ctheme=$(getthemepath 2> /dev/null)
|
||
6 years ago
|
fi
|
||
6 years ago
|
if [ ! -z "$ctheme" ]; then
|
||
|
cd $ctheme
|
||
7 years ago
|
fi
|
||
|
}
|
||
|
|
||
|
#Takes you to the js folder child theme
|
||
|
function js() {
|
||
6 years ago
|
ctheme=$(getthemepath)
|
||
6 years ago
|
if [ ! -z "$ctheme" ]; then
|
||
|
cd $ctheme/js
|
||
7 years ago
|
fi
|
||
|
}
|
||
|
|
||
|
#Takes you to the css folder child theme
|
||
|
function css() {
|
||
6 years ago
|
ctheme=$(getthemepath)
|
||
6 years ago
|
if [ ! -z "$ctheme" ]; then
|
||
|
cd $ctheme/css
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
#Takes you to the plugin directory
|
||
|
function plugins() {
|
||
6 years ago
|
public_html=${${PWD%/public_html*}%/wiki*}/public_html
|
||
7 years ago
|
if [ -d $public_html ]; then
|
||
|
if [ -d $public_html/wp ]; then
|
||
|
wpPath=$public_html/wp;
|
||
|
else
|
||
|
wpPath=$public_html;
|
||
|
fi
|
||
6 years ago
|
cd $(wp --path="$wpPath" plugin path)
|
||
7 years ago
|
else
|
||
|
echo " Can't find public_html folder."
|
||
|
fi
|
||
|
}
|
||
|
|
||
6 years ago
|
#Takes you to the woocommece plugin directory
|
||
|
function woo() {
|
||
|
public_html=${${PWD%/public_html*}%/wiki*}/public_html
|
||
|
if [ -d $public_html ]; then
|
||
|
if [ -d $public_html/wp ]; then
|
||
|
wpPath=$public_html/wp;
|
||
|
else
|
||
|
wpPath=$public_html;
|
||
|
fi
|
||
|
cd $(dirname $(wp --path="$wpPath" plugin path woocommerce))
|
||
|
else
|
||
|
echo " Can't find public_html folder."
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
#Takes you to the woocommerce templates plugin directory
|
||
|
function wooTemplates() {
|
||
|
public_html=${${PWD%/public_html*}%/wiki*}/public_html
|
||
|
if [ -d $public_html ]; then
|
||
|
if [ -d $public_html/wp ]; then
|
||
|
wpPath=$public_html/wp;
|
||
|
else
|
||
|
wpPath=$public_html;
|
||
|
fi
|
||
|
cd $(dirname $(wp --path="$wpPath" plugin path woocommerce))/templates
|
||
|
else
|
||
|
echo " Can't find public_html folder."
|
||
|
fi
|
||
|
}
|
||
|
|
||
7 years ago
|
#Takes you to the theme directory
|
||
|
function themes() {
|
||
6 years ago
|
public_html=${${PWD%/public_html*}%/wiki*}/public_html
|
||
7 years ago
|
if [ -d $public_html ]; then
|
||
|
if [ -d $public_html/wp ]; then
|
||
|
wpPath=$public_html/wp;
|
||
|
else
|
||
|
wpPath=$public_html;
|
||
|
fi
|
||
|
cd $(wp --path="$wpPath" theme path)
|
||
|
else
|
||
|
echo " Can't find public_html folder."
|
||
|
fi
|
||
|
}
|
||
|
|
||
6 years ago
|
function todo() {
|
||
|
wikidir=${${PWD%/public_html*}%/wiki*}/wiki
|
||
|
if [ -d "$wikidir" ]; then
|
||
|
$EDITOR "$wikidir/ToDo.md"
|
||
|
fi
|
||
|
}
|
||
|
|
||
7 years ago
|
#This function toggles debug in wp-config
|
||
7 years ago
|
function debugToggle(){
|
||
|
public_html=${PWD%/public_html*}/public_html
|
||
|
if [ -d $public_html ]; then
|
||
|
current=$(egrep "'WP_DEBUG'" "$public_html/wp-config.php" | egrep -o "(true|false)")
|
||
|
[[ $current == true ]] && newvalue=false || newvalue=true
|
||
|
sed -i "s/'WP_DEBUG'.*/'WP_DEBUG', $newvalue\)\;/g" "$public_html/wp-config.php"
|
||
|
echo "WP_DEBUG is now $newvalue";
|
||
|
fi
|
||
|
}
|
||
|
|
||
6 years ago
|
# Adds sub folders in by .bin directory to the PATH if they are not already in it
|
||
6 years ago
|
# Also adds .bin to the path adjacent to any public_html folder
|
||
6 years ago
|
function updatePath(){
|
||
6 years ago
|
# Reset the path
|
||
|
PATH=$(echo $PATH | sed -E "s/:\/home\/jonathan\/\.bin\/.*//g")
|
||
6 years ago
|
for d in ~/.bin/*/; do
|
||
|
if [[ :$PATH: != *:"$d":* ]] ; then
|
||
|
PATH+=":$d"
|
||
|
fi
|
||
|
done
|
||
6 years ago
|
public_html=${PWD%/public_html*}/public_html
|
||
|
if [ -d $public_html ]; then
|
||
|
PATH+=":${PWD%/public_html*}/.bin"
|
||
|
fi
|
||
|
|
||
7 years ago
|
}
|
||
|
|