aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.bashrc_text
blob: 3f5c4fd6b7d779319be66c78271b33c417f963a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

alias dos2eol='sed --binary --in-place '"'"'s/\(\r\?\)$//'"'"
alias eol2dos='sed --binary --in-place '"'"'s/\r\?$/\r/'"'"

alias trim='sed --binary --in-place '"'"'s/[[:blank:]]*\(\r\?\)$/\1/'"'"

alias trimeol='sed --binary --in-place -e :a -e '"'"'/^\n*$/{$d;N;ba}'"'"
alias trimdoseol='sed --binary --in-place -e :a -e '"'"'/^\(\r\n\)*\r$/{$d;N;ba}'"'"

alias eol='sed --binary --in-place '"'"'$a\'"'"
alias doseol='sed --binary --in-place '"'"'$s/\r\?$/\r/;a\'"'"

alias trimbom='sed --binary --in-place '"'"'1 s/^\xef\xbb\xbf//'"'"

lint() {
    trim "$@" && trimeol "$@" && eol "$@"
}

doslint() {
    trim "$@" && trimdoseol "$@" && doseol "$@"
}