Skip to content

Commit

Permalink
woman, deer, awk
Browse files Browse the repository at this point in the history
  • Loading branch information
neeasade committed Jul 1, 2018
1 parent 7c0775a commit ada2305
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ insert_final_newline = true
[*.sh] [*.sh]
indent_size = 2 indent_size = 2
indent_style = space indent_style = space

[shell/.sh.d/*]
indent_size = 2
indent_style = space
2 changes: 1 addition & 1 deletion bin/bin/mpv
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# always run mpv w/ socket # always run mpv w/ socket


mpv="$(type -a mpv | tail -n 1 | sed 's/.* //')" mpv="$(type -a mpv | awk 'END{print $3}')"


# todo: account for multiple instances here # todo: account for multiple instances here
mpc pause >/dev/null mpc pause >/dev/null
Expand Down
82 changes: 45 additions & 37 deletions shell/.sh.d/functions
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- mode: sh -*- # -*- mode: sh -*-


ranger() {
$ESHELL && elisp '(deer)' || env ranger
}

sysinfo() { sysinfo() {
clear clear
ufetch ufetch
Expand Down Expand Up @@ -90,7 +94,7 @@ gitupdate() {
# Change to root of git repo # Change to root of git repo
groot() { groot() {
if git status &> /dev/null; then if git status &> /dev/null; then
cd $(git rev-parse --show-toplevel) cd $(git rev-parse --show-toplevel)
else else
echo "Error: Not a git repository" echo "Error: Not a git repository"
return 128 return 128
Expand All @@ -107,18 +111,18 @@ note() {
nq() { nq() {
local CACHE="$HOME/.cache/nq-cache" local CACHE="$HOME/.cache/nq-cache"
if ! ( [ -e $CACHE ] && [ $(stat -c %Y $CACHE) -gt $(( $(date +%s) - 3600 )) ] ); then if ! ( [ -e $CACHE ] && [ $(stat -c %Y $CACHE) -gt $(( $(date +%s) - 3600 )) ] ); then
echo "update cache" && nix-env -qa --json > "$CACHE" echo "update cache" && nix-env -qa --json > "$CACHE"
fi fi
jq -r 'to_entries | .[] | .key + "|" + .value.meta.description' < "$CACHE" | jq -r 'to_entries | .[] | .key + "|" + .value.meta.description' < "$CACHE" |
{ {
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
# double grep because coloring breaks column's char count # double grep because coloring breaks column's char count
# $* so that we include spaces (could do .* instead?) # $* so that we include spaces (could do .* instead?)
grep -i "$*" | column -t -s "|" | grep -i "$*" grep -i "$*" | column -t -s "|" | grep -i "$*"
else else
column -t -s "|" column -t -s "|"
fi fi
} }
} }


dec2hex() { dec2hex() {
Expand All @@ -131,39 +135,43 @@ hex2dec() {


extract() { # Handy Extract Program extract() { # Handy Extract Program
if [ -f $1 ] ; then if [ -f $1 ] ; then
case $1 in case $1 in
*.tar.bz2) tar xvjf $1 ;; *.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;; *.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;; *.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;; *.rar) unrar x $1 ;;
*.gz) gunzip $1 ;; *.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;; *.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;; *.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;; *.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;; *.zip) unzip $1 ;;
*.Z) uncompress $1 ;; *.Z) uncompress $1 ;;
*.7z) 7z x $1 ;; *.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;; *) echo "'$1' cannot be extracted via >extract<" ;;
esac esac
else else
echo "'$1' is not a valid file!" echo "'$1' is not a valid file!"
fi fi
} }


# manpages with colors # manpages with colors
man() { man() {
settitle "$* - manual" if $ESHELL; then
# removing standout means find highlights stay inverted.. elisp "(woman \"$*\")"
#LESS_TERMCAP_so=$(printf '\e[38;5;246m') \ else

settitle "$* - manual"
env LESS_TERMCAP_mb=$(printf '\e[01;31m') \ # removing standout means find highlights stay inverted..
LESS_TERMCAP_md=$(printf '\e[01;38;5;74m') \ #LESS_TERMCAP_so=$(printf '\e[38;5;246m') \
LESS_TERMCAP_me=$(printf '\e[0m') \
LESS_TERMCAP_se=$(printf '\e[0m') \ env LESS_TERMCAP_mb=$(printf '\e[01;31m') \
LESS_TERMCAP_ue=$(printf '\e[0m') \ LESS_TERMCAP_md=$(printf '\e[01;38;5;74m') \
LESS_TERMCAP_us=$(printf '\e[04;38;5;146m') \ LESS_TERMCAP_me=$(printf '\e[0m') \
man "$@" LESS_TERMCAP_se=$(printf '\e[0m') \
defaulttitle LESS_TERMCAP_ue=$(printf '\e[0m') \
LESS_TERMCAP_us=$(printf '\e[04;38;5;146m') \
man "$@"
defaulttitle
fi
} }


page() { page() {
Expand Down
4 changes: 2 additions & 2 deletions wm/.wm/panel/lemons/mpd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ else
title="Stopped" title="Stopped"
fi fi


icon music

if [ "$title" = "Stopped" ]; then if [ "$title" = "Stopped" ]; then
icon music
echo Stopped echo Stopped
else else
icon music
$playing && icon pause $playing && icon pause
$paused && icon play $paused && icon play
echo "$title" | cut -c 1-$maxWinNameLen echo "$title" | cut -c 1-$maxWinNameLen
Expand Down

0 comments on commit ada2305

Please sign in to comment.