Skip to content

Commit

Permalink
add rcat and flatten functions, add check_question_mark_in_filename, …
Browse files Browse the repository at this point in the history
…comment obsidian vim plugins
  • Loading branch information
MaxWolf-01 committed May 20, 2024
1 parent b910b83 commit 4ed3c34
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
19 changes: 19 additions & 0 deletions git/hooks/check_question_mark_in_filename
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# pre-commit hook to prevent files with question marks from being committed (Android compatibility)

files_to_commit=$(git diff --cached --name-only)

found=false
for file in $files_to_commit; do
if [[ "$file" == *"?"* ]]; then
echo "Error: File '$file' contains a question mark and cannot be committed."
found=true
fi
done

if [ "$found" = true ]; then
exit 1
fi

exit 0
1 change: 1 addition & 0 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ obsidian_vault() {
git clone git@github.com:MaxWolf-01/knowledge-base.git
cd knowledge-base && git clone git@github.com:MaxWolf-01/.obsidian-pc.git && mv .obsidian-pc .obsidian || exit
ln -sf ~/.dotfiles/vim/obsidian ~/repos/obsidian/knowledge-base/.obsidian.vimrc
ln -sf ~/.dotfiles/git/hooks/check_question_mark_in_filename ~/repos/obsidian/knowledge-base/.git/hooks/pre-commit
}

obsidian() {
Expand Down
8 changes: 3 additions & 5 deletions vim/obsidian
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ noremap L }
" Yank to system clipboard
set clipboard=unnamed

call plug#begin('~/.vim/plugged')

"call plug#begin('~/.vim/plugged')
" TODO change Ctrl+n to alt+j https://www.reddit.com/r/neovim/comments/17dcy9i/plugin_or_command_for_simultaneous_nonadjacent/
Plug 'mg979/vim-visual-multi', {'branch': 'master'}

call plug#end()
"Plug 'mg979/vim-visual-multi', {'branch': 'master'}
"call plug#end()
21 changes: 19 additions & 2 deletions zsh/functions
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,25 @@ function restic_lsfs() {
restic ls --json latest | jq -r 'select(.type == "file") | [.path, .size] | @tsv' | sort -k2 -n -r | head -n "$n" | awk -F'\t' '{printf "%s\t%.2f MB\n", $1, $2/1048576}'
}

# put the content of a file into the clipboard
# put the content of a file into the clipboard, or read from stdin if no file is provided
clip() {
xclip -selection clipboard < "$1"
if [ -z "$1" ]; then
xclip -selection clipboard
else
xclip -selection clipboard < "$1"
fi
}


# recursively cat the content of a directory (default current)
function rcat() {
local dir=${1:-.}
find "$dir" -type f -exec cat {} \;
}

# recursively flatten a directory structure (defalt current dir), skip files with the same name
function flatten() {
local dir=${1:-.}
find "$dir" -mindepth 2 -type f -exec mv -n -t "$dir" {} +
}

0 comments on commit 4ed3c34

Please sign in to comment.