diff --git a/aliases.sh b/aliases.sh index 5d653c4..9b8bba5 100644 --- a/aliases.sh +++ b/aliases.sh @@ -1,27 +1,15 @@ -#!/bin/sh -ALIASES_BLACK='\033[0;30m' # Black -ALIASES_RED='\033[0;31m' # Red +#!/usr/bin/env bash +# shellcheck shell=bash ALIASES_GREEN='\033[0;32m' # Green -ALIASES_YELLOW='\033[0;33m' # Yellow (or Brown) ALIASES_BLUE='\033[0;34m' # Blue -ALIASES_MAGENTA='\033[0;35m' # Magenta -ALIASES_CYAN='\033[0;36m' # Cyan -ALIASES_LIGHT_GRAY='\033[0;37m' # Light Gray (or White) - -ALIASES_DARK_GRAY='\033[1;30m' # Dark Gray -ALIASES_LIGHT_RED='\033[1;31m' # Light Red -ALIASES_LIGHT_GREEN='\033[1;32m' # Light Green -ALIASES_LIGHT_YELLOW='\033[1;33m' # Light Yellow -ALIASES_LIGHT_BLUE='\033[1;34m' # Light Blue -ALIASES_LIGHT_MAGENTA='\033[1;35m' # Light Magenta -ALIASES_LIGHT_CYAN='\033[1;36m' # Light Cyan ALIASES_WHITE='\033[1;37m' # White ALIASES_NC='\033[0m' # No Color echo "Aliases added:" -echo -e "${ALIASES_WHITE} cs venv" -echo " n ns pc cdlf lfcd g gg gitknow disk-usage sx debug.log" -echo " mc newsh smartresize" +echo -e "${ALIASES_WHITE} cs pc venv cdlf lfcd" +echo " e er et en ens ea ee" +echo " g gg disk-usage debug.log" +echo " backup update re mc" echo " mac red alice phthalo zirconia datapasa ultra kermit singsay pi4" echo -e " ${ALIASES_NC}client:${ALIASES_WHITE} crafty lv" echo -e "${ALIASES_NC}" @@ -52,7 +40,6 @@ alias speak='/usr/local/src/kokora/speak' alias debug.log='clear && echo "" > debug.log && tail -f debug.log' alias g='git status' alias gg='git add . && git commit -m "update" && git push' -alias gitknow='cd ~/knowledge-base && git add . && git status && git commit -m update && git push ; cd -' alias ls='LC_COLLATE=C ls --color=auto -h --group-directories-first --time-style=+"%d.%m.%Y %H:%M" -F' @@ -99,49 +86,33 @@ else fi cdlf() { - cd "$(cat ~/.cache/lf-last-dir)" + local last_dir + [ -r "$HOME/.cache/lf-last-dir" ] || return 1 + IFS= read -r last_dir < "$HOME/.cache/lf-last-dir" + [ -n "$last_dir" ] || return 1 + cd -- "$last_dir" || return } lfcd() { - lf -last-dir-path="$HOME"/.cache/lf-last-dir - cdlf + lf -last-dir-path="$HOME"/.cache/lf-last-dir && cdlf } update() { echo -e "Executing \"${ALIASES_GREEN}pacman -Syu${ALIASES_NC}\" via \"${ALIASES_BLUE}archnews_wrap${ALIASES_NC}\" wrapper" - sudo ~/.src/archnews/archnews_wrap -Syu \ - && systemctl --user start --no-block package-status-refresh.service -} - -# functions -# $1 - output directory -# $2 - size -# $3 - filename -smartresize() { - mogrify -path "$3" -filter Triangle -define filter:support=2 -thumbnail "$2" -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB "$1" + sudo ~/.src/archnews/archnews_wrap -Syu || return + systemctl --user start --no-block package-status-refresh.service >/dev/null 2>&1 || true } re() { - git clone ssh://git@git.rayelliott.dev:3222/rayelliott/"$1".git $2 + if [ -n "${2:-}" ]; then + git clone "ssh://git@git.rayelliott.dev:3222/rayelliott/$1.git" "$2" + else + git clone "ssh://git@git.rayelliott.dev:3222/rayelliott/$1.git" + fi } mc() { - mkdir "$1" && cd "$1" -} - -newsh() { - set -e - - if [ -f "$1" ] ; then - echo "Error: file exists: $1" - exit 1 - fi - - echo "#!/bin/sh" > "$1" - echo "" >> "$1" - echo "$2" >> "$1" - - chmod +x "$1" - nvim "$1" +3 + mkdir "$1" || return + cd "$1" || return } diff --git a/install.sh b/install.sh index 6301a18..048b7fd 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ -e "$HOME/.profile" ] ; then +if [ -e "$HOME/.profile" ] || [ -L "$HOME/.profile" ] ; then mv "$HOME/.profile" "$HOME/.profile-original-$(date +%s)" fi diff --git a/profile b/profile index 3753939..bc3d1bd 100644 --- a/profile +++ b/profile @@ -1,46 +1,51 @@ +#!/bin/sh + export XDG_DATA_HOME="$HOME/.local/share" export XDG_CONFIG_HOME="$HOME/.config" export XDG_STATE_HOME="$HOME/.local/state" export XDG_CACHE_HOME="$HOME/.cache" -export SHELL_CONFIG="$SHELL_CONFIG:.profile" +export SHELL_CONFIG="${SHELL_CONFIG:+${SHELL_CONFIG}:}.profile" export EDITOR=/usr/bin/vim export BROWSER=/usr/bin/qutebrowser export GOPATH="$HOME/.go" -if command -v ruby ; then - ruby_path=$(ruby -r rubygems -e "puts Gem.user_dir")/bin - export PATH="$ruby_path:$PATH" -fi &> /dev/null +_path_prepend() { + case ":${PATH}:" in + *":$1:"*) ;; + *) PATH="$1${PATH:+:${PATH}}" ;; + esac +} -if command -v php ; then - phpcs_path=$(composer global config bin-dir --absolute) - export PATH="$phpcs_path:$PATH" -fi &> /dev/null +_path_append() { + case ":${PATH}:" in + *":$1:"*) ;; + *) PATH="${PATH:+${PATH}:}$1" ;; + esac +} -export PATH="$PATH:$HOME/.local/bin" -export PATH="$PATH:/opt/neovim/nvim-linux-x86_64/bin" +if command -v ruby >/dev/null 2>&1; then + ruby_path=$(ruby -r rubygems -e 'puts Gem.user_dir' 2>/dev/null) + [ -n "$ruby_path" ] && _path_prepend "$ruby_path/bin" +fi + +if command -v composer >/dev/null 2>&1; then + phpcs_path=$(composer global config bin-dir --absolute 2>/dev/null) + [ -n "$phpcs_path" ] && _path_prepend "$phpcs_path" +fi + +_path_append "$GOPATH/bin" +_path_append "$HOME/.local/bin" +_path_append /opt/neovim/nvim-linux-x86_64/bin +export PATH # https://developers.google.com/web/tools/puppeteer/troubleshooting export CHROME_DEVEL_SANDBOX=/usr/lib/chromium/chrome-sandbox -export HISTFILE=~/.histfile -export HISTSIZE=10000 -export SAVEHIST=$HISTSIZE +[ -r "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" -#disable suspend and resume -stty -ixon - -# autoenv activate -export AUTOENV_ENV_FILENAME=.in -export AUTOENV_ENV_LEAVE_FILENAME=.out -export AUTOENV_ENABLE_LEAVE=1 -[ -f "$HOME/.src/autoenv/activate.sh" ] && . "$HOME/.src/autoenv/activate.sh" - -# custom aliases -[ -f "$HOME/.config/profile/aliases.sh" ] && . "$HOME/.config/profile/aliases.sh" - -. "$HOME/.cargo/env" +unset ruby_path phpcs_path +unset -f _path_prepend _path_append 2>/dev/null || true # vim: filetype=sh