init comit

main
Nicholas Hope 2022-11-03 22:09:35 -04:00
parent 10478cfa81
commit 00230fe82e
5 changed files with 79 additions and 0 deletions

2
.bash_aliases Normal file
View File

@ -0,0 +1,2 @@
alias please='sudo $(fc -ln -1)'
alias resource='source ~/.bash_profile'

12
.bash_functions Normal file
View File

@ -0,0 +1,12 @@
function mcd {
mkdir "$@" && cd $_
}
function rewind {
# cheeky hack
source rewind.sh "$HISTFILE" "$@"
}
function download {
curl "$1" > "$2"
}

3
.bash_profile Normal file
View File

@ -0,0 +1,3 @@
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
[ -f ~/.bash_functions ] && . ~/.bash_functions
export PS1='\[\033[0m\]\[\033[1;36m\]\w\[\033[0m\]\n: \$\u@\h; '

37
init.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# set internal field separator,
# saving old one
OIFS="$IFS"
IFS=$'\n'
MV="mv"
LN="ln"
[[ -d ~/apt_stuff ]] || mkdir ~/apt_stuff
if [[ "$PATH" != *"~/.cyber_bin"* ]]; then
# if script not run yet
PATH="$PATH:~/.cyber_bin"
mkdir ../.cyber_bin
fi
for file in $(ls -A1 .bash_*); do
${MV} "$file" ~
done
for file in $(
ls -1 |
egrep -vi \(init\|license\|readme\|git\)
); do
${LN} "$file" "~/.cyber_bin/$file"
done
[[ ! -f ~/.bashrc ]] && ${LN} ~/.bash_profile ~/.bashrc
# push changes made to PATH
hash -r
source ~/.bash_profile
# reset internal field separator
IFS="$OIFS"

25
rewind.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
HISTFILE="$1"; shift 1
if [[ "$1" == "-f" ]]; then
# lazy getopt
TARGETFUNC="$2"
shift 2
else
TARGETFUNC=
fi
HEADLINES="${1:-1}"
FCLINES=$((HEADLINES + 1))
COMMANDS="$(fc -ln "-${FCLINES}" | head "-${HEADLINES}")"
# echo "$COMMANDS"
if [[ -z "$TARGETFUNC" ]]; then
eval "$COMMANDS"
else
eval "function $TARGETFUNC {
$COMMANDS
}"
fi