mirror of
https://github.com/JanJastrow/.dotfiles.git
synced 2024-10-07 23:15:51 +02:00
Update scripts - thx to shellcheck.net
This commit is contained in:
parent
cadc04bb86
commit
53a7185265
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -x `which zsh` ]; then
|
||||
if [ ! -x "$(which zsh)" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
@ -10,10 +10,10 @@ ln -s ~/.dotfiles/tmux/tmux.conf ~/.tmux.conf
|
||||
mkdir ~/.dotfiles/this-machine
|
||||
touch ~/.dotfiles/this-machine/zsh
|
||||
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 [ -d $HOME/.jan ]; then
|
||||
if [ -d "$HOME/.jan" ]; then
|
||||
echo "Include ~/.dotfiles/ssh/settings" >> ~/.ssh/config
|
||||
echo "Include ~/.jan/ssh_hosts" >> ~/.ssh/config
|
||||
chmod 600 ~/.ssh/config
|
||||
|
16
zsh/alias
16
zsh/alias
@ -5,24 +5,24 @@
|
||||
# Better LS
|
||||
if [[ $platform == 'Linux' ]]; then
|
||||
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'
|
||||
elif [[ $platform == 'macOS' ]]; then
|
||||
alias bls='/bin/ls -lahG'
|
||||
fi
|
||||
|
||||
# Better exa
|
||||
if [[ -x `which exa` ]]; then
|
||||
if [[ -x $(which exa) ]]; then
|
||||
alias exa='pwd; exa -la --group-directories-first --git -g'
|
||||
fi
|
||||
|
||||
# Better lsd
|
||||
if [[ -x `which lsd` ]]; then
|
||||
if [[ -x $(which lsd) ]]; then
|
||||
alias lsd='pwd; lsd -laF --group-dirs=first --icon=never'
|
||||
fi
|
||||
|
||||
# Update aliases
|
||||
if [[ -x `which brew` ]]; then
|
||||
if [[ -x $(which brew) ]]; then
|
||||
alias brewupdate='brew update; brew upgrade; brew upgrade --cask; brew cleanup'
|
||||
fi
|
||||
|
||||
@ -44,9 +44,9 @@ alias a2='aria2c -x4 -c -m3'
|
||||
alias sc='screen -R'
|
||||
|
||||
# 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"'
|
||||
elif [[ -x `which youtube-dl` ]]; then
|
||||
elif [[ -x $(which youtube-dl) ]]; then
|
||||
alias ytmp4='youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4"'
|
||||
fi
|
||||
|
||||
@ -58,13 +58,13 @@ alias rrsync='rsync -avhP'
|
||||
alias bcp='rsync -avzuh --progress --partial'
|
||||
|
||||
# generate pseudo-random hash
|
||||
alias random32="echo $(date +%s | md5sum | head -c 32)"
|
||||
alias random32='echo $(date +%s | md5sum | head -c 32)'
|
||||
|
||||
# tar
|
||||
alias untargz='tar -xzvf'
|
||||
|
||||
# (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'
|
||||
fi
|
||||
|
||||
|
2
zsh/env
2
zsh/env
@ -81,7 +81,7 @@ fi
|
||||
#
|
||||
|
||||
# TheFuck
|
||||
if [[ -x `which thefuck` ]]; then
|
||||
if [[ -x $(which thefuck) ]]; then
|
||||
eval "$(thefuck --alias)"
|
||||
# You can use whatever you want as an alias, like for Mondays:
|
||||
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/
|
||||
function ff-mp4() {
|
||||
findpath=$1
|
||||
: ${findpath:="."}
|
||||
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' \) | while read f ; do
|
||||
: "${findpath:="."}"
|
||||
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' \) | while read -r f ; do
|
||||
dir=$(dirname "$f");
|
||||
file=$(basename "$f");
|
||||
# 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/
|
||||
function ff-ac3-to-stereo() {
|
||||
findpath=$1
|
||||
: ${findpath:="."}
|
||||
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' -o -iname '*.mp4' \) | while read f ; do
|
||||
: "${findpath:="."}"
|
||||
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' -o -iname '*.mp4' \) | while read -r f ; do
|
||||
dir=$(dirname "$f");
|
||||
file=$(basename "$f");
|
||||
# ext="${filename##*.}";
|
||||
@ -50,8 +50,8 @@ function ff-dts() {
|
||||
## ffmpeg wma-to-m4a
|
||||
function ff-wma-m4a() {
|
||||
findpath=$1
|
||||
: ${findpath:="."}
|
||||
find "$findpath" -name '*.wma' | while read f ; do
|
||||
: "${findpath:="."}"
|
||||
find "$findpath" -name '*.wma' | while read -r f ; do
|
||||
dir=$(dirname "$f");
|
||||
file=$(basename "$f");
|
||||
# ext="${filename##*.}";
|
||||
|
46
zsh/scripts
46
zsh/scripts
@ -9,13 +9,13 @@ function f() {
|
||||
|
||||
# mkdir and cd
|
||||
function mkcd() {
|
||||
mkdir -p "$@" && cd "$_";
|
||||
mkdir -p "$@" && cd "$_" || exit;
|
||||
}
|
||||
|
||||
# "Fake" sha256sum
|
||||
if [[ ! -x `which sha256sum` ]]; then
|
||||
if [[ ! -x $(which sha256sum) ]]; then
|
||||
function sha256sum() {
|
||||
shasum -a256 $1
|
||||
shasum -a256 "$1"
|
||||
}
|
||||
fi
|
||||
|
||||
@ -25,11 +25,11 @@ function targz() {
|
||||
echo "usage: targz filename.tar.gz directory"
|
||||
return
|
||||
fi
|
||||
if [[ ! -x `which pigz` ]]; then
|
||||
tar -czf $1 $2
|
||||
if [[ ! -x $(which pigz) ]]; then
|
||||
tar -czf "$1" "$2"
|
||||
echo "gzip"
|
||||
else
|
||||
tar -c $2 | pigz > $1
|
||||
tar -c "$2" | pigz > "$1"
|
||||
echo "pigz"
|
||||
fi
|
||||
}
|
||||
@ -47,8 +47,8 @@ function pushover() {
|
||||
# png to jpg 85
|
||||
function png2web() {
|
||||
findpath=$1
|
||||
: ${findpath:="."}
|
||||
find "$findpath" -name '*.png' | while read f ; do
|
||||
: "${findpath:="."}"
|
||||
find "$findpath" -name '*.png' | while read -r f ; do
|
||||
dir=$(dirname "$f");
|
||||
file=$(basename "$f");
|
||||
name="${file%.*}";
|
||||
@ -58,7 +58,7 @@ function png2web() {
|
||||
}
|
||||
|
||||
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
|
||||
@ -73,21 +73,21 @@ function pdf-like-scanned () {
|
||||
# Extract files
|
||||
# src: https://github.com/mawalu/dotfiles/blob/master/zsh/.zsh/functions.zsh#L21
|
||||
function extract () {
|
||||
if [ -f $1 ] ; then
|
||||
if [ -f "$1" ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tbz) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*) echo "'$1' cannot be extracted via ex()" ;;
|
||||
*.tar.bz2) tar xjf "$1" ;;
|
||||
*.tar.gz) tar xzf "$1" ;;
|
||||
*.bz2) bunzip2 "$1" ;;
|
||||
*.rar) unrar x "$1" ;;
|
||||
*.gz) gunzip "$1" ;;
|
||||
*.tar) tar xf "$1" ;;
|
||||
*.tbz2) tar xjf "$1" ;;
|
||||
*.tbz) tar xjf "$1" ;;
|
||||
*.tgz) tar xzf "$1" ;;
|
||||
*.zip) unzip "$1" ;;
|
||||
*.Z) uncompress "$1" ;;
|
||||
*.7z) 7z x "$1" ;;
|
||||
*) echo "'$1' cannot be extracted via extract()" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
|
18
zshrc
18
zshrc
@ -10,7 +10,7 @@ prompt_color1="#ffaf00"
|
||||
prompt_color2="#000000"
|
||||
|
||||
# Load zsh settings
|
||||
source $HOME/.dotfiles/zsh/settings
|
||||
source "$HOME/.dotfiles/zsh/settings"
|
||||
|
||||
# Define platform
|
||||
platform='Unknown'
|
||||
@ -41,12 +41,12 @@ elif test -f "/usr/local/bin/brew"; then
|
||||
fi
|
||||
|
||||
# Load additional settings
|
||||
source $HOME/.dotfiles/zsh/env
|
||||
source $HOME/.dotfiles/zsh/alias
|
||||
source $HOME/.dotfiles/zsh/bindings
|
||||
source $HOME/.dotfiles/zsh/scripts
|
||||
source $HOME/.dotfiles/zsh/ffmpeg
|
||||
source $HOME/.dotfiles/this-machine/zsh
|
||||
source "$HOME/.dotfiles/zsh/env"
|
||||
source "$HOME/.dotfiles/zsh/alias"
|
||||
source "$HOME/.dotfiles/zsh/bindings"
|
||||
source "$HOME/.dotfiles/zsh/scripts"
|
||||
source "$HOME/.dotfiles/zsh/ffmpeg"
|
||||
source "$HOME/.dotfiles/this-machine/zsh"
|
||||
|
||||
# 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}
|
||||
@ -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
|
||||
if [[ -d $HOME/.jan ]]; then
|
||||
source $HOME/.jan/credentials
|
||||
source $HOME/.jan/zsh_options
|
||||
source "$HOME/.jan/credentials"
|
||||
source "$HOME/.jan/zsh_options"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user