From 4649405dc48c4f66ec6901fe633e6fda08a5c72c Mon Sep 17 00:00:00 2001 From: James Dixon Date: Sat, 29 May 2021 21:31:41 -0400 Subject: [PATCH] start in tmux and re-add tmux --- README.md | Bin 679 -> 45 bytes files/bash/.bashrc | 123 +++++++++++++++++++++++++++++---------------- 2 files changed, 81 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 35ba4413b6dc8d2625d5ddc61af823057aa1de1e..872c01559ea7ac2302b7d73ae653f7ad29f8981d 100644 GIT binary patch literal 45 qcmb2|=3oE==C=nKd4a4$3%>j3@|iDyhyuw5bLLt1WYrlo7#IN4*9i&$ literal 679 zcmZ`%!D`$v5WVXwhHMUP>00+dPocC6O#%%$g@R>iY>CJkR~pysrQhC>z1uAdy@{DO zZ=T+p9XuSt5%(ctQR)C@gt>$?!0VUC7kFk`e!TO{Q@PW6S(au(j&M7F?)p%Ev~j-3|_^aGvdo ztc9&&qAVDou2iaR+s+iP%*4V~Sek1GcHpoJCV{lk3A0d9Q7-k@xE>v4bA_9X9c6g` zd}cG*`YVj=-c;R3N>vj3P$1((t1eM>3qxSA(ndJ@Clx<;jipgX94U!BefGYQrVLrp zdrCuZnfzTsI{%_Wa`* diff --git a/files/bash/.bashrc b/files/bash/.bashrc index a2d4a95..7bc2d1d 100644 --- a/files/bash/.bashrc +++ b/files/bash/.bashrc @@ -4,6 +4,11 @@ case $- in *) return;; esac +# start in tmux session if possible +if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then + exec tmux +fi + # history HISTSIZE= ; HISTFILESIZE= @@ -26,6 +31,7 @@ GREP_OPTS="--color=auto" ## aliases ## +# core utils alias l="ls ${LS_OPTS}" alias ls="ls ${LS_OPTS}" alias ll="ls -lsh ${LS_OPTS}" @@ -41,40 +47,35 @@ alias egrep="egrep ${GREP_OPTS}" alias treel="tree -C | less -R" alias lsmnt="mount | column -t" +# git - vim - tmux alias g="git" alias groot="cd $(git rev-parse --show-toplevel 2> /dev/null || echo -n ".")" +alias v="$EDITOR" +alias vi="$EDITOR" + alias tmls="tmux ls" alias tmlsc="tmux lsc" alias tmks="tmux kill-session -t" # kill one session alias tmka="tmux kill-server" # aka killall -if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then - alias a="sudo apt" - alias aup="sudo apt update" - alias aupg="sudo apt upgrade -y" - alias alu="apt list --upgradable" -fi - -alias sud="sudo su" -alias s="systemctl" -alias xo="xdg-open" -alias open="xdg-open" - -alias v="$EDITOR" -alias vi="$EDITOR" -alias vmi="$EDITOR" -alias imv="$EDITOR" -alias ivm="$EDITOR" - +# python alias py="python3" alias ipy="ipython3" alias venvac="source venv/bin/activate" +# gui things +alias xo="xdg-open" +alias open="xdg-open" alias firefox-temp='firefox --profile $(mktemp -d) &> /dev/null &' -## colors ## +# compression/archives +alias untar="tar -xvf" +alias mktar="tar -caf" +alias tarls="tar -tvf" +alias ungzip="gunzip" +## colors ## # color vars using tput or ANSI/VT100 Control sequences # check if tput is available if [ -x "$(command -v tput)" ]; then @@ -125,12 +126,28 @@ else # or fallback to ANSI esacpe codes fi ## functions ## - -# common commands improved +# concat common commands mkcd() { mkdir -p -- "$1" && cd "$1"; } cdd() { [ -n "$1" ] && for i in $(seq 1 "$1"); do cd ..; done; } +cdl() { cd "$1" && ls -l; } +cdla() { cd "$1" && ls -la; } touchx() { touch "$@" && chmod +x "$@"; } +# git +lazygit() { + git commit -a -m "$*" && git push; +} +lg() { + lazygit "$*"; +} + +# vim +swp_vimrc(){ + mv ~/.vim/vimrc ~/.vim/vimrc.swp + mv ~/.vim/vimrc.min ~/.vim/vimrc + mv ~/.vim/vimrc.swp ~/.vim/vimrc.min +} + # tmux tm() { if [ "$#" -gt 0 ]; then @@ -151,14 +168,7 @@ tma() { fi } -# vim -swp_vimrc(){ - mv ~/.vim/vimrc ~/.vim/vimrc.swp - mv ~/.vim/vimrc.min ~/.vim/vimrc - mv ~/.vim/vimrc.swp ~/.vim/vimrc.min -} - -# checks for path duplication +# path helpers appendpath () { [[ ":$PATH:" != *":$1:"* ]] && PATH="${PATH}:$1" } @@ -166,25 +176,54 @@ prependpath() { [[ ":$PATH:" != *":$1:"* ]] && PATH="$1:${PATH}" } -# easy backup +# etc functions +colordump(){ + for i in $(seq 0 255); do printf "$(tput setaf $i)$i "; done +} + +extract() { + if [ -z "$1" ]; then + # display usage if no parameters given + echo "Usage: extract ." + echo " extract [path/file_name_2.ext] [path/file_name_3.ext]" + return 1 + else + for n in "$@"; do + if [ -f "$n" ] ; then + case "${n%,}" in + *.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar) + tar xvf "$n" ;; + *.lzma) unlzma ./"$n" ;; + *.bz2) bunzip2 ./"$n" ;; + *.rar) unrar x -ad ./"$n" ;; + *.gz) gunzip ./"$n" ;; + *.zip) unzip ./"$n" ;; + *.z) uncompress ./"$n" ;; + *.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar) + 7z x ./"$n" ;; + *.xz) unxz ./"$n" ;; + *.exe) cabextract ./"$n" ;; + *) + echo "extract: '$n' - unknown archive method" + return 1 + ;; + esac + else + echo "'$n' - file does not exist" + return 1 + fi + done + fi +} + bkup() { if [ -f "$1" ]; then cp "${1}" "${1}.bkup.$(date +'%F.%R')"; fi } -# git -lazygit() { - git commit -a -m "$*" && git push; -} - -lg() { - lazygit "$*"; -} - -# colors -colordump(){ - for i in $(seq 0 255); do printf "$(tput setaf $i)$i "; done +cheatsh() { + curl cheat.sh/"$1" } ## prompt stuff ##