Add bash config and add user to docker group
parent
3dd44f655a
commit
04aff773ad
@ -0,0 +1,274 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -z "$WORKSPACE_USER" ]]; then
|
||||
workspace run
|
||||
fi
|
||||
|
||||
declare -gx WORKSPACE_CONFIG_DIR=~/.workspace
|
||||
declare -gx BROWSER='firefox'
|
||||
|
||||
if [[ -n $TMUX ]]; then
|
||||
declare -gx TERM=screen-256color
|
||||
elif [[ $TERM != 'dumb' ]]; then
|
||||
declare -gx TERM=xterm-256color
|
||||
fi
|
||||
|
||||
alias td='cd $(mktemp -d)'
|
||||
alias snr='echo 500759739'
|
||||
alias snr_vu='echo 2667409'
|
||||
alias q='exit'
|
||||
alias ctrlc='xclip -selection clipboard'
|
||||
alias cpsnr='snr | ctrlc'
|
||||
alias cpdatum="date +'%0e - %m - %Y' | ctrlc"
|
||||
alias xclass="executeClass"
|
||||
|
||||
# git stuff
|
||||
alias st='git status'
|
||||
alias gp='git pull'
|
||||
alias gpush='git push'
|
||||
alias amend='git commit -a --amend'
|
||||
alias boom='git log --oneline --graph --decorate --all'
|
||||
|
||||
# This file stuff
|
||||
alias ali='source ~/.bash_aliases'
|
||||
alias alilength='echo "Length of ~/.bash_aliases is $(wc -l < ~/.bash_aliases) lines"'
|
||||
|
||||
enable-anaconda() {
|
||||
eval "$(/home/hugo/anaconda3/bin/conda shell.bash hook)"
|
||||
}
|
||||
|
||||
enable-venv() {
|
||||
source ~/.virtualenvs/main/bin/activate
|
||||
}
|
||||
|
||||
# Emacs stuff
|
||||
|
||||
ec() {
|
||||
if [[ -n ${1+x} ]]; then
|
||||
declare file="$1"
|
||||
|
||||
file="${file//\\/\\\\}"
|
||||
file="${file//\"/\\\"}"
|
||||
workspace run emacsclient -s ~/.cache/emacs/server --create-frame -nw -e '(find-file "'"$file"'")'
|
||||
return $?
|
||||
fi
|
||||
|
||||
workspace run emacsclient -s ~/.cache/emacs/server --create-frame -nw
|
||||
}
|
||||
|
||||
ew() {
|
||||
if [[ -n ${1+x} ]]; then
|
||||
declare file="$1"
|
||||
|
||||
file="${file//\\/\\\\}"
|
||||
file="${file//\"/\\\"}"
|
||||
workspace run -detach emacsclient -s ~/.cache/emacs/server --create-frame -e '(find-file "'"$file"'")'
|
||||
return $?
|
||||
fi
|
||||
|
||||
workspace run -detach emacsclient -s ~/.cache/emacs/server --create-frame
|
||||
}
|
||||
|
||||
# Grep stuff
|
||||
alias progrep='grep -r --exclude-dir={.cache,vendor,.git,.idea,vendor,var,web,node_modules,httpconf}'
|
||||
alias ymlgrep='progrep --include={"*.yml","*.yaml"}'
|
||||
alias phpgrep='grep -r --include="*.php"'
|
||||
|
||||
# Tmux stuff
|
||||
alias tmux_cheatsheet='nohup $BROWSER https://gist.github.com/MohamedAlaa/2961058 &>>/dev/null &'
|
||||
|
||||
# Make grep colored if it isn't aliased yet
|
||||
if ! alias grep &>>/dev/null; then
|
||||
alias grep='grep --color=auto'
|
||||
fi
|
||||
|
||||
# Do the same for ls
|
||||
if ! alias ls &>>/dev/null; then
|
||||
alias ls='ls --color=auto'
|
||||
fi
|
||||
|
||||
# php stuff
|
||||
alias pserver='php -S localhost:8000 -t'
|
||||
|
||||
# check what the fuck happened in a commit
|
||||
TFH() {
|
||||
if [[ -n $1 ]]; then
|
||||
declare commit="$1"
|
||||
else
|
||||
declare commit="$(git log --oneline | head -n 1)"
|
||||
fi
|
||||
declare prev_commit="$(git log --oneline | grep -A 1 "^${commit:0:7}" | { read && cat; } | grep -m 1 -Po '^\S+')";
|
||||
git diff "$prev_commit" "${commit:0:7}"
|
||||
}
|
||||
|
||||
# php stuff
|
||||
cg() {
|
||||
grep "$1" composer.json
|
||||
}
|
||||
|
||||
debugserver() {
|
||||
sleep 1 && $BROWSER localhost:8888/app_dev.php &
|
||||
XDEBUG_CONFIG='idekey=pugdebug' php -S localhost:8888 -t public
|
||||
}
|
||||
|
||||
executeClass() {
|
||||
declare name="$1"
|
||||
shift
|
||||
javac "$name".java && java -cp ./ "$name" "$@"
|
||||
}
|
||||
|
||||
calc(){
|
||||
echo "scale=4;$*" | bc
|
||||
}
|
||||
|
||||
pathEmacs() {
|
||||
declare -a opener=(workspace run emacs)
|
||||
if [[ "$1" == @(-c|--client) ]]; then
|
||||
opener=(workspace run -detach emacsclient --create-frame --no-wait)
|
||||
shift
|
||||
fi
|
||||
|
||||
declare executable=''
|
||||
executable="$(which "$1")"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "$1 is not in your path, exiting."
|
||||
return
|
||||
fi
|
||||
|
||||
"${opener[@]}" "$executable"
|
||||
}
|
||||
|
||||
_pathEmacs() {
|
||||
declare word="${COMP_WORDS[COMP_CWORD]}"
|
||||
COMPREPLY=($(compgen -c "$word"))
|
||||
}
|
||||
|
||||
_clone() {
|
||||
COMPREPLY=($(compgen -W "$(projects list)" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||
}
|
||||
|
||||
alias pem='pathEmacs'
|
||||
alias pec='pathEmacs -c'
|
||||
|
||||
complete -F _pathEmacs pathEmacs
|
||||
complete -F _pathEmacs pem
|
||||
complete -F _pathEmacs pec
|
||||
complete -F _clone clone
|
||||
complete -F _clone pull
|
||||
complete -F _clone pushdate
|
||||
|
||||
alias p='project'
|
||||
|
||||
listDirs() {
|
||||
ls -1 | while read -r line; do [[ -d "$line" ]] && echo "$line"; done
|
||||
}
|
||||
|
||||
_protonbak() {
|
||||
declare protondir="$HOME/.steam/steam/steamapps/compatdata"
|
||||
|
||||
if [[ -d "$protondir" ]]; then
|
||||
COMPREPLY=($(compgen -W "$(cd ~/.steam/steam/steamapps/compatdata && listDirs)" "$word"))
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2164
|
||||
# A tiny little helper to jump to- and between projects
|
||||
project() {
|
||||
declare proj_dir="$HOME/projects/$1"
|
||||
if [[ -d "$proj_dir" ]]; then
|
||||
if [[ -d "$proj_dir/www" ]]; then
|
||||
cd "$proj_dir/www"
|
||||
else
|
||||
cd "$proj_dir"
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
read -rp "Project folder \"$1\" does not exist. Do you want to create it? (y/n): " ans
|
||||
if [[ "$ans" == [yY] ]]; then
|
||||
mkdir -p "$proj_dir" && cd "$proj_dir"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Complete project names to make jumping between projects that much easier
|
||||
# shellcheck disable=SC2035
|
||||
_project() {
|
||||
declare word="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ "$word" == */* ]]; then
|
||||
declare basename="${word##*/}"
|
||||
declare dir="${word%/*}"
|
||||
if [[ -d ~/projects/"$dir" ]]; then
|
||||
COMPREPLY=($(compgen -P "$dir/" -W "$(cd ~/projects/"$dir" && listDirs)" "$basename"))
|
||||
return
|
||||
fi
|
||||
COMPREPLY=()
|
||||
return
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "$(cd ~/projects && listDirs)" "$word"))
|
||||
}
|
||||
|
||||
complete -o nospace -F _project p
|
||||
complete -o nospace -F _project project
|
||||
complete -o nospace -F _protonbak protonbak
|
||||
|
||||
untrack() {
|
||||
while read -rp 'Link: ' link; do
|
||||
torsocks curl -L -s -I "$link" | grep -i '^location' | sed 's/\?.\+$//g'
|
||||
done
|
||||
}
|
||||
|
||||
if [[ -f "$/WORKSPACE_CONFIG_DIR/environment" ]]; then
|
||||
source "$/WORKSPACE_CONFIG_DIR/environment"
|
||||
fi
|
||||
|
||||
PROMPT_COMMAND='history -a'
|
||||
HISTFILESIZE=10000
|
||||
HISTSIZE=2000
|
||||
|
||||
# Let's make REALLY sure the right editor is selected
|
||||
if command -v emacsclient >/dev/null; then
|
||||
export EDITOR='emacsclient -s ~/.cache/emacs/server --create-frame'
|
||||
elif command -v vim >/dev/null; then
|
||||
export EDITOR='vim'
|
||||
else
|
||||
export EDITOR='vi'
|
||||
fi
|
||||
|
||||
if command -v gnome-keyring-daemon &>>/dev/null; then
|
||||
eval `gnome-keyring-daemon --start --components=ssh,secrets`
|
||||
fi
|
||||
|
||||
# Readline options
|
||||
if [ -t 1 ] && [[ -z "$ALIAS_NONINTERACTIVE" ]]; then
|
||||
bind 'set show-all-if-ambiguous on'
|
||||
bind 'set colored-stats on'
|
||||
bind 'set colored-completion-prefix on'
|
||||
bind 'TAB:menu-complete'
|
||||
fi
|
||||
|
||||
if [[ -f ~/perl5/perlbrew/etc/bashrc ]]; then
|
||||
source ~/perl5/perlbrew/etc/bashrc
|
||||
fi
|
||||
|
||||
if [[ -f ~/projects/phpns/scripts/phpns_env.bash ]]; then
|
||||
pushd ~/projects/phpns &>/dev/null
|
||||
source ~/projects/phpns/scripts/phpns_env.bash
|
||||
popd &>/dev/null
|
||||
fi
|
||||
|
||||
|
||||
# Fancy pretty prompt
|
||||
declare -gx PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u \e[1;31mat\e[1;32m \h${WORKSPACE_USER:+ \e[1;31mrunning \e[1;32mworkspace}\[\033[00m\] \e[1;31min\e[1;32m \[\033[01;93m\]\w\[\033[00m\] \n\$: '
|
||||
|
||||
# Give emacs a hand by making the prompt standard
|
||||
if [[ -n $INSIDE_EMACS ]]; then
|
||||
unset PROMPT_COMMAND
|
||||
declare -gx PS1='\[\033[01;32m\]\u \e[1;31mat\e[1;32m \h\[\033[00m\] \e[1;31min\e[1;32m \[\033[01;93m\]\w\[\033[00m\] \n\$: '
|
||||
|
||||
alias ec='emacsclient'
|
||||
elif [[ $TERM == 'dumb' ]]; then
|
||||
export PS1='> '
|
||||
fi
|
||||
|
||||
# Tell everyone that bash_aliases was sourced!
|
||||
declare -g ALIASES_WERE_SOURCED='true'
|
Loading…
Reference in New Issue