diff --git a/.bashrc b/.bashrc index 1681de5..2da2781 100644 --- a/.bashrc +++ b/.bashrc @@ -2,19 +2,34 @@ # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples -# If not running interactively, don't do anything +## If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac +## Bash Configuration + # If set, the pattern "**" used in a pathname expansion context will # match all files and zero or more directories and subdirectories. #shopt -s globstar -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +## Setup Prompt # set variable identifying the chroot you work in (used in the prompt below) if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) @@ -48,6 +63,7 @@ else fi unset color_prompt force_color_prompt +## Set title if xterm # If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) @@ -57,72 +73,18 @@ xterm*|rxvt*) ;; esac -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# colored GCC warnings and errors -#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Add an "alert" alias for long running commands. Use like so: -# sleep 10; alert -alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' - -# Alias definitions. -# You may want to put all your additions into a separate file like -# ~/.bash_aliases, instead of adding them here directly. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. - -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi - ## Begin .rc.d stuff -## Homebrew -# Consider moving this to a .rc.d script. -# If Apple Silicon Homebrew is installed activate it. -if [ -x "/usr/local/homebrew/bin/brew" ]; then - eval "$(/usr/local/homebrew/bin/brew shellenv)" - # If x86_64 Homebrew is installed alias it to brew86. - if [ -x "/opt/homebrew/bin/brew" ]; then - alias brew86='arch -x86_64 /usr/local/homebrew/bin/brew' - fi -fi - -# If x86_64 Homebrew is installed activate it. -if [ -x "/opt/homebrew/bin/brew" ]; then - eval "$(/opt/homebrew/bin/brew shellenv)" - # If Apple Silicon Homebrew is installed alias it to brewarm. - if [ -x "/usr/local/homebrew/bin/brew" ]; then - alias brewarm='arch -arm64 /opt/homebrew/bin/brew' - fi -fi - ## Source all scripts in ~/.rc.d for f in ~/.rc.d/*.sh; do source "$f" done - ## Autocompletion # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). +# sources /etc/bash.bashrc). This is after .rc.d stuff because that may have changed the available completions. if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion @@ -133,19 +95,15 @@ fi ## Functions -## Configure History -# don't put duplicate lines or lines starting with space in the history. -# See bash(1) for more options -HISTCONTROL=ignoreboth +## Paths -# append to the history file, don't overwrite it -shopt -s histappend +# Append personal bin to path +# if [ -d "$HOME/bin" ] ; then +# PATH="$HOME/bin:$PATH" +# fi -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize +# Append local personal bin to path +# if [ -d "$HOME/.local/bin" ] ; then +# PATH="$HOME/.local/bin:$PATH" +# fi diff --git a/.rc.d/aliases.sh b/.rc.d/aliases.sh index f943be4..530262b 100755 --- a/.rc.d/aliases.sh +++ b/.rc.d/aliases.sh @@ -1,4 +1,6 @@ +# TODO: detect color support and enable/disable color in aliases based on that. # File Manipulation +# TODO: bash ls doesn't need -G or maybe macs don't. Figure that out and use that test here. alias ls='ls -G --color=auto' alias lsd='ls -G --color=auto -d' alias ll='ls -G --color=auto -l' @@ -6,12 +8,16 @@ alias lld='ls -G --color=auto -l -d' alias lsg='ls | grep --color' alias llg='ls -l| grep --color' alias ln='ln -ivw' -alias grep='grep --color' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' alias slash='ls -SlAhr' alias slasher='ls -SlAh' alias slashed='ls -SlAhrd' alias dud='function { du -h -d 1 $* | sort -h }' +alias dud='function f() { du -h -d 1 "$@" 2>/dev/null | sort -h ; unset -f f; }; f' alias dudr='function { du -h -d 1 $* | sort -h -r }' +alias dudr='function f() { du -h -d 1 "$@" 2>/dev/null | sort -h -r ; unset -f f; }; f' alias mvn='mv -n' alias gmv='mv $* ~/Google\ Drive/My\ Drive/' alias gmvn='mv -n $* ~/Google\ Drive/My\ Drive/' @@ -21,8 +27,9 @@ alias gmv='mv $* ~/OneDrive/' alias gmvn='mv -n $* ~/OneDrive/' alias mv='mv -i' alias rm='rm -i' -alias rs='rsync -avhz --no-perms' +alias rs='rsync -avhz --no-perms --progress' alias ds='function { du -h -d 1 $* | sort -h | tee ~/dirsize }' +alias ds='function f() { du -h -d 1 $* | sort -h | tee ~/dirsize ; unset -f f; }; f' alias md=mkdir alias rd=rmdir @@ -50,6 +57,7 @@ alias hashes='md5deep -r' alias lsusb='system_profiler SPUSBDataType' alias tea='tee -a' alias find_recent='function { find . $* -exec ls -ltr {} + }' +alias find_recent='function f() { find . $* -exec ls -ltr {} + ; unset -f f; }; f' # In Development @@ -60,3 +68,18 @@ alias log_and_do='function { `echo "# $1 >> $2\n" > $2 && echo $1` >> $2 }' # This should get the PIDs of any avd commands running and kill-9 them and then do the # same as kill-all-android-emulators to clean them up after. # alias kaae="kill -9 `ps aux | grep avd | sed '$d' | cut -f 2 -w` > /dev/null" + +# TODO: Stuff I don't know why other configs setup +#alias dir='dir --color=auto' +#alias vdir='vdir --color=auto' +#alias ll='ls -alF' +#alias la='ls -A' +#alias l='ls -CF' +# From Bash on Ubuntu +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +#alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# WSL Specific +#alias pbcopy=clip.exe +#alias pbpaste="powershell.exe -noprofile Get-Clipboard" diff --git a/.rc.d/android.sh b/.rc.d/android.sh index 71d9be2..ed9cb16 100755 --- a/.rc.d/android.sh +++ b/.rc.d/android.sh @@ -19,3 +19,31 @@ if [ -n "${ANDROID_HOME}" ]; then fi # "extras;google;simulators" "ndk;27.0.11718014" "platform-tools" "platforms;android-34" "system-images;android-34;default;arm64-v8a" + +function anon() { + local android_studio_sdk_home_on_mac="$HOME/Library/Android/sdk" + local android_home= + if [ -d "$android_studio_sdk_home_on_mac" ]; then + android_home="$android_studio_sdk_home_on_mac" + elif [ -d "$android_cmdline_tools_on_mac" ]; then + android_home="$android_cmdline_tools_on_mac" + fi + + if [ -n "$android_home" ]; then + export ANDROID_HOME="$android_home" + if [ -d "$android_home/cmdline-tools/latest/bin" ]; then + path=("$android_home/cmdline-tools/latest/bin" $path) + fi + # TODO: Get the appropriate directories based on what is available. + path=(${ANDROID_HOME}/build-tools/34.0.0 $path) + path=(${ANDROID_HOME}/ndk/26.1.0909125 $path) + path=(${ANDROID_HOME}/platform-tools $path) + path=(${ANDROID_HOME}/tools $path) + path=(${ANDROID_HOME}/tools:/bin $path) + fi + + # "extras;google;simulators" "ndk;27.0.11718014" "platform-tools" "platforms;android-34" "system-images;android-34;default;arm64-v8a" + + unset -f anon +} +anon diff --git a/.rc.d/gcc.sh.disabled b/.rc.d/gcc.sh.disabled new file mode 100644 index 0000000..b1ff50f --- /dev/null +++ b/.rc.d/gcc.sh.disabled @@ -0,0 +1,2 @@ +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' diff --git a/.rc.d/homebrew.sh.disabled b/.rc.d/homebrew.sh.disabled new file mode 100644 index 0000000..a57a284 --- /dev/null +++ b/.rc.d/homebrew.sh.disabled @@ -0,0 +1,17 @@ +# If both intel and arm versions are installed the arm version will be the default brew, but aliases will be available to run either specifically. + +# If intel Homebrew is installed activate it. +if [ -x "/usr/local/homebrew/bin/brew" ]; then + eval "$(/usr/local/homebrew/bin/brew shellenv)" + + # If arm Homebrew is also installed create aliases for each version + if [ -x "/opt/homebrew/bin/brew" ]; then + alias brew86='arch -x86_64 /usr/local/homebrew/bin/brew' + alias brewarm='arch -arm64 /opt/homebrew/bin/brew' + fi +fi + +# If arm Homebrew is installed activate it. +if [ -x "/opt/homebrew/bin/brew" ]; then + eval "$(/opt/homebrew/bin/brew shellenv)" +fi diff --git a/.rc.d/lesspipe.sh b/.rc.d/lesspipe.sh new file mode 100644 index 0000000..975ba70 --- /dev/null +++ b/.rc.d/lesspipe.sh @@ -0,0 +1,2 @@ +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" diff --git a/.rc.d/ls-colors.sh b/.rc.d/ls-colors.sh index 0f895ab..dff98f8 100755 --- a/.rc.d/ls-colors.sh +++ b/.rc.d/ls-colors.sh @@ -1,34 +1,5 @@ -# export LSCOLORS=ExfxcxdxbxEgEdabagacad -# export LSCOLORS=GxFxedGdCxEgEdCbCdacad -# export LSCOLORS=BxGxedGdCxxExFHBDBbcbd +# zsh export LSCOLORS=FxGxedGdCxxExFHBDBbcbd -# a black -# b red -# c green -# d brown -# e blue -# f magenta -# g cyan -# h light grey -# A bold black, usually shows up as dark grey -# B bold red -# C bold green -# D bold brown, usually shows up as yellow -# E bold blue -# F bold magenta -# G bold cyan -# H bold light grey; looks like bright white -# x default foreground or background - -# 1. directory -# 2. symbolic link -# 3. socket -# 4. pipe -# 5. executable -# 6. block special -# 7. character special -# 8. executable with setuid bit set -# 9. executable with setgid bit set -# 10. directory writable to others, with sticky bit -# 11. directory writable to others, without sticky bit +# bash +export LS_COLORS="rs=0:di=95:ln=36:mh=00:pi=96;43:so=34;43:do=34;43:bd=104:cd=105:or=5;96;40:mi=5;30;46:su=97;101:sg=93;101:ca=00:tw=91;42:ow=91;43:st=42:ex=92:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:" diff --git a/.rc.d/nvm.sh b/.rc.d/nvm.sh index 46fdcf8..01bfea3 100755 --- a/.rc.d/nvm.sh +++ b/.rc.d/nvm.sh @@ -6,5 +6,6 @@ function anon() { [ -s $nvm_dir/bash_completion ] && \. $nvm_dir/bash_completion # This loads nvm bash_completion export NVM_DIR=$nvm_dir fi + unset -f anon } -unset -f anon +anon diff --git a/.rc.d/yarn.sh b/.rc.d/yarn.sh deleted file mode 100755 index 58f5e9f..0000000 --- a/.rc.d/yarn.sh +++ /dev/null @@ -1,7 +0,0 @@ -function anon() { - if [[ $(command -v yarn) ]]; then - local yarn_path="$(yarn global bin)" - path=($yarn_path $path) - fi -} -unset -f anon diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e2c7f44 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "[shellscript]": { + "editor.tabSize": 2 + }, + "files.associations": { + "*.sh.disabled": "shellscript" + } +}