From 902ca7dc025c9ced3fccad4e0a99332e3d63361d Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 1 Feb 2020 16:29:27 +0100 Subject: [PATCH] Add basic aliases and profile configuration --- sh/.config/sh/alias | 34 ++++++++++++++++++++++++--- sh/.config/sh/profile | 10 ++++++++ sh/.config/sh/profile.d/autostartx.sh | 5 ++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 sh/.config/sh/profile.d/autostartx.sh diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index cc6d2a4..9d930f5 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -2,6 +2,8 @@ # # Global aliases for any shell +exist() { type "$1" >/dev/null 2>&1; } + # Avoid aliases which I did not create -- unalias EVERYTHING unalias -a @@ -12,8 +14,14 @@ alias v="nvim" alias :q="exit" # ls defaults -if [ "$(uname -s)" = "Linux" ]; then - # we're on linux +if exist exa; then + alias l="exa -l --git --git-ignore" + alias L="exa -hal --grid --git" + # a recursive tree + # - usually want to change levels recursed with -L2 -L3 or similar + alias ll="exa --tree -L2" + alias LL="exa -a --tree -L2" +else alias l="ls -lhF" alias L="ls -lAhF" fi @@ -26,5 +34,25 @@ alias ~="cd ~" # clear my screen alias cl="clear" -# Display your current external ip address +# Display current external ip address alias myip="curl -s icanhazip.com" + +# fzf +if exist fzf; then + # Display fuzzy-searchable history + alias fzf_history="history | fzf --tac --height 20" + # Fuzzy search packages to install + alias fzf_yay="yay -Slq | fzf -m --preview 'yay -Si {1}' | xargs -ro yay -S" + # Fuzzy uninstall packages + alias fzf_yayrns="yay -Qeq | fzf -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns" +fi + +# vifm +if exist vifm; then + alias vm=vifm + alias vmm='vifm ${PWD}' + # enable picture preview script + exist vifmrun && alias vifm=vifmrun +fi + +unset -f exist diff --git a/sh/.config/sh/profile b/sh/.config/sh/profile index afb471a..e568d23 100644 --- a/sh/.config/sh/profile +++ b/sh/.config/sh/profile @@ -16,3 +16,13 @@ if [ -d "$XDG_CONFIG_HOME/sh/env.d" ]; then done unset _env fi + +# shellcheck source=alias +[ -f "$XDG_CONFIG_HOME/sh/alias" ] && . "$XDG_CONFIG_HOME/sh/alias" +# load additional aliases +if [ -d "$XDG_CONFIG_HOME/sh/alias.d" ]; then + for _alias in "$XDG_CONFIG_HOME/sh/alias.d"/*.sh; do + . "$_alias" + done + unset _alias +fi diff --git a/sh/.config/sh/profile.d/autostartx.sh b/sh/.config/sh/profile.d/autostartx.sh new file mode 100644 index 0000000..5da5059 --- /dev/null +++ b/sh/.config/sh/profile.d/autostartx.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +if [ ! "$DISPLAY" ] && [ "$XDG_VTNR" -eq 1 ]; then + exec startx "$XDG_CONFIG_HOME"/xresources/xinitrc +fi