| 1 | function gcom { |
| 2 | local message=$@ |
| 3 | echo "$message" |
| 4 | git add . && git commit -m "$message" |
| 5 | } |
| 6 | function vsource() { |
| 7 | local start=`pwd` |
| 8 | for i in $(seq 1 5);do |
| 9 | if test -d venv; then |
| 10 | source venv/**/activate |
| 11 | break |
| 12 | else |
| 13 | cd .. |
| 14 | fi |
| 15 | done |
| 16 | cd $start |
| 17 | } |
| 18 | function Gpush() { |
| 19 | local start=`pwd` |
| 20 | cd ~/.ghost |
| 21 | gcom $@ |
| 22 | git push -u origin main |
| 23 | cd $start |
| 24 | } |
| 25 | function djs() { |
| 26 | local start=`pwd` |
| 27 | for i in $(seq 1 5);do |
| 28 | if test -f manage.py;then |
| 29 | python manage.py runserver $1 |
| 30 | break |
| 31 | else |
| 32 | cd .. |
| 33 | fi |
| 34 | done |
| 35 | cd $start |
| 36 | } |
| 37 | function dj() { |
| 38 | local start=`pwd` |
| 39 | for i in $(seq 1 5);do |
| 40 | if test -f manage.py;then |
| 41 | python manage.py $@ |
| 42 | break |
| 43 | else |
| 44 | cd .. |
| 45 | fi |
| 46 | done |
| 47 | cd $start |
| 48 | } |
| 49 | function Gupdate() { |
| 50 | local start=`pwd` |
| 51 | cd ~/.ghost && git pull |
| 52 | Source |
| 53 | cd $start |
| 54 | } |
| 55 | function pygrep { |
| 56 | local start=`pwd` |
| 57 | local pylocation=`which python` |
| 58 | local pydir=`dirname $pylocation` |
| 59 | local packagedir=$pydir/Lib/site-packages |
| 60 | cd $packagedir |
| 61 | local package=$1 |
| 62 | shift |
| 63 | local search=$@ |
| 64 | grep -rni "$search" $package |
| 65 | cd $start |
| 66 | } |
| 67 | function pygrepcore { |
| 68 | local start=`pwd` |
| 69 | wd python |
| 70 | cd include |
| 71 | local package=$1 |
| 72 | shift |
| 73 | grep "$@" $package.h |
| 74 | cd $start |
| 75 | } |
| 76 | function pmain { |
| 77 | local start=`pwd` |
| 78 | for i in $(seq 1 5);do |
| 79 | if test -f main.py;then |
| 80 | python main.py $@ |
| 81 | break |
| 82 | else |
| 83 | cd .. |
| 84 | fi |
| 85 | done |
| 86 | cd $start |
| 87 | } |
| 88 | function dev { |
| 89 | local start=`pwd` |
| 90 | for i in $(seq 1 5);do |
| 91 | if test -f dev.sh;then |
| 92 | chmod +x dev.sh |
| 93 | ./dev.sh |
| 94 | break |
| 95 | else |
| 96 | cd .. |
| 97 | fi |
| 98 | done |
| 99 | cd $start |
| 100 | } |
| 101 | function gcode { |
| 102 | local files=`find . -name $1` |
| 103 | local i=0 |
| 104 | local choices=( ) |
| 105 | for r in $files;do |
| 106 | echo "$i) $r" |
| 107 | choices+=( $r ) |
| 108 | let i=i+1 |
| 109 | done |
| 110 | echo "What file do you want?" |
| 111 | read choicenum |
| 112 | local choice=${choices[$choicenum]} |
| 113 | echo "Opening $choice with vscode" |
| 114 | code $choice |
| 115 | } |
| 116 | function vbash { |
| 117 | local start=`pwd` |
| 118 | for i in $(seq 1 5);do |
| 119 | if test -d venv;then |
| 120 | vim venv/**/activate |
| 121 | break |
| 122 | else |
| 123 | cd .. |
| 124 | fi |
| 125 | done |
| 126 | cd $start |
| 127 | } |
| 128 | function wdl { |
| 129 | dirname `which $1` |
| 130 | } |
| 131 | function wd { |
| 132 | cd `wdl $1` |
| 133 | } |
| 134 | function dev { |
| 135 | local start=`pwd` |
| 136 | for i in $(seq 1 5);do |
| 137 | if test -f dev.sh;then |
| 138 | ./dev.sh |
| 139 | break |
| 140 | else |
| 141 | cd .. |
| 142 | fi |
| 143 | done |
| 144 | cd $start |
| 145 | } |
| 146 | function pipd () { |
| 147 | updatesetupversion |
| 148 | rm -rf dist *.egg-info build |
| 149 | python setup.py bdist_wheel |
| 150 | pm twine upload --skip-existing dist/* |
| 151 | rm -rf dist *.egg-info build |
| 152 | gcom `cat setup.py | grep version` |
| 153 | git push origin main |
| 154 | } |
| 155 | function updatesetupversion () { |
| 156 | local num=`cat setup.py | grep version | tr -dc '0-9.'` |
| 157 | local updatePart=`echo $num | grep -oE '[^.]+$'` |
| 158 | local updatedPart=$((updatePart+1)) |
| 159 | local firstPart=`echo $num | grep -oE -m 0 '[^.]+$'` |
| 160 | local update=$((firstPart)).$updatedPart |
| 161 | echo $update |
| 162 | sed -i "s/$num/$update/g" setup.py |
| 163 | } |
| 164 | function psand () { |
| 165 | local start=`pwd` |
| 166 | for i in $(seq 1 5);do |
| 167 | if test -f sandbox.py;then |
| 168 | python sandbox.py |
| 169 | break |
| 170 | else |
| 171 | cd .. |
| 172 | fi |
| 173 | done |
| 174 | cd $start |
| 175 | } |
| 176 | function venv () { |
| 177 | pm venv venv |
| 178 | vsource |
| 179 | pi --upgrade pip |
| 180 | pi -U autopep8 |
| 181 | } |
| 182 | function rust () { |
| 183 | local base=`echo $1 | cut -d\. -f1` |
| 184 | rustc $1 && ./$base && rm $base.exe $base.pdb |
| 185 | } |
| 186 | function forward () { |
| 187 | while true; do |
| 188 | ssh -N -R $2:localhost:$3 $1 |
| 189 | done |
| 190 | } |
| 191 | function dnames () { |
| 192 | docker ps --format '{{.Names}}' |
| 193 | } |
| 194 | function dsh () { |
| 195 | local container=$(dnames | grep $1 | head -1) |
| 196 | echo "Connecting to $container" |
| 197 | docker exec -it $container sh |
| 198 | } |