Created
January 25, 2019 22:49
-
-
Save spboyer/ad1d487e0bf65c12bbd94c92e12f3102 to your computer and use it in GitHub Desktop.
bashrc scripts
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
function dockerstopall { | |
echo ’stopping all containers’; | |
docker stop $(docker ps -a -q); | |
} | |
function dockerremoveallcontainers { | |
echo ‘removing all containers’; | |
docker rm $(docker ps -a -q); | |
} | |
function dockerremoveuntagged { | |
echo ‘removing untagged images’; | |
docker rmi $(docker images | grep “^<none>”); | |
} | |
function dockeremoveallimages { | |
echo ‘removing all images’; | |
docker rmi $(docker images); | |
} | |
function clone { | |
# customize username to your own | |
local username="spboyer" | |
local url=$1; | |
local repo=$2; | |
if [[ ${url:0:4} == 'http' || ${url:0:3} == 'git' ]] | |
then | |
# just clone this thing. | |
repo=$(echo $url | awk -F/ '{print $NF}' | sed -e 's/.git$//'); | |
elif [[ -z $repo ]] | |
then | |
# my own stuff. | |
repo=$url; | |
url="git@github.com:$username/$repo"; | |
else | |
# not my own, but I know whose it is. | |
url="git@github.com:$url/$repo.git"; | |
fi | |
git clone $url $repo && cd $repo && code-insiders .; | |
} | |
function updatefork() { | |
local branch=$1 | |
git fetch upstream | |
if [[ -n "$1" ]] | |
then | |
echo $branch = "no master" | |
git checkout $branch | |
git merge upstream/$branch | |
else | |
echo $branch = "master" | |
git checkout master | |
git merge upstream/master | |
fi | |
git commit -am 'update fork' | |
git push | |
} | |
## inits, adds the README and push -u | |
function gitcreate() { | |
local user="spboyer" | |
local repo=$1; | |
echo "# " $repo >> README.md | |
git init | |
git add README.md | |
git commit -m "first commit" | |
curl -u $user https://api.github.com/user/repos -d '{"name": "'$repo'"}' | |
git remote add origin git@github.com:$user/$repo.git | |
git push -u origin master | |
} | |
function myip() { | |
ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | |
} | |
###function git branch | |
function parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\u @ \w$\[\033[32m\]\$(parse_git_branch)\[\033[00m\] \n$ " | |
### end git branch | |
# | |
# mkcd command | |
# This is an improvised version of the mkcd command at http://superuser.com/questions/152794/is-there-a-shortcut-to-mkdir-foo-and-immediately-cd-into-it | |
# This function has to be added to the ~/.bashrc file | |
# After that you can run command like: mkdir abc, mkdir -p one/two/three | |
# | |
function mkcd { | |
last=$(eval "echo \$$#") | |
if [ ! -n "$last" ]; then | |
echo "Enter a directory name" | |
elif [ -d $last ]; then | |
echo "\`$last' already exists" | |
else | |
mkdir $@ && cd $last | |
fi | |
} | |
function swaggereditor { | |
echo "Pulling latest Swagger Docker image..." | |
docker pull swaggerapi/swagger-editor | |
echo "Running Swagger." | |
docker run -d -p 3131:8080 swaggerapi/swagger-editor | |
open "http://127.0.0.1:3131" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment