Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added .functions file
  • Loading branch information
eko committed Sep 16, 2017
1 parent 010fb80 commit ff3facc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .functions
@@ -0,0 +1,40 @@
# Clones if a Git repository is given, elsewhere just cd
function cdc() {
name=`sed -e 's/.*\///g' <<< $1`

if [[ ! -d "$1" && $1 =~ ^(github|bitbucket|gitlab)\.[a-z]{2,}/.*$ ]]; then
ssh=`sed -e 's/^/git@/' -e 's/$/.git/' -e 's/\//:/' <<< $1`
git clone $ssh;
fi

cd $name;
}

# Determines size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}

# Creates a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1");
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8";
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
}

# Returns useful information using dig tool
function digga() {
dig +nocmd "$1" any +multiline +noall +answer;
}

1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -11,6 +11,7 @@ install: ## Installs dotfiles into current environment
@$(MAKE) DOTFILE=.hyper.js install_file
@$(MAKE) DOTFILE=.aliases install_file
@$(MAKE) DOTFILE=.exports install_file
@$(MAKE) DOTFILE=.functions install_file
@$(MAKE) DOTFILE=.sources install_file
@$(MAKE) DOTFILE=.zshrc install_file

Expand Down

0 comments on commit ff3facc

Please sign in to comment.