1
0
Fork 0
This commit is contained in:
Gregory Eremin 2024-02-04 11:28:19 +01:00
parent bb1e28fcb1
commit 7d93d1bc82
9 changed files with 80 additions and 46 deletions

View File

@ -20,7 +20,7 @@ alias gcl="git co -"
alias gml="git merge - --no-edit"
# Ruby
alias bd="bundle install --jobs=8"
alias bd="bundle install --jobs=$(getconf _NPROCESSORS_ONLN)"
alias bdc="bundle config set path 'vendor/bundle'"
alias b="bundle exec"
alias br="bundle exec rails"
@ -29,7 +29,5 @@ alias br="bundle exec rails"
alias goi="go install ./..."
alias gg='rg -g "*.go"'
alias ytdl="youtube-dl -f 'bestvideo+bestaudio'"
#alias ytdl="youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]'"
# Rust
alias cr="cargo run --quiet --"

View File

@ -10,37 +10,34 @@ export LSCOLORS=Exfxcxdxbxegedabagacad
export EDITOR=vim
export PROJECTS=$HOME/Code
export WORK_PROJECTS=$HOME/Code/work
# Go
# GOROOT can be easily derived from go binary path
# export GOROOT=$HOME/go/lang
export GOPATH=$HOME/go/path
source $HOME/dotfiles/bash/functions_internal.sh
source $HOME/dotfiles/bash/history.sh
source $HOME/dotfiles/bash/path.sh
source $HOME/dotfiles/bash/format.sh
source $HOME/dotfiles/bash/alias.sh
source $HOME/dotfiles/bash/prompt.sh
source $HOME/dotfiles/bash/functions.sh
source $HOME/dotfiles/bash/overrides.sh
for f in $HOME/dotfiles/bash/{tools,secrets}/*; do
BASHFILES=$HOME/dotfiles/bash
source $BASHFILES/functions_internal.sh
source $BASHFILES/functions.sh
source $BASHFILES/history.sh
source $BASHFILES/path.sh
source $BASHFILES/format.sh
source $BASHFILES/alias.sh
source $BASHFILES/prompt.sh
for f in $BASHFILES/secrets/*; do
source $f
done
case "$(uname -s)" in
Darwin) source $BASHFILES/macos.sh ;;
Linux) source $BASHFILES/linux.sh ;;
*) echo "*** Unknown system! Check dotfiles/bashrc.sh ***" ;;
esac
# Use bash-completion, if available
[[ $PS2 && -f /usr/share/bash-completion/bash_completion ]] && \
. /usr/share/bash-completion/bash_completion
#
# Misc
#
export PATH="$HOME/.local/bin:$PATH"
# Disable Ruby 2.7 deprecation warnings
# export RUBYOPT='-W:no-deprecated -W:no-experimental'
export RUBYOPT=
alias sysupdate="sudo pacman -Sy archlinux-keyring && sudo pacman -Su && PATH=/usr/bin:$PATH yay -Syu"
if [ $PS2 ] && [ -f /usr/share/bash-completion/bash_completion ]; then
source /usr/share/bash-completion/bash_completion
fi
if [ $PS2 ] && [ -f $HOME/.git-completion.bash ]; then
source $HOME/.git-completion.bash
fi

View File

@ -2,6 +2,25 @@ function reload {
source $HOME/.bashrc
}
function __path_list {
IFS=':' read -ra ARY <<< "$PATH"
for DIR in "${ARY[@]}"; do
echo $DIR
done
}
function __path_append {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
export PATH="${PATH:+"$PATH:"}$1"
fi
}
function __path_prepend {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
export PATH="$1${PATH:+":$PATH"}"
fi
}
# Count lines of code in files that are checked into the current Git repository
function gkloc {
cloc $(git ls-files)
@ -30,13 +49,17 @@ function h { cd $HOME/$1; }
function _h { __bash_directory_complete $HOME; }
complete -F _h h
function c { cd $(realpath $PROJECTS/$1); }
function _c { __bash_directory_complete $PROJECTS; }
function c { cd $(realpath $WORK_PROJECTS/$1); }
function _c { __bash_directory_complete $WORK_PROJECTS; }
complete -F _c c
function cg { cd $GOPATH/src/github.com/$1; }
function _cg { __bash_directory_complete $GOPATH/src/github.com; }
complete -W "$(dir -d $HOME/go/path/src/github.com/*/* | cut -d'/' -f8-)" cg
function p { cd $(realpath $PROJECTS/$1); }
function _p { __bash_directory_complete $PROJECTS; }
complete -F _p p
# function cg { cd $GOPATH/src/github.com/$1; }
# function _cg { __bash_directory_complete $GOPATH/src/github.com; }
# complete -W "$(dir -d $HOME/go/path/src/github.com/*/* | cut -d'/' -f8-)" cg
#
# Misc

3
bash/linux.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
alias sysupdate="sudo pacman -Sy archlinux-keyring && sudo pacman -Su && PATH=/usr/bin:$PATH yay -Syu"

14
bash/macos.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# Homebrew
__path_append "/opt/homebrew/bin"
# Node
__path_append "/opt/homebrew/opt/node@18/bin"
__path_append "/opt/homebrew/opt/libpq/bin"
# Add sublime binary directly to PATH
__path_append "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin"
# Lowercase Tailscale alias
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"

View File

@ -1,4 +0,0 @@
function htop {
__window_title "htop"
/sbin/htop
}

View File

@ -1,13 +1,17 @@
# Dotfiles
export PATH=$PATH:$HOME/dotfiles/bin # Dotfiles scripts
__path_append "$HOME/dotfiles/bin"
# Ruby
export PATH=$HOME/.rbenv/versions/$(cat $HOME/.rbenv/version)/bin:$PATH # Gem binaries
export PATH=$HOME/.rbenv/shims:$PATH # Gem binaries
# export PATH=$HOME/.rbenv/versions/$(cat $HOME/.rbenv/version)/bin:$PATH # Gem binaries
# export PATH=$HOME/.rbenv/shims:$PATH # Gem binaries
# Go
export PATH=$HOME/go/lang/bin:$PATH # Go package binaries
export PATH=$GOPATH/bin:$PATH # Go package binaries
__path_prepend "$HOME/go/lang/bin"
__path_append "$GOPATH/bin"
# Rust
export PATH=$PATH:$HOME/.cargo/bin
__path_append "$HOME/.cargo/bin"
if [ -d "$HOME/.local/bin" ]; then
__path_append "$HOME/.local/bin"
fi

View File

@ -1,4 +1,4 @@
GIT="/sbin/git"
GIT="$(which git)"
function __bash_prompt {
local baseDir=$(__bash_basedir)

View File

@ -1 +0,0 @@
#!/bin/bash