Giter Club home page Giter Club logo

bash-notes's Introduction

declare -a note_dirs
mapfile -t note_dirs < ~/.notes_file

function init_notes() {
	[[ "${1}" == "" ]] && return -1
	cd ~/notes
	git clone https://github.com/zachleach/bash-notes "${1}"
	pushd "${1}" && ./init
	rm -rf 'README.md' 'init' '.git'
	popd
	echo "${1}" >> ~/.notes_file
}

function notes() {
	dir="" base="$(basename $(pwd))"
	[[ " ${note_dirs[@]} " =~ " ${base} " ]] && dir="${base}"
	[[ " ${note_dirs[@]} " =~ " ${1} " ]] && dir=${1}
	
	week_num=$(date +%U)		# week number [00..53]
	week_num=${week_num#0}		# strip the leading zero for non-octal arithmetic
	((week_num++))				
	week_num=$(printf "%02d" ${week_num})	
	year_num=$(date +%Y)
	cd ~/notes/${dir} && vi +${week_num} ${year_num}.md
}

function note() {
	dir="" base="$(basename $(pwd))"
	[[ " ${note_dirs[@]} " =~ " ${base} " ]] && dir="${base}"
	[[ " ${note_dirs[@]} " =~ " ${1} " ]] && dir=${1}
	week_num=$(date +%U)		# week number [00..53]
	week_num=${week_num#0}		# strip the leading zero for non-octal arithmetic
	((week_num++))				
	week_num=$(printf "%02d" ${week_num})	
	week_str=$(date +%Y)-${week_num}
	day_num=$((($(date +%u) + 1) % 8))
	cd ~/notes/${dir} && vi +${day_num} ${week_str}.md
}

function n() {
	dir="" base="$(basename $(pwd))"
	[[ " ${note_dirs[@]} " =~ " ${base} " ]] && dir="${base}"
	[[ " ${note_dirs[@]} " =~ " ${1} " ]] && dir=${1}

	date=$(date +%Y-%m-%d)
	cd ~/notes/${dir} && vi ${date}.md
}

bash-notes's People

Contributors

zachleach avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.