From 5869f1e4d220dd020113deade66ea01790d2023e Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 5 Jun 2023 08:40:16 -0500 Subject: added some git-annex helpers and an offline spellchecker --- .aliases | 12 +++++------- .bashrc | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/.aliases b/.aliases index b4bf5b6..5e6e19d 100644 --- a/.aliases +++ b/.aliases @@ -14,10 +14,10 @@ alias cp='cp -v' alias mv='mv -v' # i like ls alias ls='ls --color -h --group-directories-first' -alias ll='ls -l --group-directories-first ' +alias ll='ls -lh --group-directories-first ' alias lt='ls -lt ' alias lsh='ls -lh' -alias la='ls -lah' +alias la='ls -lah --group-directories-first' alias count='ls -l | wc -l' alias sizes=' du --summarize --human-readable *' @@ -41,19 +41,17 @@ alias mopen='tmux attach-session -t' alias mnew='tmux new -s' #Git aliases +alias g="git " alias gs="git status" -alias ga="git add" alias gc="git commit -S " alias gl="git log" +alias ga="git annex" +alias gaa="git annex add" #apps alias music='ncmpcpp' alias write='countdown $((60*20))' -# rsync/s3cmd aliases -alias syncw="rsync -vv --recursive --delete --checksum -P --ignore-times --exclude-from=/home/lxf/.rsync-exclude-weekly $1 $2" -alias s3pics="s3cmd sync --rr --exclude '*.*' pictures/ s3://lxfpictures" - # rename files etc alias reraw="~/./bin/rename_raw_files.sh" alias regoproraw="~/./bin/rename_gopro_raw.sh" diff --git a/.bashrc b/.bashrc index b53e42b..5e32293 100644 --- a/.bashrc +++ b/.bashrc @@ -625,6 +625,55 @@ yt () { yt-dlp -S height:1080 https://www.youtube.com/watch?v="$1" } +spell() { + local candidates oldifs word array_pos + oldifs="$IFS" + IFS=':' + + # Parse the apsell format and return a list of ":" separated words + read -a candidates <<< "$(printf "%s\n" "$1" \ + | aspell -a \ + | awk -F':' '/^&/ { + split($2, a, ",") + result="" + for (x in a) { + gsub(/^[ \t]/, "", a[x]) + result = a[x] ":" result + } + gsub(/:$/, "", result) + print result + }')" + + # Reverse number and print the parsed bash array because the list comes + # out of gawk backwards + for item in "${candidates[@]}"; do + printf '%s\n' "$item" + done \ + | tac \ + | nl \ + | less -FirSX + + printf "[ $(tput setaf 2)?$(tput sgr0) ]\t%s" \ + 'Enter the choice (empty to cancel, 0 for input): ' + read index + + [[ -z "$index" ]] && return + [[ "$index" == 0 ]] && word="$1" + + [[ -z "$word" ]] && { + array_pos=$(( ${#candidates[@]} - index )) + word="${candidates[$array_pos]}" + } + + [[ -n "$word" ]] && { + printf "$word" | xsel -p + printf "Copied '%s' to clipboard!\n" "$word" + } || printf "[ $(tput setaf 1):($(tput sgr0) ] %s\n" 'No match found' + + + IFS="$oldifs" +} + RIPGREP_CONFIG_PATH=~/.ripgreprc GPG_TTY=$(tty) export GPG_TTY -- cgit v1.2.3-70-g09d2