From 6ea3f345b0b809ed83002ad008d9e1f826144616 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 17 Apr 2018 22:47:11 +0100 Subject: [PATCH] Work on dotdiles --- .gitmodules | 3 + rofi/rofi | 1 + rofi/scripts/rofi-emoji | 2 +- shells/aliases | 162 ++++++++++++++++++++ shells/bash/bash_profile | 18 +-- shells/bash/bashrc | 192 +---------------------- shells/functions | 233 ++++++++++++++++++++++++++++ shells/profile | 14 ++ shells/zsh/oh-my-zsh/aliases.zsh | 142 +---------------- shells/zsh/oh-my-zsh/functions.zsh | 234 +---------------------------- shells/zsh/zprofile | 15 +- shells/zsh/zsh-syntax-highlighting | 1 + shells/zsh/zshrc | 9 +- symlinks.sh | 53 +++++-- 14 files changed, 465 insertions(+), 614 deletions(-) create mode 120000 rofi/rofi create mode 100644 shells/aliases create mode 100644 shells/functions create mode 100644 shells/profile create mode 160000 shells/zsh/zsh-syntax-highlighting diff --git a/.gitmodules b/.gitmodules index 4d854e8e..e8ee1da8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "custom-oh-my-zsh/themes/powerlevel9k"] path = custom-oh-my-zsh/themes/powerlevel9k url = https://github.com/bhilburn/powerlevel9k.git +[submodule "shells/zsh/zsh-syntax-highlighting"] + path = shells/zsh/zsh-syntax-highlighting + url = https://github.com/zsh-users/zsh-syntax-highlighting.git diff --git a/rofi/rofi b/rofi/rofi new file mode 120000 index 00000000..a193de6e --- /dev/null +++ b/rofi/rofi @@ -0,0 +1 @@ +/home/jonathan/.dotfiles/rofi \ No newline at end of file diff --git a/rofi/scripts/rofi-emoji b/rofi/scripts/rofi-emoji index ff6ed6a9..a65c98e1 100755 --- a/rofi/scripts/rofi-emoji +++ b/rofi/scripts/rofi-emoji @@ -21,7 +21,7 @@ # # Where to save the emojis file. -UNICODE_FILE="/home/jonathan/.dotfiles/config/rofi/scripts/unicode.txt" +UNICODE_FILE="$HOME/.dotfiles/rofi/scripts/unicode.txt" # Urls of emoji to download. # You can remove what you don't need. diff --git a/shells/aliases b/shells/aliases new file mode 100644 index 00000000..8703e292 --- /dev/null +++ b/shells/aliases @@ -0,0 +1,162 @@ +# These alow me to easily set the file and folder permissions for a wordpress instilation. +alias folder-perms='find . -type d -not -path "./.git/*" -not -path "./.git" -not -perm 775 -exec chmod 775 {} \;' +alias file-perms='find . -type f -not -path "./.git/*" -not -path "./.git" -not -perm 664 -exec chmod 664 {} \;' +alias wp-perms='folder-perms; file-perms' +alias magentoPerms='cd ${PWD%/public_html*}/public_html;sudo chown -R jonathan:http .; folder-perms; file-perms; chmod +x bin/*; cd -' +alias upgr='magento setup:upgrade && magento setup:di:compile && magentoPerms' + # +# Make ls add Indicator#s to file names and colour the output +alias ls='ls -F --color=auto' + +# Make tree add indicators and color +alias tree='tree -F -C' + +# Make qmv open on 1 column mode +alias qmv='qmv -f do' + +alias msfconsole="msfconsole --quiet -x \"db_connect msf@msf\"" + +#Start cups +alias cups='sudo systemctl start org.cups.cupsd.service' + +#Start network manager +alias net='sudo systemctl start NetworkManager.service' + +# Alias lampp because I don't want to clog my PATH +alias lampp='/opt/lampp/lampp' +alias glampp='gksudo /opt/lampp/manager-linux-x64.run' +alias php='/opt/lampp/bin/php' +alias php-cgi='/opt/lampp/bin/php-cgi' +alias php-config='/opt/lampp/bin/php-config' + +#Always make all directories necesary +alias mkdir='mkdir -p' + +# Shortcut for rewriting wp permalinks +alias perms='wp rewrite flush' + +#Clear terminal and screenfetch +alias cls='clear; neofetch' + +#An alias for my standard less configuration +#I don't set it to lessc because sometimes I don't use this config and I always forget how to ignore an alias +#alias myless='lessc --clean-css --source-map-basepath=/home/jonathan/Sites/charts/public_html --source-map --autoprefix="last 3 versions, ie >= 9" styles.less styles.min.css' +alias myless='lessc --clean-css --source-map --autoprefix="last 3 versions, ie >= 11" styles.less styles.min.css' + +# Git shortcuts +alias status='git status ' +alias st='git status' +alias checkout='git checkout' +alias ch='git checkout' +alias push='git push ' +alias pull='git pull ' +alias bb='git open' +alias merge='git merge' +alias mg='git merge' + +# Always make grep ouput color +alias grep="grep --color=auto" + +# Shortcuts to sites folder +alias sites="cd ~/Sites" +alias s="cd ~/Sites" + +# Shortcuts to documents folder +alias documents="cd ~/Documents/" +alias d="cd ~/Documents/" + +# Shortcuts to hack the box folder +alias htb="cd ~/Documents/htb/" + +# Shortcuts to documents folder +alias db="cd ~/Dropbox/" + +# Shortcuts to home folder +alias home="cd ~/" +alias ~="cd ~/" + +#Goes up to the public_html folder +alias ph='cd ${PWD%/public_html*}/public_html' + +# Quit the terminal using :q (The same as Vi/Vim) +alias :q='exit;' + +# Not sure why and how but this makes sudo work with my aliases +alias sudo='sudo ' + +#Make the cal command default to start on Sunday +alias cal='cal -s' + +# update the third party wordpress plugins we are mirroring +alias u3p='update3rdPartyPlugins' + +# Edit my bashrc +alias brc='$EDITOR ~/.bashrc' + +# Edit my vimrc +alias vrc='$EDITOR ~/.vimrc' + +# Go to my .vim folder +alias .v='cd ~/.vim/' + +alias df='cd ~/.dotfiles' + +#Make vim start in server mode +alias vim='vim --servername jab2870' + +# moon phase +alias moonphase='weather moon' + +#Get arch news +alias archNews='w3m https://www.archlinux.org/ | sed -n "/Latest News/,/Older News/ p" | head -n -1 | less' + +#Radio Stations +AUDIO=mpv +alias radio2="$AUDIO http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_two.m3u8" +alias radio4="$AUDIO http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_fourfm.m3u8" +alias classic="$AUDIO http://icy-e-bab-04-cr.sharp-stream.com/absoluteradio.mp3" +alias absolute="$AUDIO 'http://network.absoluteradio.co.uk/core/audio/mp3/live.pls?service=vrbb'" + +alias bs="curl -s http://cbsg.sourceforge.net/cgi-bin/live | grep -Eo '^
  • .*
  • ' | sed -r -e 's/<\/?li>//g' | shuf -n 1 | cowsay" + +alias jq="jq -C" + +alias debugBuild='node --inspect-brk /usr/bin/grunt build' + +alias lc="colorls -r" + +alias open="$TERMINAL & disown" + +#audiable to mp3 +alias aa2mp3='ffmpeg -f concat -safe 0 -i <(for f in *.aa; do echo "file '"'"'$(pwd)/$f'"'"'";done) output.mp3' + +# Fix Typos +alias cim="vim" +alias vom="vim" +alias vin="vim" +alias vi="vim" +alias v="vim" + +#Servers Memory +alias servermem='toilet -w 200 "VPS 01" && ssh shires free -h && toilet -w 200 "VPS 02" && ssh abc free -h && toilet -w 200 "VPS 03" && ssh cdc2 free -h && toilet -w 200 "Freightliner" && ssh freightliner free -h && toilet -w 200 "NHS" && ssh nhs free -h' + +########################################### +# # +# Suffex Aliases # +# # +########################################### + +alias -s html=$EDITOR +alias -s htm=$EDITOR + +alias -s php=$EDITOR + +alias -s less=$EDITOR +alias -s css=$EDITOR + +alias -s js=$EDITOR +alias -s es6=$EDITOR + +alias -s gitignore=$EDITOR + +alias -s json=$EDITOR diff --git a/shells/bash/bash_profile b/shells/bash/bash_profile index bdd1682f..faecfd4d 100644 --- a/shells/bash/bash_profile +++ b/shells/bash/bash_profile @@ -7,25 +7,9 @@ -export TERMINAL=/usr/bin/konsole -export TERM=xterm-256color -export PATH=~/.bin:$PATH:/opt/lampp/bin:. -export EDITOR='vim --servername jab2870' -export CDPATH=.:~:~/Sites - -#Ruby things -GEM_HOME=$(ls -t -U | ruby -e 'puts Gem.user_dir') -GEM_PATH=$GEM_HOME -export PATH=$PATH:$GEM_HOME/bin -export GEM_HOME=$(ruby -e 'print Gem.user_dir') +source ~/.dotfiles/shells/profile # tab completion for ssh hosts complete -o default -o nospace -W "$(/usr/bin/env ruby -ne 'puts $_.split(/[,\s]+/)[1..-1].reject{|host| host.match(/\*|\?/)} if $_.match(/^\s*Host\s+/);' < $HOME/.ssh/config)" scp sftp ssh -#echo -e "Please don't sabotage my computer while I'm away \n\nTo turn on the print server, run the command 'cups'\n\nTo update 3d party plugins, run command 'u3p'" | /usr/bin/cowsay -f tux -W 80 - - -[ -r "$HOME/.smartcd_config" ] && ( [ -n $BASH_VERSION ] || [ -n $ZSH_VERSION ] ) && source ~/.smartcd_config - -[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* diff --git a/shells/bash/bashrc b/shells/bash/bashrc index c6cb4ae9..df2d3bd1 100644 --- a/shells/bash/bashrc +++ b/shells/bash/bashrc @@ -2,200 +2,14 @@ # ~/.bashrc # + # If not running interactively, don't do anything [[ $- != *i* ]] && return +source ~/.dotfiles/shells/aliases +source ~/.dotfiles/shells/functions -big-chromium () { - chromium --force-device-scale-factor=$1 -} - -big-new-chromium () { - chromium-snapshot-bin --force-device-scale-factor=$1 -} - -#Swap two files -function swap() { - mv $1 $1._tmp; - mv $2 $1; - mv $1._tmp $2; -} - -function old() { - mv "$1" "$1.old" -} - -#This prints the current working directory after doing a cd" -cdls(){ - cd "$@" - ls -F --color=always -} - -#Takes you to the aquarius theme -function aquarius() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - theme=$public_html/wp-content/themes - if [ -d $theme ]; then - cdls $theme/aquarius - else - echo " Can't find theme folder " - fi - else - echo " Can't find public_html folder." - fi -} - -#Takes you to the child theme -function theme() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - theme=$public_html/wp-content/themes - if [ -d $theme ]; then - child=$(ls -d $theme/*/ | grep -v "$theme\/aquarius" | grep -v "$theme\/twenty*" | grep -v "$theme\/barelycorporate" -m 1) - cdls $child - else - echo " Can't find theme folder " - fi - else - echo " Can't find public_html folder." - fi -} - -######################################## -## ## -## Search Functions ## -## ## -######################################## - -#These search functions use grep to search all sub-folders of the current working directory -searchjs() { - # This will search through .js and .es6 files but won't search minified files - grep -r -i -n --color="always" --include=\*.{js,es6} --exclude=\*.min.js "$1" . -} -searchcss() { - # This will search through .css and .less files but won't search minified files - grep -r -i -n --color="always" --include=\*.{css,less,scss,sass} --exclude=\*.min.css "$1" . -} -searchphp() { - grep -r -i -n --color="always" --include="*.php" "$1" . -} - -# This makes cd use function above -alias cd="cdls" - -# These alow me to easily set the file and folder permissions for a wordpress instilation. -alias folder-perms='find . -type d -not -path "./.git/*" -not -path "./.git" -exec chmod 775 {} \;' -alias file-perms='find . -type f -not -path "./.git/*" -not -path "./.git" -exec chmod 664 {} \;' -alias wp-perms='folder-perms; file-perms' -alias magentoPerms='cd ${PWD%/public_html*}/public_html;sudo chown -R jonathan:http .; folder-perms; file-perms; chmod +x bin/magento; cd -' - # -# Make ls add Indicator#s to file names and colour the output -alias ls='ls -F --color=auto' - -# Make tree add indicators and color -alias tree='tree -F -C' - -#Start cups -alias cups='sudo systemctl start org.cups.cupsd.service' - -#Start network manager -alias net='sudo systemctl start NetworkManager.service' - -# Alias lampp because I don't want to clog my PATH -alias lampp='/opt/lampp/lampp' -alias glampp='gksudo /opt/lampp/manager-linux-x64.run' -alias php='/opt/lampp/bin/php' -alias php-cgi='/opt/lampp/bin/php-cgi' -alias php-config='/opt/lampp/bin/php-config' - -#Always make all directories necesary -alias mkdir='mkdir -p' - -# Shortcut for rewriting wp permalinks -alias perms='wp rewrite flush' - -#Clear terminal and screenfetch -alias cls='clear; screenfetch' - -#An alias for my standard less configuration -#I don't set it to lessc because sometimes I don't use this config and I always forget how to ignore an alias -#alias myless='lessc --clean-css --source-map-basepath=/home/jonathan/Sites/charts/public_html --source-map --autoprefix="last 3 versions, ie >= 9" styles.less styles.min.css' -alias myless='lessc --clean-css --source-map --autoprefix="last 3 versions, ie >= 9" styles.less styles.min.css' - -# Git shortcuts -alias status='git status ' -alias st='git status' -alias checkout='git checkout' -alias ch='git checkout' -alias push='git push ' -alias pull='git pull ' -alias bb='git open' - -# Always make grep ouput color -alias grep="grep --color=auto" - -# Shortcuts to sites folder -alias sites="cd ~/Sites" -alias s="cd ~/Sites" - -# Shortcuts to documents folder -alias documents="cd ~/Documents/" -alias d="cd ~/Documents/" - -# Shortcuts to home folder -alias home="cd ~/" -alias ~="cd ~/" - -#Goes up to the public_html folder -alias ph='cd ${PWD%/public_html*}/public_html' - -# Quit the terminal using :q (The same as Vi/Vim) -alias :q='exit;' - -# Not sure why and how but this makes sudo work with my aliases -alias sudo='sudo ' - -#Make the cal command default to start on Sunday -alias cal='cal -s' - -# update the third party wordpress plugins we are mirroring -alias u3p='update3rdPartyPlugins' - -# Edit my bashrc -alias brc='$EDITOR ~/.bashrc' - -# Edit my vimrc -alias vrc='$EDITOR ~/.vimrc' - -# Go to my .vim folder -alias .v='cd ~/.vim/' -# Go to my dotfiles folder -#if [[ $(hostname) == "jonathansnuc" ]]; then -# #Please don't judge - This is a reminant from first days of version controlling dotfiles -# alias df='cd ~/Downloads/laptopConfig/' -#else - alias df='cd ~/.dotfiles' -#fi - -#Make vim start in server mode -alias vim='vim --servername jab2870' - -# moon phase -alias moonphase='weather moon' - -#Radio Stations -AUDIO=mpv -alias radio2="$AUDIO http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_two.m3u8" -alias radio4="$AUDIO http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_fourfm.m3u8" -alias classic="$AUDIO http://icy-e-bab-04-cr.sharp-stream.com/absoluteradio.mp3" -alias absolute="$AUDIO http://network.absoluteradio.co.uk/core/audio/mp3/live.pls?service=vrbb" - -alias bs="curl -s http://cbsg.sourceforge.net/cgi-bin/live | grep -Eo '^
  • .*
  • ' | sed s,\\,,g | shuf -n 1 | cowsay" - -alias jq="jq -C" -alias debugBuild='node --inspect-brk /usr/bin/grunt build' #alias xkcd='curl https://xkcd.com/info.0.json 2> /dev/null| \jq ".img" | xargs feh' diff --git a/shells/functions b/shells/functions new file mode 100644 index 00000000..5e0f72d2 --- /dev/null +++ b/shells/functions @@ -0,0 +1,233 @@ +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 +function xclip(){ +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" +} + +function cdlc() { + cd "$@" + /home/jonathan/.gem/ruby/2.4.0/bin/colorls --sd | tail -n +2 +} +#alias cd="cdlc" + +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 +} + +#Takes you to the parent theme +function ptheme() { + public_html=${PWD%/public_html*}/public_html + if [ -d $public_html ]; then + if [ -d $public_html/wp ]; then + wpPath=$public_html/wp; + else + wpPath=$public_html; + fi + theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "parent" | awk '{print $1}'))) + 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 +} + +#Takes you to the child theme +function theme() { + public_html=${PWD%/public_html*}/public_html + if [ -d $public_html ]; then + if [ -d $public_html/wp ]; then + wpPath=$public_html/wp; + else + wpPath=$public_html; + fi + theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) + if [ -d $theme ]; then + cd $theme + else + echo " Can't find theme folder " + fi + else + echo " Can't find public_html folder." + fi +} + +#Takes you to the js folder child theme +function js() { + public_html=${PWD%/public_html*}/public_html + if [ -d $public_html ]; then + if [ -d $public_html/wp ]; then + wpPath=$public_html/wp; + else + wpPath=$public_html; + fi + theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) + if [ -d $theme ]; then + if [ -d "$theme/js" ]; then + cd "$theme/js" + else + echo "Can't find a JS folder. Here is the theme" + cd "$theme" + fi + else + echo " Can't find theme folder " + fi + else + echo " Can't find public_html folder." + fi +} + +#Takes you to the css folder child theme +function css() { + public_html=${PWD%/public_html*}/public_html + if [ -d $public_html ]; then + if [ -d $public_html/wp ]; then + wpPath=$public_html/wp; + else + wpPath=$public_html; + fi + theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) + if [ -d $theme ]; then + if [ -d "$theme/css" ]; then + cd "$theme/css" + else + echo "Can't find a CSS folder. Here is the theme" + cd "$theme" + fi + else + echo " Can't find theme folder " + fi + else + echo " Can't find public_html folder." + fi +} + +#Takes you to the plugin directory +function plugins() { + public_html=${PWD%/public_html*}/public_html + if [ -d $public_html ]; then + if [ -d $public_html/wp ]; then + wpPath=$public_html/wp; + else + wpPath=$public_html; + fi + cd $(wp --path="$wpPath" plugin path) + else + echo " Can't find public_html folder." + fi +} + +#Takes you to the theme directory +function themes() { + public_html=${PWD%/public_html*}/public_html + 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 +} + +######################################## +## ## +## Search Functions ## +## ## +######################################## + +#These search functions use grep to search all sub-folders of the current working directory +searchjs() { + # This will search through .js and .es6 files but won't search minified files + grep -r -i -n --color="always" --include=\*.{js,es6} --exclude=\*.min.js "$1" . +} +searchcss() { + # This will search through .css and .less files but won't search minified files + grep -r -i -n --color="always" --include=\*.{css,less,scss,sass} --exclude=\*.min.css "$1" . +} +searchphp() { + grep -r -i -n --color="always" --include=\*.{php,phtml} "$1" . +} +searchhtml() { + grep -r -i -n --color="always" --include=\*.{html,htm} "$1" . +} + +png() { + pngcrush -brute "$1"{,.} && du -b "$1"{,.} +} +gif() { + gifsicle -O "$1" -o "$1." && du -b "$1"{,.} +} +jpeg() { + jpegtran "$1" > "$1." && du -b "$1"{,.} +} +# Just for easy access in history +mpng() { + mv "$1"{.,} +} +mgif() { + newsize=$(wc -c <"$1.") + oldsize=$(wc -c <"$1") + if [ $oldsize -gt $newsize ] ; then + mv "$1"{.,} + else + rm "$1." + fi +} +mjpeg() { + mv "$1"{.,} +} diff --git a/shells/profile b/shells/profile new file mode 100644 index 00000000..25a242ae --- /dev/null +++ b/shells/profile @@ -0,0 +1,14 @@ +export LANG="en_GB.UTF-8" +export TERMINAL=/usr/local/bin/st +export TERM=xterm-256color +export PATH=~/.bin:$PATH:/opt/lampp/bin:. +export EDITOR='vim' +export CDPATH=.:~:~/Sites + +#Ruby things +GEM_HOME=$(ls -t -U | ruby -e 'puts Gem.user_dir') +GEM_PATH=$GEM_HOME +export PATH=$PATH:$GEM_HOME/bin +export GEM_HOME=$(ruby -e 'print Gem.user_dir') + +echo -e "Please don't sabotage my computer while I'm away \n\nTo turn on the print server, run the command 'cups'\n\nTo update 3d party plugins, run command 'u3p'\n\nTo turn on my servers, run command 'sudo lampp start'" | /usr/bin/cowsay -f tux -W 80 diff --git a/shells/zsh/oh-my-zsh/aliases.zsh b/shells/zsh/oh-my-zsh/aliases.zsh index 8703e292..7e54dffb 100644 --- a/shells/zsh/oh-my-zsh/aliases.zsh +++ b/shells/zsh/oh-my-zsh/aliases.zsh @@ -1,144 +1,4 @@ -# These alow me to easily set the file and folder permissions for a wordpress instilation. -alias folder-perms='find . -type d -not -path "./.git/*" -not -path "./.git" -not -perm 775 -exec chmod 775 {} \;' -alias file-perms='find . -type f -not -path "./.git/*" -not -path "./.git" -not -perm 664 -exec chmod 664 {} \;' -alias wp-perms='folder-perms; file-perms' -alias magentoPerms='cd ${PWD%/public_html*}/public_html;sudo chown -R jonathan:http .; folder-perms; file-perms; chmod +x bin/*; cd -' -alias upgr='magento setup:upgrade && magento setup:di:compile && magentoPerms' - # -# Make ls add Indicator#s to file names and colour the output -alias ls='ls -F --color=auto' - -# Make tree add indicators and color -alias tree='tree -F -C' - -# Make qmv open on 1 column mode -alias qmv='qmv -f do' - -alias msfconsole="msfconsole --quiet -x \"db_connect msf@msf\"" - -#Start cups -alias cups='sudo systemctl start org.cups.cupsd.service' - -#Start network manager -alias net='sudo systemctl start NetworkManager.service' - -# Alias lampp because I don't want to clog my PATH -alias lampp='/opt/lampp/lampp' -alias glampp='gksudo /opt/lampp/manager-linux-x64.run' -alias php='/opt/lampp/bin/php' -alias php-cgi='/opt/lampp/bin/php-cgi' -alias php-config='/opt/lampp/bin/php-config' - -#Always make all directories necesary -alias mkdir='mkdir -p' - -# Shortcut for rewriting wp permalinks -alias perms='wp rewrite flush' - -#Clear terminal and screenfetch -alias cls='clear; neofetch' - -#An alias for my standard less configuration -#I don't set it to lessc because sometimes I don't use this config and I always forget how to ignore an alias -#alias myless='lessc --clean-css --source-map-basepath=/home/jonathan/Sites/charts/public_html --source-map --autoprefix="last 3 versions, ie >= 9" styles.less styles.min.css' -alias myless='lessc --clean-css --source-map --autoprefix="last 3 versions, ie >= 11" styles.less styles.min.css' - -# Git shortcuts -alias status='git status ' -alias st='git status' -alias checkout='git checkout' -alias ch='git checkout' -alias push='git push ' -alias pull='git pull ' -alias bb='git open' -alias merge='git merge' -alias mg='git merge' - -# Always make grep ouput color -alias grep="grep --color=auto" - -# Shortcuts to sites folder -alias sites="cd ~/Sites" -alias s="cd ~/Sites" - -# Shortcuts to documents folder -alias documents="cd ~/Documents/" -alias d="cd ~/Documents/" - -# Shortcuts to hack the box folder -alias htb="cd ~/Documents/htb/" - -# Shortcuts to documents folder -alias db="cd ~/Dropbox/" - -# Shortcuts to home folder -alias home="cd ~/" -alias ~="cd ~/" - -#Goes up to the public_html folder -alias ph='cd ${PWD%/public_html*}/public_html' - -# Quit the terminal using :q (The same as Vi/Vim) -alias :q='exit;' - -# Not sure why and how but this makes sudo work with my aliases -alias sudo='sudo ' - -#Make the cal command default to start on Sunday -alias cal='cal -s' - -# update the third party wordpress plugins we are mirroring -alias u3p='update3rdPartyPlugins' - -# Edit my bashrc -alias brc='$EDITOR ~/.bashrc' - -# Edit my vimrc -alias vrc='$EDITOR ~/.vimrc' - -# Go to my .vim folder -alias .v='cd ~/.vim/' - -alias df='cd ~/.dotfiles' - -#Make vim start in server mode -alias vim='vim --servername jab2870' - -# moon phase -alias moonphase='weather moon' - -#Get arch news -alias archNews='w3m https://www.archlinux.org/ | sed -n "/Latest News/,/Older News/ p" | head -n -1 | less' - -#Radio Stations -AUDIO=mpv -alias radio2="$AUDIO http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_two.m3u8" -alias radio4="$AUDIO http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_fourfm.m3u8" -alias classic="$AUDIO http://icy-e-bab-04-cr.sharp-stream.com/absoluteradio.mp3" -alias absolute="$AUDIO 'http://network.absoluteradio.co.uk/core/audio/mp3/live.pls?service=vrbb'" - -alias bs="curl -s http://cbsg.sourceforge.net/cgi-bin/live | grep -Eo '^
  • .*
  • ' | sed -r -e 's/<\/?li>//g' | shuf -n 1 | cowsay" - -alias jq="jq -C" - -alias debugBuild='node --inspect-brk /usr/bin/grunt build' - -alias lc="colorls -r" - -alias open="$TERMINAL & disown" - -#audiable to mp3 -alias aa2mp3='ffmpeg -f concat -safe 0 -i <(for f in *.aa; do echo "file '"'"'$(pwd)/$f'"'"'";done) output.mp3' - -# Fix Typos -alias cim="vim" -alias vom="vim" -alias vin="vim" -alias vi="vim" -alias v="vim" - -#Servers Memory -alias servermem='toilet -w 200 "VPS 01" && ssh shires free -h && toilet -w 200 "VPS 02" && ssh abc free -h && toilet -w 200 "VPS 03" && ssh cdc2 free -h && toilet -w 200 "Freightliner" && ssh freightliner free -h && toilet -w 200 "NHS" && ssh nhs free -h' +source ~/.dotfiles/shells/aliases ########################################### # # diff --git a/shells/zsh/oh-my-zsh/functions.zsh b/shells/zsh/oh-my-zsh/functions.zsh index 5e0f72d2..1e31a9f9 100644 --- a/shells/zsh/oh-my-zsh/functions.zsh +++ b/shells/zsh/oh-my-zsh/functions.zsh @@ -1,233 +1 @@ -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 -function xclip(){ -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" -} - -function cdlc() { - cd "$@" - /home/jonathan/.gem/ruby/2.4.0/bin/colorls --sd | tail -n +2 -} -#alias cd="cdlc" - -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 -} - -#Takes you to the parent theme -function ptheme() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - if [ -d $public_html/wp ]; then - wpPath=$public_html/wp; - else - wpPath=$public_html; - fi - theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "parent" | awk '{print $1}'))) - 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 -} - -#Takes you to the child theme -function theme() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - if [ -d $public_html/wp ]; then - wpPath=$public_html/wp; - else - wpPath=$public_html; - fi - theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) - if [ -d $theme ]; then - cd $theme - else - echo " Can't find theme folder " - fi - else - echo " Can't find public_html folder." - fi -} - -#Takes you to the js folder child theme -function js() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - if [ -d $public_html/wp ]; then - wpPath=$public_html/wp; - else - wpPath=$public_html; - fi - theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) - if [ -d $theme ]; then - if [ -d "$theme/js" ]; then - cd "$theme/js" - else - echo "Can't find a JS folder. Here is the theme" - cd "$theme" - fi - else - echo " Can't find theme folder " - fi - else - echo " Can't find public_html folder." - fi -} - -#Takes you to the css folder child theme -function css() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - if [ -d $public_html/wp ]; then - wpPath=$public_html/wp; - else - wpPath=$public_html; - fi - theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) - if [ -d $theme ]; then - if [ -d "$theme/css" ]; then - cd "$theme/css" - else - echo "Can't find a CSS folder. Here is the theme" - cd "$theme" - fi - else - echo " Can't find theme folder " - fi - else - echo " Can't find public_html folder." - fi -} - -#Takes you to the plugin directory -function plugins() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - if [ -d $public_html/wp ]; then - wpPath=$public_html/wp; - else - wpPath=$public_html; - fi - cd $(wp --path="$wpPath" plugin path) - else - echo " Can't find public_html folder." - fi -} - -#Takes you to the theme directory -function themes() { - public_html=${PWD%/public_html*}/public_html - 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 -} - -######################################## -## ## -## Search Functions ## -## ## -######################################## - -#These search functions use grep to search all sub-folders of the current working directory -searchjs() { - # This will search through .js and .es6 files but won't search minified files - grep -r -i -n --color="always" --include=\*.{js,es6} --exclude=\*.min.js "$1" . -} -searchcss() { - # This will search through .css and .less files but won't search minified files - grep -r -i -n --color="always" --include=\*.{css,less,scss,sass} --exclude=\*.min.css "$1" . -} -searchphp() { - grep -r -i -n --color="always" --include=\*.{php,phtml} "$1" . -} -searchhtml() { - grep -r -i -n --color="always" --include=\*.{html,htm} "$1" . -} - -png() { - pngcrush -brute "$1"{,.} && du -b "$1"{,.} -} -gif() { - gifsicle -O "$1" -o "$1." && du -b "$1"{,.} -} -jpeg() { - jpegtran "$1" > "$1." && du -b "$1"{,.} -} -# Just for easy access in history -mpng() { - mv "$1"{.,} -} -mgif() { - newsize=$(wc -c <"$1.") - oldsize=$(wc -c <"$1") - if [ $oldsize -gt $newsize ] ; then - mv "$1"{.,} - else - rm "$1." - fi -} -mjpeg() { - mv "$1"{.,} -} +source ~/.dotfiles/shells/functions diff --git a/shells/zsh/zprofile b/shells/zsh/zprofile index 8ece2d57..63e4a6ac 100644 --- a/shells/zsh/zprofile +++ b/shells/zsh/zprofile @@ -1,15 +1,2 @@ -export LANG="en_GB.UTF-8" -export TERMINAL=/usr/local/bin/st -export TERM=xterm-256color -export PATH=~/.bin:$PATH:/opt/lampp/bin:. -export EDITOR='vim' -export CDPATH=.:~:~/Sites +source ~/.dotfiles/shells/profile -#Ruby things -GEM_HOME=$(ls -t -U | ruby -e 'puts Gem.user_dir') -GEM_PATH=$GEM_HOME -export PATH=$PATH:$GEM_HOME/bin -export GEM_HOME=$(ruby -e 'print Gem.user_dir') - -echo -e "Please don't sabotage my computer while I'm away \n\nTo turn on the print server, run the command 'cups'\n\nTo update 3d party plugins, run command 'u3p'\n\nTo turn on my servers, run command 'sudo lampp start'" | /usr/bin/cowsay -f tux -W 80 -export TERM=xterm-256color diff --git a/shells/zsh/zsh-syntax-highlighting b/shells/zsh/zsh-syntax-highlighting new file mode 160000 index 00000000..02a37dd9 --- /dev/null +++ b/shells/zsh/zsh-syntax-highlighting @@ -0,0 +1 @@ +Subproject commit 02a37dd919dc48e0821186e5f20e78bd0215f86a diff --git a/shells/zsh/zshrc b/shells/zsh/zshrc index fc0a56a1..63b76915 100644 --- a/shells/zsh/zshrc +++ b/shells/zsh/zshrc @@ -85,11 +85,4 @@ source $ZSH/oh-my-zsh.sh # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" -if [ -e "$HOME/.smartcd_config" ]; then - [ -r "$HOME/.smartcd_config" ] && ( [ -n $BASH_VERSION ] || [ -n $ZSH_VERSION ] ) && source ~/.smartcd_config -fi - -export TERM=xterm-256color - -# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. -export PATH="$PATH:$HOME/.rvm/bin" +source ~/.dotfiles/shells/zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh diff --git a/symlinks.sh b/symlinks.sh index 37eb13c6..0309faff 100644 --- a/symlinks.sh +++ b/symlinks.sh @@ -1,26 +1,57 @@ #!/usr/bin/sh +# Simple shell script to symlink my dotfiles to their place in the system + +#whether to use -f when creating symlnk +force=false +#Ask if files should be overiten +read -n1 -p "Do you want to overide files if they exist? [y/N] " answer + +#If anser is y or Y then they should be ovewriten +#Anything else and they shouldn't +if [[ "$answer" == "y" || "$answer" == "Y" ]]; then + force=true +fi + +# A wrapper around ln which will force if necesary +function myLink(){ + if $force; then + /usr/bin/ln -sf "$1" "$2" + echo "forced $2 -> $1" + else + /usr/bin/ln -s "$1" "$2" + fi +} + #ZSH -ln -s ~/.dotfiles/shells/zsh/zprofile ~/.zprofile -ln -s ~/.dotfiles/shells/zsh/zshrc ~/.zshrc -ln -s ~/.dotfiles/shells/zsh/zshrc ~/.zshrc.pre-oh-my-zsh +myLink $HOME/.dotfiles/shells/zsh/zprofile $HOME/.zprofile +myLink $HOME/.dotfiles/shells/zsh/zshrc $HOME/.zshrc +myLink $HOME/.dotfiles/shells/zsh/zshrc $HOME/.zshrc.pre-oh-my-zsh #bash -ln -s ~/.dotfiles/shells/bash/bash_profile ~/.bash_profile -ln -s ~/.dotfiles/shells/bash/bashrc ~/.bashrc +myLink $HOME/.dotfiles/shells/bash/bash_profile $HOME/.bash_profile +myLink $HOME/.dotfiles/shells/bash/bashrc $HOME/.bashrc #X -ln -s ~/.dotfiles/x/xinitrc ~/.xinitrc +myLink $HOME/.dotfiles/x/xinitrc $HOME/.xinitrc #Git -ln -s ~/.dotfiles/git/gitconfig ~/.gitconfig +myLink $HOME/.dotfiles/git/gitconfig $HOME/.gitconfig #i3 -mkdir -p ~/.config/i3 -ln -s ~/.dotfiles/i3/config ~/.config/i3/config +mkdir -p $HOME/.config/i3 +myLink $HOME/.dotfiles/i3/config $HOME/.config/i3/config #vim -ln -s ~/.dotfiles/vim ~/.vim -ln -s ~/.dotfiles/vim/.vimrc ~/.vimrc +myLink $HOME/.dotfiles/vim $HOME/.vim +myLink $HOME/.dotfiles/vim/.vimrc $HOME/.vimrc + +#rofi +myLink $HOME/.dotfiles/rofi $HOME/.config/rofi + +#Templates +myLink $HOME/.dotfiles/Templates $HOME/Templates +#Pandoc +myLink $HOME/.dotfiles/pandoc $HOME/.pandoc