Published in: Other
# mkmv - creates a new directory and moves the file into it, in 1 step # Usage: mkmv <file> <directory> mkmv() { mkdir "$2" mv "$1" "$2" } # sanitize - set file/directory owner and permissions to normal values (644/755) # Usage: sanitize <file> sanitize() { chmod -R u=rwX,go=rX "$@" chown -R ${USER}.users "$@" } # nh - run command detached from terminal and without output # Usage: nh <command> nh() { nohup "$@" &>/dev/null & } # run - compile a simple c or cpp file, run the program, afterwards delete it # Usage: run <file> [params] run() { filename="${1%%.*}" extension="${1##*.}" file="$1" shift params="$@" command="" if [ $extension = "cc" -o $extension = "cpp" -o $extension = "c++" ]; then command="g++" elif [ $extension = "c" ]; then command="gcc" else echo "Invalid file extension!" return 1 fi $command -Wall -o $filename $file chmod a+x $filename ./$filename $params rm -f $filename 2>/dev/null }
You need to login to post a comment.
