Merge branch 'master' of git.blakenorth.net/home/git/dotfiles

This commit is contained in:
PowerUser64 2022-04-13 17:04:27 -07:00
commit ed35809110
6 changed files with 41 additions and 21 deletions

View file

@ -104,7 +104,7 @@ vim.cmd 'let g:markdown_fenced_languages = [ "bash=sh", "javascript", "cpp=cpp",
--- autocmd's --- --- autocmd's ---
-- Set comment strings -- Set comment strings
vim.cmd 'autocmd FileType crontab set commentstring=#\\ %s' vim.cmd 'autocmd FileType crontab set commentstring=#%s'
-- vim.cmd 'autocmd FileType rmd set commentstring=<!--\\ %s\\ -->' -- vim.cmd 'autocmd FileType rmd set commentstring=<!--\\ %s\\ -->'
-- Automatically jump to the last position in a file when opening -- Automatically jump to the last position in a file when opening

View file

@ -12,7 +12,8 @@
BASE_DIR="${NOTES_DIR:-"$HOME/Documents/college/current"}" BASE_DIR="${NOTES_DIR:-"$HOME/Documents/college/current"}"
EDITOR="nvim" EDITOR="nvim"
EDITOR_CMD="nvim -c :ZenMode" EDITOR_CMD="nvim -c :ZenMode"
DEFAULT_NEW_NOTE_NAME="$(date +'%m-%d').md" DEFAULT_NEW_NOTE_EXT=.md
DEFAULT_NEW_NOTE_NAME="$(date +'%m-%d')$DEFAULT_NEW_NOTE_EXT"
# Some fzf commands # Some fzf commands
FZF="fzf -1 --layout=reverse --info=inline --height=10%" FZF="fzf -1 --layout=reverse --info=inline --height=10%"
@ -26,9 +27,10 @@ usage() {
[edit|ed] [folder] <note name> Search for and edit a text document in a folder [edit|ed] [folder] <note name> Search for and edit a text document in a folder
ned Edit ned ned Edit ned
help Print this message help Print this message
cd [folder] Open a shell in a directory or the default directory
Notes: Notes:
Edit 'T' to get today's note Edit 'T' to get today's note
Folder and file names are searched with fuzzy search Folder and file names are searched with fuzzy search
ned will automatically activate the ZenMode neovim extension ned will automatically activate the ZenMode neovim extension
Current repository path: '$BASE_DIR' Current repository path: '$BASE_DIR'
@ -69,13 +71,15 @@ new() {
# Note name # Note name
if [ -n "$3" ]; then if [ -n "$3" ]; then
NEW_NOTE_NAME="$3.md" NEW_NOTE_NAME="$3"
else else
NEW_NOTE_NAME="$DEFAULT_NEW_NOTE_NAME" NEW_NOTE_NAME="$DEFAULT_NEW_NOTE_NAME"
fi fi
# Note dir # Note dir
NEW_NOTE_DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 | sed 's-\./--g' | $FZF_SEARCH "$2")" || exit NEW_NOTE_DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 | sed 's-\./--g' | $FZF_SEARCH "$2")/notes" || exit
[ -d "${NEW_NOTE_DIR%/*}" ] || mkdir "${NEW_NOTE_DIR%/*}"
if [ -f "$NEW_NOTE_DIR/$NEW_NOTE_NAME" ]; then if [ -f "$NEW_NOTE_DIR/$NEW_NOTE_NAME" ]; then
open_file "$NEW_NOTE_DIR/$NEW_NOTE_NAME" open_file "$NEW_NOTE_DIR/$NEW_NOTE_NAME"
@ -83,7 +87,7 @@ new() {
cd "$NEW_NOTE_DIR" || exit cd "$NEW_NOTE_DIR" || exit
# apply a template for notes # apply a template for notes
cat <<-EOF >> "$NEW_NOTE_DIR/$NEW_NOTE_NAME" cat <<-EOF >> "$NEW_NOTE_DIR/$NEW_NOTE_NAME"
# $NEW_NOTE_NAME # ${NEW_NOTE_NAME%%"$DEFAULT_NEW_NOTE_EXT"}
<!-- vim: wrap nonu nornu <!-- vim: wrap nonu nornu
--> -->
@ -104,10 +108,14 @@ subshell() {
} }
shell() { shell() {
if [ -n "${1+foo}" ]; then if [ -n "${2+foo}" ]; then
DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 -t d | sed 's-\./--g' | $FZF_SEARCH "$1")" || exit DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 -t d | sed 's-\./--g' | $FZF_SEARCH "$2")" || exit
fi
if cd "$DIR"; then
subshell
else
exit
fi fi
cd "$DIR" || exit
} }
check_setup() { check_setup() {

View file

@ -7,11 +7,16 @@
usage() { usage() {
cat <<-EOF cat <<-EOF
Usage: Usage:
$0 [output_type] [input_files] $0 [output_type] [pandoc_args for file 1] [pandoc_args for file 1] [input_files]
Examples: Examples:
$0 pdf *.md $0 pdf *.md
$0 .docx *.md # leading .'s are automatically removed from the output name $0 .docx *.md # leading .'s are automatically removed from the output format
Note:
To put a file in pandoc arguments without having it be compiled to its own document, put a './' at the start of the path to it
You can have as many arg/file combinations you want
The argument array is cleared between input files
EOF EOF
} }
@ -27,13 +32,17 @@ if [[ -z "$2" ]]; then
echo "error: no files specified" echo "error: no files specified"
usage && exit 1 usage && exit 1
fi fi
FORMAT="$1"
SKIP_FIRST=true OUTPUT_FORMAT="$1"
SKIP_FIRST=true # don't process the first argument, it is the output format
for FILE in "$@";do for FILE in "$@";do
$SKIP_FIRST && SKIP_FIRST=false && continue $SKIP_FIRST && SKIP_FIRST=false && continue
if [[ -f "$FILE" ]]; then if [[ -f "$FILE" ]] && [[ "${FILE:0:2}" != "./" ]]; then
pandoc -s "$FILE" -o "${FILE%.*}.${FORMAT##.}" pandoc -s "$FILE" "${PANDOC_ARGS[@]}" -o "${FILE%.*}.${OUTPUT_FORMAT##.}"
PANDOC_ARGS=()
else
PANDOC_ARGS+=("$FILE")
fi fi
done done

View file

@ -71,5 +71,6 @@ export P10K_CONFIG_LOCATION="${P10K_CONFIG_LOCATION:-"$SHELL_CONFIG_DIR/p10k/cur
########################################### ###########################################
S="$SHELL_CONFIG_DIR" S="$SHELL_CONFIG_DIR"
DD="$DOCS_DIR" DD="$DOCS_DIR"
C=~/code/spu/ds2/src
# vim:fdm=marker:fmr=>>>,<<<:et:ft=sh:sw=3:ts=3 # vim:fdm=marker:fmr=>>>,<<<:et:ft=sh:sw=3:ts=3

View file

@ -1,15 +1,15 @@
#!/bin/sh #!/bin/sh
# shellcheck disable=SC2155 # shellcheck disable=SC2155
export PROFILE_LOADED=false export SHELL_CONFIG_DIR="${SHELL_CONFIG_DIR:-"${XDG_CONFIG_HOME:-"$HOME/.config"}/shell"}"
. "$SHELL_CONFIG_DIR/env"
# set PATH so it includes user's private bin if it exists # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH" PATH="$HOME/.local/bin:$PATH"
fi fi
export SHELL_CONFIG_DIR="${SHELL_CONFIG_DIR:-"${XDG_CONFIG_HOME:-"$HOME/.config"}/shell"}"
# Locales # Locales
export LC_ALL=en_US.UTF-8 export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8 export LANG=en_US.UTF-8
@ -50,6 +50,8 @@ export VDPAU_DRIVER=va_gl # Fix steam remote play black screen
# shellcheck disable=SC2046 # shellcheck disable=SC2046
export $(dbus-launch) export $(dbus-launch)
# If running in a TTY… # If running in a TTY…
if [ "$(tty | sed 's-[0-9]$--g')" = /dev/tty ]; then if [ "$(tty | sed 's-[0-9]$--g')" = /dev/tty ]; then
export IS_TTY=true export IS_TTY=true

View file

@ -2,7 +2,7 @@
# this script will install the dotfiles from the target git repository, and back up any conflicting files # this script will install the dotfiles from the target git repository, and back up any conflicting files
# credit for this idea and basic script outline goes to https://www.atlassian.com/git/tutorials/dotfiles # credit for this idea and basic script outline goes to https://www.atlassian.com/git/tutorials/dotfiles
# TODO: make it so like 31 (DOTFILES_BACKUP_LIST) can handle spaces # TODO: make it so line 31 (DOTFILES_BACKUP_LIST) can handle spaces (do it in a for loop)
DOTFILES_REPO_DIR="$HOME/git/dotfiles" DOTFILES_REPO_DIR="$HOME/git/dotfiles"
DOTFILES_REPO_URL="https://git.blakenorth.net/dotfiles" DOTFILES_REPO_URL="https://git.blakenorth.net/dotfiles"
@ -31,7 +31,7 @@ else
DOTFILES_BACKUP_LIST=($(dot checkout 2>&1 | grep -Po "(?<=\t)(.*)$")) DOTFILES_BACKUP_LIST=($(dot checkout 2>&1 | grep -Po "(?<=\t)(.*)$"))
# create directories for everything that needs one # create directories for everything that needs one
mkdir -p "$DOTFILES_BACKUP_DIR" $(printf '%s\n' "${DOTFILES_BACKUP_LIST[@]}" | grep -Po '.*/' | sed "s#.*#$DOTFILES_BACKUP_DIR/&#g") mkdir -p "$DOTFILES_BACKUP_DIR" $(printf '%s\n' "${DOTFILES_BACKUP_LIST[@]}" | grep -Po '.*/' | sed "s#.*#$DOTFILES_BACKUP_DIR/&#g")
# backup the files to avoid them being overwritten # backup existing files to avoid them being overwritten
printf '%s\n' "${DOTFILES_BACKUP_LIST[@]}" | xargs -I{} mv "$HOME"/{} "$DOTFILES_BACKUP_DIR"/{} printf '%s\n' "${DOTFILES_BACKUP_LIST[@]}" | xargs -I{} mv "$HOME"/{} "$DOTFILES_BACKUP_DIR"/{}
fi fi