From 11be9bde17c8b949118f02acbfd04adf16df1e04 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sat, 5 Nov 2022 18:19:41 +0100 Subject: Add ex and welcome_msg function --- exports/.exports | 3 +++ initsh/.initsh | 28 +++++++++++++++++++++++++--- zsh/.zshrc | 9 ++++++--- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/exports/.exports b/exports/.exports index 6737695..ce68517 100644 --- a/exports/.exports +++ b/exports/.exports @@ -55,3 +55,6 @@ export RUST_BACKTRACE=1 # Pico SDK [ -d "$HOME/pico/pico-sdk" ] && export PICO_SDK_PATH="$HOME/pico/pico-sdk" + +# FZF +export FZF_DEFAULT_OPTS="--reverse" diff --git a/initsh/.initsh b/initsh/.initsh index 47af88c..fcbd398 100755 --- a/initsh/.initsh +++ b/initsh/.initsh @@ -48,8 +48,30 @@ elif [ "$KERNEL" = "Darwin" ]; then alias upaste='pbpaste' fi -# Greeting message -if [ -n "$WELCOME_MSG" ]; then +# ex - archive extractor +# # usage: ex +ex () { + 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 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +welcome_msg () { if [ "$KERNEL" = "Linux" ]; then DF_ARGS="-h -T -xtmpfs -xdevtmpfs" if [ -x "$(command -v lsb_release)" ]; then @@ -74,4 +96,4 @@ if [ -n "$WELCOME_MSG" ]; then printf '\n' printf '%s\n' "$(eval df $DF_ARGS | sed 's/^/ /')" printf '\n' -fi +} diff --git a/zsh/.zshrc b/zsh/.zshrc index 42a13f0..da3ea9b 100755 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -111,16 +111,19 @@ POWERLEVEL9K_STATUS_ERROR_BACKGROUND='009' # lightred POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='009' # lightred # Autosuggestions -[ -n "$ZSH_AUTOSUGGEST_PATH" ] && source "$ZSH_AUTOSUGGEST_PATH" +[ -n "$ZSH_AUTOSUGGEST" ] && source "$ZSH_AUTOSUGGEST" ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE=fg=7 ZSH_AUTOSUGGEST_USE_ASYNC=1 # Syntax highlighting -[ -n "$ZSH_SYNTAX_HIGHLIGHTING_PATH" ] && source "$ZSH_SYNTAX_HIGHLIGHTING_PATH" +[ -n "$ZSH_SYNTAX_HIGHLIGHTING" ] && source "$ZSH_SYNTAX_HIGHLIGHTING" -[ -f "$ZSH_FZF_PATH" ] && source "$ZSH_FZF_PATH" +[ -f "$ZSH_FZF_KEYBINDS" ] && source "$ZSH_FZF_KEYBINDS" # Exec general init script source ~/.initsh # Dedupe PATH typeset -U PATH + +# Only show welcome message if it's enabled and we're a login shell +[[ -o login && -n "$WELCOME_MSG" ]] && welcome_msg -- cgit v1.2.3