summaryrefslogblamecommitdiff
path: root/.aliases
blob: a68442a144517797ef2e5fb91596d9214ef6f782 (plain) (tree)
1
2
3
4
5
6
7
8

         
                
                             

                            
                   
                 



                                              

                            
                                                                                         
                                                                  
                    
                

                 
                                  

                      
                                                                                                           

                  
                                      
                  


                  











                                                             
              



                                                              
                            
                                                                            
                          

                                                                

                                                                          
                                                                                  

                          
                                               

                                                                                     
                                                       

                                                                                                                             
                                                              

                             
                                                   







                                                                                             
                                   





























                                                                                                       











                                                                                                                        
# Aliases

alias cp="cp -i"
alias dd="dd status=progress"
alias define="dict -d gcide"
alias df="df -h"
alias du="du -h -c"
alias e="$EDITOR"
alias ffmpeg="ffmpeg -hide_banner"
alias ffprobe="ffprobe -hide_banner"
alias g="git status -s"
alias gg="git add -A && git commit ; git push"
alias grep="grep --color -i"
alias l="ls"
alias less="less --long-prompt --mouse --quit-if-one-screen --ignore-case --LINE-NUMBERS"
alias lightgtk="GTK2_RC_FILES= GTK_DATA_PREFIX= GTK_THEME=Adwaita"
alias ll="ls -lahGF"
alias ln="ln -v"
alias lr="ls -R"
alias ls="ls -GF"
alias noprompt="PROMPT= RPROMPT= "
alias q="ls|grep"
alias qq="find .|grep"
alias sigil="crispy-doom -iwad ~/games/doom/DOOM.WAD -file ~/games/doom/SIGIL_v1_21/SIGIL_COMPAT_v1_21.wad"
alias doas="doas "
alias sudo="doas "
alias synonym="dict -d moby-thesaurus"
alias tar="tar -v"

# Useful functions

function i3-swallow() {
	i3-msg -q "mark swallowed$$"
	i3-msg -q "[con_mark=\"swallowed$$\"] split toggle"
	i3-msg -q "[con_mark=\"swallowed$$\"] layout tabbed"
}

function i3-unswallow() {
	i3-msg -q "[con_mark=\"swallowed$$\"] layout default"
	i3-msg -q "[con_mark=\"swallowed$$\"] split toggle"
	i3-msg -q "unmark swallowed$$"
}

function o() {
	case "$@" in 
		*.d64|*.prg)
			i3-swallow && x64 "$1" && i3-unswallow
			;;
		*.wad|*.WAD)
			i3-swallow && crispy-doom -iwad "$1" && i3-unswallow
			;;
		*.PDF|*.pdf|*.epub|*.xhtml|*.xps)
			i3-swallow && mupdf "$@" && i3-unswallow
			;;
		*.jpg|*.png|*.bmp|*.gif|*.jpeg|*.JPG|*.JPEG|*.webp|*.tiff)
			i3-swallow && sxiv -a "$(dirname $1)" "$@" && i3-unswallow
			;;
		*.xcf)
			gimp "$@" 2>/dev/null &
			;;
		*.wav|*.mp3|*.flac|*.m4a|*.wma|*.ape|*.ac3|*.og|*.ogagx|*.spx|*.opus)
			mpv --no-video "$@" 2>/dev/null
			;;
		*.avi|*.mp4|*.wmv|*.dat|*.3gp|*.ogv|*.mkv|*.mpg|*.mpeg|*.vob|*.m2v|*.mov|*.webm|*.ts|*.mts|*.m4v|*.qt|*.divx)
			i3-swallow && mpv "$@" && i3-unswallow
			;;
		*.html|*.htm)
			$BROWSER "$@" 2>/dev/null &
			;;
		*.zip|*.jar|*.war|*.7z|*.7zip|*.tar|*.tar.gz|*.tgz|*.tar.xz|*.xz|*.txz|*.iso)
			tar -xvf "$1"
			;;
		*.xls|*.xlsx|*.csv)
			sc-im "$1"
			;;
		*.lcd|*.ldr|*.mpd)
			leocad "$@"
			;;
		*)
			[ -f "$1" ] && less "$1" || echo Unsure what to do...
			;;
	esac
}

theme_add() {
	indir="${1:-~/downloads}"
	[ -d "$indir" ] || exit 

	outdir=~/.local/share/wallpapers
	[ -d "$outdir" ] || mkdir -p "$outdir"

	sxiv -rot "$indir" | while read infile; do
		outfile="$outdir/$(echo ${infile##*/} | tr -s [:blank:] - | tr [:upper:] [:lower:])"
		convert "$infile" -geometry '2560x1440^' -gravity center -crop 2560x1440+0+0 "$outfile"
		wpg -a "$outfile"
	done
}

theme_set() {
	theme="$(sxiv -rot ~/.config/wpg/wallpapers | head -1)"
	[ -f "$theme" ] && wpg -s "$theme"
}

theme_reset() {
	wpg -s "$(wpg -c)"
}

bak() {
	mv -n "$1" "$1".bak
}

rename() {
	# Reads filenames from args, uses vim to generate their new filenames, and then mv's them.
	src="$(mktemp -t rename)"
	dst="$(mktemp -t rename)"
	printf '%s\n' "$@" | tee "$src" > "$dst"
	$EDITOR "$dst"
	diff -s "$src" "$dst" > /dev/null || paste "$src" "$dst" | sed -e "s/\t/' '/" -e "s/^/mv -i '/" -e "s/$/'/" | sh
}