mirror of
https://github.com/JanJastrow/.dotfiles.git
synced 2024-11-22 10:39:57 +01:00
Update scripts - thx to shellcheck.net
This commit is contained in:
parent
cadc04bb86
commit
53a7185265
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ ! -x `which zsh` ]; then
|
if [ ! -x "$(which zsh)" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -10,10 +10,10 @@ ln -s ~/.dotfiles/tmux/tmux.conf ~/.tmux.conf
|
|||||||
mkdir ~/.dotfiles/this-machine
|
mkdir ~/.dotfiles/this-machine
|
||||||
touch ~/.dotfiles/this-machine/zsh
|
touch ~/.dotfiles/this-machine/zsh
|
||||||
touch ~/.dotfiles/this-machine/tmux.conf
|
touch ~/.dotfiles/this-machine/tmux.conf
|
||||||
sudo chsh -s $(which zsh) $USER
|
sudo chsh -s '$(which zsh)' "$USER"
|
||||||
|
|
||||||
# If private repo is available, add ssh config + hosts
|
# If private repo is available, add ssh config + hosts
|
||||||
if [ -d $HOME/.jan ]; then
|
if [ -d "$HOME/.jan" ]; then
|
||||||
echo "Include ~/.dotfiles/ssh/settings" >> ~/.ssh/config
|
echo "Include ~/.dotfiles/ssh/settings" >> ~/.ssh/config
|
||||||
echo "Include ~/.jan/ssh_hosts" >> ~/.ssh/config
|
echo "Include ~/.jan/ssh_hosts" >> ~/.ssh/config
|
||||||
chmod 600 ~/.ssh/config
|
chmod 600 ~/.ssh/config
|
||||||
|
16
zsh/alias
16
zsh/alias
@ -5,24 +5,24 @@
|
|||||||
# Better LS
|
# Better LS
|
||||||
if [[ $platform == 'Linux' ]]; then
|
if [[ $platform == 'Linux' ]]; then
|
||||||
alias bls='pwd; ls -lahp --color=auto --group-directories-first'
|
alias bls='pwd; ls -lahp --color=auto --group-directories-first'
|
||||||
elif [[ $platform == 'macOS' && -x `which gls` ]]; then
|
elif [[ $platform == 'macOS' && -x $(which gls) ]]; then
|
||||||
alias bls='pwd; gls -lahpG --group-directories-first'
|
alias bls='pwd; gls -lahpG --group-directories-first'
|
||||||
elif [[ $platform == 'macOS' ]]; then
|
elif [[ $platform == 'macOS' ]]; then
|
||||||
alias bls='/bin/ls -lahG'
|
alias bls='/bin/ls -lahG'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Better exa
|
# Better exa
|
||||||
if [[ -x `which exa` ]]; then
|
if [[ -x $(which exa) ]]; then
|
||||||
alias exa='pwd; exa -la --group-directories-first --git -g'
|
alias exa='pwd; exa -la --group-directories-first --git -g'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Better lsd
|
# Better lsd
|
||||||
if [[ -x `which lsd` ]]; then
|
if [[ -x $(which lsd) ]]; then
|
||||||
alias lsd='pwd; lsd -laF --group-dirs=first --icon=never'
|
alias lsd='pwd; lsd -laF --group-dirs=first --icon=never'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update aliases
|
# Update aliases
|
||||||
if [[ -x `which brew` ]]; then
|
if [[ -x $(which brew) ]]; then
|
||||||
alias brewupdate='brew update; brew upgrade; brew upgrade --cask; brew cleanup'
|
alias brewupdate='brew update; brew upgrade; brew upgrade --cask; brew cleanup'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ alias a2='aria2c -x4 -c -m3'
|
|||||||
alias sc='screen -R'
|
alias sc='screen -R'
|
||||||
|
|
||||||
# Only download mp4 version of youtube
|
# Only download mp4 version of youtube
|
||||||
if [[ -x `which yt-dlp` ]]; then
|
if [[ -x $(which yt-dlp) ]]; then
|
||||||
alias ytmp4='yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4"'
|
alias ytmp4='yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4"'
|
||||||
elif [[ -x `which youtube-dl` ]]; then
|
elif [[ -x $(which youtube-dl) ]]; then
|
||||||
alias ytmp4='youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4"'
|
alias ytmp4='youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4"'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -58,13 +58,13 @@ alias rrsync='rsync -avhP'
|
|||||||
alias bcp='rsync -avzuh --progress --partial'
|
alias bcp='rsync -avzuh --progress --partial'
|
||||||
|
|
||||||
# generate pseudo-random hash
|
# generate pseudo-random hash
|
||||||
alias random32="echo $(date +%s | md5sum | head -c 32)"
|
alias random32='echo $(date +%s | md5sum | head -c 32)'
|
||||||
|
|
||||||
# tar
|
# tar
|
||||||
alias untargz='tar -xzvf'
|
alias untargz='tar -xzvf'
|
||||||
|
|
||||||
# (macOS) start Firefox Profile manager
|
# (macOS) start Firefox Profile manager
|
||||||
if test -x "/Applications/Firefox.app/Contents/MacOS/firefox-bin"; then
|
if test -x '/Applications/Firefox.app/Contents/MacOS/firefox-bin'; then
|
||||||
alias firefox-pm='/Applications/Firefox.app/Contents/MacOS/firefox-bin -P'
|
alias firefox-pm='/Applications/Firefox.app/Contents/MacOS/firefox-bin -P'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
2
zsh/env
2
zsh/env
@ -81,7 +81,7 @@ fi
|
|||||||
#
|
#
|
||||||
|
|
||||||
# TheFuck
|
# TheFuck
|
||||||
if [[ -x `which thefuck` ]]; then
|
if [[ -x $(which thefuck) ]]; then
|
||||||
eval "$(thefuck --alias)"
|
eval "$(thefuck --alias)"
|
||||||
# You can use whatever you want as an alias, like for Mondays:
|
# You can use whatever you want as an alias, like for Mondays:
|
||||||
eval "$(thefuck --alias FUCK)"
|
eval "$(thefuck --alias FUCK)"
|
||||||
|
12
zsh/ffmpeg
12
zsh/ffmpeg
@ -6,8 +6,8 @@
|
|||||||
# source: https://yohanes.gultom.me/2016/05/21/bash-script-to-batch-convert-mkv-to-mp4-linux/
|
# source: https://yohanes.gultom.me/2016/05/21/bash-script-to-batch-convert-mkv-to-mp4-linux/
|
||||||
function ff-mp4() {
|
function ff-mp4() {
|
||||||
findpath=$1
|
findpath=$1
|
||||||
: ${findpath:="."}
|
: "${findpath:="."}"
|
||||||
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' \) | while read f ; do
|
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' \) | while read -r f ; do
|
||||||
dir=$(dirname "$f");
|
dir=$(dirname "$f");
|
||||||
file=$(basename "$f");
|
file=$(basename "$f");
|
||||||
# ext="${filename##*.}";
|
# ext="${filename##*.}";
|
||||||
@ -21,8 +21,8 @@ function ff-mp4() {
|
|||||||
# source: https://yohanes.gultom.me/2016/05/21/bash-script-to-batch-convert-mkv-to-mp4-linux/
|
# source: https://yohanes.gultom.me/2016/05/21/bash-script-to-batch-convert-mkv-to-mp4-linux/
|
||||||
function ff-ac3-to-stereo() {
|
function ff-ac3-to-stereo() {
|
||||||
findpath=$1
|
findpath=$1
|
||||||
: ${findpath:="."}
|
: "${findpath:="."}"
|
||||||
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' -o -iname '*.mp4' \) | while read f ; do
|
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' -o -iname '*.mp4' \) | while read -r f ; do
|
||||||
dir=$(dirname "$f");
|
dir=$(dirname "$f");
|
||||||
file=$(basename "$f");
|
file=$(basename "$f");
|
||||||
# ext="${filename##*.}";
|
# ext="${filename##*.}";
|
||||||
@ -50,8 +50,8 @@ function ff-dts() {
|
|||||||
## ffmpeg wma-to-m4a
|
## ffmpeg wma-to-m4a
|
||||||
function ff-wma-m4a() {
|
function ff-wma-m4a() {
|
||||||
findpath=$1
|
findpath=$1
|
||||||
: ${findpath:="."}
|
: "${findpath:="."}"
|
||||||
find "$findpath" -name '*.wma' | while read f ; do
|
find "$findpath" -name '*.wma' | while read -r f ; do
|
||||||
dir=$(dirname "$f");
|
dir=$(dirname "$f");
|
||||||
file=$(basename "$f");
|
file=$(basename "$f");
|
||||||
# ext="${filename##*.}";
|
# ext="${filename##*.}";
|
||||||
|
46
zsh/scripts
46
zsh/scripts
@ -9,13 +9,13 @@ function f() {
|
|||||||
|
|
||||||
# mkdir and cd
|
# mkdir and cd
|
||||||
function mkcd() {
|
function mkcd() {
|
||||||
mkdir -p "$@" && cd "$_";
|
mkdir -p "$@" && cd "$_" || exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# "Fake" sha256sum
|
# "Fake" sha256sum
|
||||||
if [[ ! -x `which sha256sum` ]]; then
|
if [[ ! -x $(which sha256sum) ]]; then
|
||||||
function sha256sum() {
|
function sha256sum() {
|
||||||
shasum -a256 $1
|
shasum -a256 "$1"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ function targz() {
|
|||||||
echo "usage: targz filename.tar.gz directory"
|
echo "usage: targz filename.tar.gz directory"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ ! -x `which pigz` ]]; then
|
if [[ ! -x $(which pigz) ]]; then
|
||||||
tar -czf $1 $2
|
tar -czf "$1" "$2"
|
||||||
echo "gzip"
|
echo "gzip"
|
||||||
else
|
else
|
||||||
tar -c $2 | pigz > $1
|
tar -c "$2" | pigz > "$1"
|
||||||
echo "pigz"
|
echo "pigz"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -47,8 +47,8 @@ function pushover() {
|
|||||||
# png to jpg 85
|
# png to jpg 85
|
||||||
function png2web() {
|
function png2web() {
|
||||||
findpath=$1
|
findpath=$1
|
||||||
: ${findpath:="."}
|
: "${findpath:="."}"
|
||||||
find "$findpath" -name '*.png' | while read f ; do
|
find "$findpath" -name '*.png' | while read -r f ; do
|
||||||
dir=$(dirname "$f");
|
dir=$(dirname "$f");
|
||||||
file=$(basename "$f");
|
file=$(basename "$f");
|
||||||
name="${file%.*}";
|
name="${file%.*}";
|
||||||
@ -58,7 +58,7 @@ function png2web() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function jpeg1024() {
|
function jpeg1024() {
|
||||||
magick "$1" -resize '1024x1024\>' -background black -flatten TGA:- | cjpeg -targo -quality 75 -optimize -progressive -outfile $1.jpg
|
magick "$1" -resize '1024x1024\>' -background black -flatten TGA:- | cjpeg -targo -quality 75 -optimize -progressive -outfile "$1".jpg
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make PDFs look like scanned
|
# Make PDFs look like scanned
|
||||||
@ -73,21 +73,21 @@ function pdf-like-scanned () {
|
|||||||
# Extract files
|
# Extract files
|
||||||
# src: https://github.com/mawalu/dotfiles/blob/master/zsh/.zsh/functions.zsh#L21
|
# src: https://github.com/mawalu/dotfiles/blob/master/zsh/.zsh/functions.zsh#L21
|
||||||
function extract () {
|
function extract () {
|
||||||
if [ -f $1 ] ; then
|
if [ -f "$1" ] ; then
|
||||||
case $1 in
|
case $1 in
|
||||||
*.tar.bz2) tar xjf $1 ;;
|
*.tar.bz2) tar xjf "$1" ;;
|
||||||
*.tar.gz) tar xzf $1 ;;
|
*.tar.gz) tar xzf "$1" ;;
|
||||||
*.bz2) bunzip2 $1 ;;
|
*.bz2) bunzip2 "$1" ;;
|
||||||
*.rar) unrar x $1 ;;
|
*.rar) unrar x "$1" ;;
|
||||||
*.gz) gunzip $1 ;;
|
*.gz) gunzip "$1" ;;
|
||||||
*.tar) tar xf $1 ;;
|
*.tar) tar xf "$1" ;;
|
||||||
*.tbz2) tar xjf $1 ;;
|
*.tbz2) tar xjf "$1" ;;
|
||||||
*.tbz) tar xjf $1 ;;
|
*.tbz) tar xjf "$1" ;;
|
||||||
*.tgz) tar xzf $1 ;;
|
*.tgz) tar xzf "$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 ex()" ;;
|
*) 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"
|
||||||
|
18
zshrc
18
zshrc
@ -10,7 +10,7 @@ prompt_color1="#ffaf00"
|
|||||||
prompt_color2="#000000"
|
prompt_color2="#000000"
|
||||||
|
|
||||||
# Load zsh settings
|
# Load zsh settings
|
||||||
source $HOME/.dotfiles/zsh/settings
|
source "$HOME/.dotfiles/zsh/settings"
|
||||||
|
|
||||||
# Define platform
|
# Define platform
|
||||||
platform='Unknown'
|
platform='Unknown'
|
||||||
@ -41,12 +41,12 @@ elif test -f "/usr/local/bin/brew"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Load additional settings
|
# Load additional settings
|
||||||
source $HOME/.dotfiles/zsh/env
|
source "$HOME/.dotfiles/zsh/env"
|
||||||
source $HOME/.dotfiles/zsh/alias
|
source "$HOME/.dotfiles/zsh/alias"
|
||||||
source $HOME/.dotfiles/zsh/bindings
|
source "$HOME/.dotfiles/zsh/bindings"
|
||||||
source $HOME/.dotfiles/zsh/scripts
|
source "$HOME/.dotfiles/zsh/scripts"
|
||||||
source $HOME/.dotfiles/zsh/ffmpeg
|
source "$HOME/.dotfiles/zsh/ffmpeg"
|
||||||
source $HOME/.dotfiles/this-machine/zsh
|
source "$HOME/.dotfiles/this-machine/zsh"
|
||||||
|
|
||||||
# Prompt design
|
# Prompt design
|
||||||
prompt="%F{$prompt_color2}%K{$prompt_color1} ▓▒░%F%B%n@%m%b%F{$prompt_color1}%K{$prompt_color2}█▓▒░%F{#ffffff}%K{$prompt_color2}%B %D{%Y-%m-%d} %D{%k:%M:%S}
|
prompt="%F{$prompt_color2}%K{$prompt_color1} ▓▒░%F%B%n@%m%b%F{$prompt_color1}%K{$prompt_color2}█▓▒░%F{#ffffff}%K{$prompt_color2}%B %D{%Y-%m-%d} %D{%k:%M:%S}
|
||||||
@ -54,6 +54,6 @@ prompt="%F{$prompt_color2}%K{$prompt_color1} ▓▒░%F%B%n@%m%b%F{$prompt_colo
|
|||||||
|
|
||||||
# Load private information from second repo
|
# Load private information from second repo
|
||||||
if [[ -d $HOME/.jan ]]; then
|
if [[ -d $HOME/.jan ]]; then
|
||||||
source $HOME/.jan/credentials
|
source "$HOME/.jan/credentials"
|
||||||
source $HOME/.jan/zsh_options
|
source "$HOME/.jan/zsh_options"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user