Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added .functions file
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters