mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-22 03:21:30 +01:00
fix some miscellanous issues
This commit is contained in:
parent
194ab3b920
commit
0860036eff
|
@ -82,5 +82,5 @@ fi
|
||||||
# dotfiles user aliases
|
# dotfiles user aliases
|
||||||
if [[ -f ~/.dotfiles_aliases ]];
|
if [[ -f ~/.dotfiles_aliases ]];
|
||||||
then
|
then
|
||||||
source ~/.dotfiles_aliases
|
source $HOME/.dotfiles_aliases
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -58,12 +58,12 @@ if [[ $SSH_CLIENT ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
alias esource="$EDITOR $HOME/.zshrc"
|
alias esource='$EDITOR $HOME/.zshrc'
|
||||||
alias resource="source $HOME/.zshrc"
|
alias resource='source $HOME/.zshrc'
|
||||||
alias dotedit="$EDITOR $DOTFILES/brethil_dotfile.sh"
|
alias dotedit='$EDITOR $DOTFILES/brethil_dotfile.sh'
|
||||||
# Custom definitions files
|
# Custom definitions files
|
||||||
alias funedit="$EDITOR ~/.dotfiles_functions.sh"
|
alias funedit='$EDITOR ~/.dotfiles_functions.sh'
|
||||||
alias aledit="$EDITOR ~/.dotfiles_aliases.sh"
|
alias aledit='$EDITOR ~/.dotfiles_aliases.sh'
|
||||||
|
|
||||||
# Extras
|
# Extras
|
||||||
functions_file=$DOTFILES/functions.sh # Function definitions
|
functions_file=$DOTFILES/functions.sh # Function definitions
|
||||||
|
|
60
functions.sh
60
functions.sh
|
@ -21,7 +21,7 @@ function cheatall
|
||||||
# List all docker tags for an image
|
# List all docker tags for an image
|
||||||
function dockertags
|
function dockertags
|
||||||
{
|
{
|
||||||
if [[ -z `which jq` ]]; then
|
if [[ -z $(command -v jq) ]]; then
|
||||||
echo "jq not installed. Please install jq." 1>&2
|
echo "jq not installed. Please install jq." 1>&2
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -35,28 +35,30 @@ function dockertags
|
||||||
## Simple calculator. Usage: calc 1+1, calc 5/7, calc "sqrt(2)"
|
## Simple calculator. Usage: calc 1+1, calc 5/7, calc "sqrt(2)"
|
||||||
function calc
|
function calc
|
||||||
{
|
{
|
||||||
awk "BEGIN { print "$*" }"
|
awk "BEGIN { print $* }"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Make new directory and cd to that directory. Usage: mcd newfolder
|
## Make new directory and cd to that directory. Usage: mcd newfolder
|
||||||
function mcd
|
function mcd
|
||||||
{
|
{
|
||||||
mkdir -p $1
|
mkdir -p "$1"
|
||||||
cd $1
|
cd $1
|
||||||
}
|
}
|
||||||
|
|
||||||
## Print full path of item in current directory
|
## Print full path of item in current directory
|
||||||
function ppath
|
function ppath
|
||||||
{
|
{
|
||||||
echo $PWD/"$1"
|
echo "$PWD/$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Color string with given color. Usage: color colorname "string", available colors in colors.sh
|
## Color string with given color. Usage: color $colorname "string", available colors in colors.sh
|
||||||
function color
|
function color
|
||||||
{
|
{
|
||||||
color=$1
|
color=$1
|
||||||
|
set -x
|
||||||
shift 1
|
shift 1
|
||||||
printf "$color$@$CLEAR"
|
echo -e "$"$color"$@${CLEAR}\n"
|
||||||
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,17 +102,19 @@ function pmusic
|
||||||
## Simple http server for current directory (or path)
|
## Simple http server for current directory (or path)
|
||||||
function httpserver
|
function httpserver
|
||||||
{
|
{
|
||||||
cwd="$pwd"
|
(
|
||||||
if [[ -e $1 ]];
|
if [[ -d $1 ]]; then
|
||||||
then
|
cd "$1" && echo "Starting webserver in $(realpath $1)/" || echo "directory: $1 does not exist" >&2 || exit 1
|
||||||
dir="$1"
|
else
|
||||||
else
|
echo "Starting webserver in $PWD/"
|
||||||
dir="$pwd"
|
fi
|
||||||
fi
|
open "http://localhost:8000" &>/dev/null &
|
||||||
cd "$dir"
|
if [[ $(python --version) == "Python 3"* ]]; then
|
||||||
sleep 0.1 && open "http://localhost:8000" &>/dev/null &
|
python -m http.server 8000
|
||||||
python -m SimpleHTTPServer
|
else
|
||||||
|
python -m SimpleHTTPServer
|
||||||
|
fi
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,7 +173,7 @@ fi
|
||||||
## List defined functions in $DOTFILES/functions.sh
|
## List defined functions in $DOTFILES/functions.sh
|
||||||
function list_functions
|
function list_functions
|
||||||
{
|
{
|
||||||
cat $DOTFILES/functions.sh | grep --color=no -A 1 '^##' | sed -E 's/function (.*)/\1/g'
|
grep --color=no -A 1 '^##' $DOTFILES/functions.sh | sed -E 's/function (.*)/\1/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,9 +198,9 @@ function ramdisk
|
||||||
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
||||||
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
||||||
mydev=$(echo "$mydev"| xargs echo)
|
mydev=$(echo "$mydev"| xargs echo)
|
||||||
newfs_hfs $mydev
|
newfs_hfs "$mydev"
|
||||||
mkdir -p "/tmp/$name"
|
mkdir -p "/tmp/$name"
|
||||||
mount -t hfs $mydev "/tmp/$name"
|
mount -t hfs "$mydev" "/tmp/$name"
|
||||||
echo "RAM Disk mounted: /tmp/$name"
|
echo "RAM Disk mounted: /tmp/$name"
|
||||||
echo "To eject (destroy) RAM disk, use:"
|
echo "To eject (destroy) RAM disk, use:"
|
||||||
echo " $ diskutil eject $mydev"
|
echo " $ diskutil eject $mydev"
|
||||||
|
@ -212,18 +216,14 @@ function man2pdf
|
||||||
function nman
|
function nman
|
||||||
{
|
{
|
||||||
if [ $# -eq 1 ] ; then
|
if [ $# -eq 1 ] ; then
|
||||||
open x-man-page://$1 ;
|
open "x-man-page://$1"
|
||||||
elif [ $# -eq 2 ] ; then
|
elif [ $# -eq 2 ] ; then
|
||||||
open x-man-page://$1/$2 ;
|
open "x-man-page://$1/$2"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
fi # end of mac-specific functions
|
fi
|
||||||
|
|
||||||
# Force update git repo from origin/master
|
### end of mac-specific functions
|
||||||
function gitupdate(){
|
|
||||||
git fetch --all
|
|
||||||
git reset --hard origin/master
|
|
||||||
}
|
|
||||||
|
|
||||||
function pipupdate(){
|
function pipupdate(){
|
||||||
for pip in pip2 pip3; do
|
for pip in pip2 pip3; do
|
||||||
|
@ -235,6 +235,6 @@ function pipupdate(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# dotfiles user functions
|
# dotfiles user functions
|
||||||
if [[ -f ~/.dotfiles_functions ]]; then
|
if [[ -f $HOME/.dotfiles_functions ]]; then
|
||||||
source ~/.dotfiles_functions
|
source "$HOME/.dotfiles_functions"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user