summaryrefslogtreecommitdiff
path: root/bash/dot-bash_aliases
blob: bc981cbd7dd50b61aa8843ae4d42e5d3844284d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# vimdiff style with nvim
alias vim='nvim'
alias vi='nvim'
alias nvimdiff='nvim -d'

# ssh as root -> Sysadmin trick
alias r='ssh -l root'

# fuck!
alias fuck='COMMAND=$(history -p \!\!); echo sudo $COMMAND; sudo $COMMAND'

# enable color support of ls and also add handy aliases
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# alias for Node.js projects
alias ntree='tree -I node_modules'
# alias for Clojure projects
alias ctree='tree -I target'
# alias for Zig projects
alias ztree='tree -I zig-cache'

# Clean whiteboards!
# found at: https://gist.github.com/lelandbatey/8677901
function whiteboard {
    convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
}

# Pandoc for ElenQ
alias pandoc-xelatex="pandoc $@ --pdf-engine=xelatex --to latex -N"
alias elenqdoc-article="pandoc-xelatex $@ --standalone --template elenq-article --metadata=documentclass:article --resource-path=~/.pandoc:."
alias elenqdoc-book="pandoc-xelatex $@  --standalone --template elenq-book --metadata=documentclass:book --top-level-division=chapter --resource-path=~/.pandoc:."

# Open using xdg
alias open="xdg-open $@ &>/dev/null"

# Reasonable looking calendar
alias cal="cal -m"
alias _cal="cal"

# Twitch
function twitch {
    mpv "https://twitch.tv/$1"
}

# Clipboard
alias clipboard="xclip -selection clipboard"

# Tilde.team
alias tilde="ssh tilde.team"

# Youtube-dl playlist
alias yt-dlp-playlist="yt-dlp -o '%(playlist_index)s-%(title)s.%(ext)s' $@"

# Email write in vim
alias mail='vim +"set ft=markdown"'

alias yt-album-playlist='yt-dlp --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --parse-metadata "playlist_index:%(track_number)s" --add-metadata --embed-metadata --output "%(playlist_autonumber)02d - %(title)s.%(ext)s" --yes-playlist'

# Easy audio recording
function audio-volume-detect {
    # https://trac.ffmpeg.org/wiki/AudioVolume
    ffmpeg -i "$1" -filter:a volumedetect -f null /dev/null
}
function audio-volume-up-db {
    # https://trac.ffmpeg.org/wiki/AudioVolume
    ffmpeg -i "$1" -filter:a "volume=$3dB" "$2"
}
alias audio_list_sources="pactl list short sources"
function audio-record-from {
    # https://trac.ffmpeg.org/wiki/Capture/PulseAudio
    if ffmpeg -f pulse -i $1 -c:a libvorbis recording.ogg ; then
        echo
        echo Written output file to: recording.ogg
        echo
    fi
}
function audio-encode-vorbis {
    local outfile="${2%.*}".ogg
    if ffmpeg -i "$1" -vn -c:a libvorbis "${outfile}" ; then
        echo
        echo Written output file to: "${outfile}"
        echo
    fi
}

# Wacom mapping
function wacom-map {
    for i in $2; do
        xsetwacom --set "$1 $i" MapToOutput "$3"
    done
}

function wacom-map-intuos {
    local name="Wacom Intuos S Pen"
    local opts="stylus eraser"
    wacom-map "$name" "$opts" "$1"

    local name_pad="Wacom Intuos S Pad"
    local opts_pad="pad"
    wacom-map "$name_pad" "$opts_pad" "$1"
}
function wacom-map-cintiq {
    local name_touch="Wacom Cintiq Pro 16 Touch Finger"
    local opts_touch="touch"
    wacom-map "$name_touch" "$opts_touch" "$1"

    local name="Wacom Cintiq Pro 16 Pen"
    local opts="stylus eraser"
    wacom-map "$name" "$opts" "$1"
}

# Add screen
alias screen-add-right='xrandr --auto --output DP-1 --mode 1920x1080 --right-of eDP-1'
alias screen-add-left='xrandr --auto --output DP-1 --mode 1920x1080 --left-of eDP-1'