| @@ -55,6 +55,9 @@ function git { | |||
| 55 | 55 | newdir="$lastarg" | |
| 56 | 56 | else | |
| 57 | 57 | newdir="$(basename $lastarg .git)" | |
| 58 | + | if case $penultimatearg in *":"*) false;; esac; then | |
| 59 | + | newdir=${newdir#*:} | |
| 60 | + | fi | |
| 58 | 61 | fi | |
| 59 | 62 | ||
| 60 | 63 | # this original way which doesn't support args when clone'ing | |
willpower232 / bash.bashrc
Last active 1 month ago
I am making my .bashrc portable as inspired by this https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html
Will Power revised this gist 5 years ago · b4ffad5
1 file changed, 3 insertions
Will Power revised this gist 5 years ago · b425325
1 file changed, 5 insertions, 2 deletions
| @@ -103,8 +103,11 @@ alias chown='chown --preserve-root' | |||
| 103 | 103 | alias chmod='chmod --preserve-root' | |
| 104 | 104 | alias chgrp='chgrp --preserve-root' | |
| 105 | 105 | ||
| 106 | - | function findinfiles() { find ./ -type f -print0 | xargs -0 grep -i "$1"; } | |
| 107 | - | function findinphpfiles() { find ./ -type f -name "*.php" -print0 | xargs -0 grep -i "$1"; } | |
| 106 | + | # I haven't used these in a while since I taught myself to use grep -R | |
| 107 | + | # don't forget about -i for ignoring case and -l if you just want file names and first matches | |
| 108 | + | # but you could rewrite these to use ag if you wanted but they also might not follow symlinks | |
| 109 | + | #function findinfiles() { find ./ -type f -print0 | xargs -0 grep -i "$1"; } | |
| 110 | + | #function findinphpfiles() { find ./ -type f -name "*.php" -print0 | xargs -0 grep -i "$1"; } | |
| 108 | 111 | ||
| 109 | 112 | complete -W "$(echo $(grep '^ssh ' ~/.bash_history | sort -u | sed 's/^ssh //'))" ssh | |
| 110 | 113 | ||
Will Power revised this gist 5 years ago · d3c3e62
1 file changed, 3 insertions
| @@ -5,3 +5,6 @@ if [ -n "$BASH_VERSION" ]; then | |||
| 5 | 5 | . "$HOME/.bashrc" | |
| 6 | 6 | fi | |
| 7 | 7 | fi | |
| 8 | + | ||
| 9 | + | # likely to not have a UI so need to sign commits in the terminal | |
| 10 | + | #export GPG_TTY=$(tty) | |
Will Power revised this gist 5 years ago · 3f350dd
1 file changed, 3 insertions, 2 deletions
| @@ -88,9 +88,10 @@ function git { | |||
| 88 | 88 | echo "removed core.filemode setting boss" | |
| 89 | 89 | cd $curdir | |
| 90 | 90 | ||
| 91 | - | elif [[ "$1" == "branch" && "$@" != *"--help"* ]]; then | |
| 91 | + | elif [[ "$1" == "branch" && "$@" != *"--help"* && -z "$3" ]]; then | |
| 92 | 92 | shift 1 | |
| 93 | - | command git checkout -b "$@" | |
| 93 | + | echo "switching to checkout..." | |
| 94 | + | command git checkout -b "$@" || command git checkout "$@" | |
| 94 | 95 | else | |
| 95 | 96 | command git "$@" | |
| 96 | 97 | fi | |
Will Power revised this gist 5 years ago · 9a30a1b
1 file changed, 1 insertion, 1 deletion
| @@ -65,7 +65,7 @@ function git { | |||
| 65 | 65 | #fi | |
| 66 | 66 | ||
| 67 | 67 | shift 1 | |
| 68 | - | command git clone "$@" || exit 1 | |
| 68 | + | command git clone "$@" || return 1 | |
| 69 | 69 | cd $newdir | |
| 70 | 70 | ||
| 71 | 71 | #case $@ in | |
Will Power revised this gist 5 years ago · 7b93b7f
1 file changed, 15 insertions, 3 deletions
| @@ -46,12 +46,24 @@ function git { | |||
| 46 | 46 | ||
| 47 | 47 | curdir="$(pwd)" | |
| 48 | 48 | ||
| 49 | - | if [ -z "$3" ]; then | |
| 50 | - | newdir="$(basename $2 .git)" | |
| 49 | + | argsarray=($(echo $@ | tr " " "\n")) | |
| 50 | + | lastarg=${argsarray[-1]} | |
| 51 | + | penultimatearg=${argsarray[-2]} | |
| 52 | + | ||
| 53 | + | # if the penultimate arg contains @ or :// then it must be the repo url | |
| 54 | + | if ! case $penultimatearg in *"@"* | *"://"*) false;; esac; then | |
| 55 | + | newdir="$lastarg" | |
| 51 | 56 | else | |
| 52 | - | newdir="$3" | |
| 57 | + | newdir="$(basename $lastarg .git)" | |
| 53 | 58 | fi | |
| 54 | 59 | ||
| 60 | + | # this original way which doesn't support args when clone'ing | |
| 61 | + | #if [ -z "$3" ]; then | |
| 62 | + | # newdir="$(basename $2 .git)" | |
| 63 | + | #else | |
| 64 | + | # newdir="$3" | |
| 65 | + | #fi | |
| 66 | + | ||
| 55 | 67 | shift 1 | |
| 56 | 68 | command git clone "$@" || exit 1 | |
| 57 | 69 | cd $newdir | |
Will Power revised this gist 5 years ago · e379978
1 file changed, 1 insertion, 1 deletion
| @@ -53,7 +53,7 @@ function git { | |||
| 53 | 53 | fi | |
| 54 | 54 | ||
| 55 | 55 | shift 1 | |
| 56 | - | command git clone "$@" | |
| 56 | + | command git clone "$@" || exit 1 | |
| 57 | 57 | cd $newdir | |
| 58 | 58 | ||
| 59 | 59 | #case $@ in | |
Will Power revised this gist 5 years ago · 6834b31
1 file changed, 18 insertions, 1 deletion
| @@ -55,9 +55,26 @@ function git { | |||
| 55 | 55 | shift 1 | |
| 56 | 56 | command git clone "$@" | |
| 57 | 57 | cd $newdir | |
| 58 | + | ||
| 59 | + | #case $@ in | |
| 60 | + | # *"workgithubname"*) | |
| 61 | + | # command git config user.email me@work.com | |
| 62 | + | # echo "set user for work boss" | |
| 63 | + | # ;; | |
| 64 | + | ||
| 65 | + | # *"personalgithubname"*) | |
| 66 | + | # command git config user.email me@home.com | |
| 67 | + | # echo "set user for personal boss" | |
| 68 | + | # ;; | |
| 69 | + | ||
| 70 | + | # *) | |
| 71 | + | # echo "whoareyou" | |
| 72 | + | # ;; | |
| 73 | + | #esac | |
| 74 | + | ||
| 58 | 75 | command git config --unset core.filemode | |
| 76 | + | echo "removed core.filemode setting boss" | |
| 59 | 77 | cd $curdir | |
| 60 | - | echo "removed core.filemode setting boss" | |
| 61 | 78 | ||
| 62 | 79 | elif [[ "$1" == "branch" && "$@" != *"--help"* ]]; then | |
| 63 | 80 | shift 1 | |
Will Power revised this gist 5 years ago · f8599f5
1 file changed, 6 insertions
| @@ -170,3 +170,9 @@ fi | |||
| 170 | 170 | #if [ -f /etc/bash_completion ]; then | |
| 171 | 171 | # . /etc/bash_completion | |
| 172 | 172 | #fi | |
| 173 | + | ||
| 174 | + | # set PATH so it includes user's private bin if it exists | |
| 175 | + | # I use a separate bin to backup standalone binaries | |
| 176 | + | #if [ -d "$HOME/bin" ] ; then | |
| 177 | + | # PATH="$HOME/bin:$PATH" | |
| 178 | + | #fi | |
Will Power revised this gist 6 years ago · f767db8
1 file changed, 3 insertions
| @@ -61,6 +61,9 @@ function qk { | |||
| 61 | 61 | firstpod="$(k get pods --output=jsonpath="{.items[0].metadata.name}" | head -1)" | |
| 62 | 62 | echo "Running in $firstpod" | |
| 63 | 63 | k exec -it $firstpod "$@" | |
| 64 | + | elif [[ "$1" == "redeploy" ]]; then | |
| 65 | + | shift 1 | |
| 66 | + | k patch deployment "$1" -p "{\"spec\": {\"template\": {\"metadata\": { \"labels\": { \"redeploy\": \"$(date +%s)\"}}}}}" | |
| 64 | 67 | else | |
| 65 | 68 | command kubectl "$@" | |
| 66 | 69 | fi | |