-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_profile
102 lines (83 loc) · 2.89 KB
/
.bash_profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/bash
# This tells shellcheck that this file is located in the home directory
# See: https://github.com/koalaman/shellcheck/wiki/SC1090
# shellcheck source=~
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
# If available, view current git branch in terminal
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]$ "
# SSH_ENV="$HOME/.ssh/environment"
# Commented out in favor of the below commands
# I think this was the predecessor?
# SSH_ENV="$HOME/.ssh/environment"
#
# function start_agent {
# echo "Initialising new SSH agent..."
# /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
# echo succeeded
# chmod 600 "${SSH_ENV}"
# . "${SSH_ENV}" > /dev/null
# /usr/bin/ssh-add;
# }
#
# # Source SSH settings, if applicable
#
# if [ -f "${SSH_ENV}" ]; then
# . "${SSH_ENV}" > /dev/null
# #ps ${SSH_AGENT_PID} doesn't work under cywgin
# ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
# start_agent;
# }
# else
# start_agent;
# fi
# Used to automatically start the ssh-agent when a terminal loads
env=~/.ssh/agent.env
# Load ssh-agent environment variables
agent_load_env() {
test -f "$env" && . "$env" >| /dev/null ;
}
# Actually start the ssh-agent
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ;
}
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! "$SSH_AUTH_SOCK" ] || [ "$agent_run_state" = 2 ]; then
agent_start
fi
# Note: This will raise print something that looks like an error if no `rsa` or `ed25519` keys are found.
# It doesn't stop execution of this file, unless you set an error bit.
ssh-add ~/.ssh/*_rsa
ssh-add ~/.ssh/*_ed25519
unset env
# Git stuff from @jsleeper; if it breaks call him
alias ga='git add'
alias gb='git branch'
alias gbd='git branch -D'
alias gcan='git commit --amend --no-edit'
alias gcl='git clean -ffxd'
alias gcm='git commit --message'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gd='git diff --ws-error-highlight=all'
alias gdc='git diff --ws-error-highlight=all --cached'
alias gdcp='git diff --patience --ws-error-highlight=all --cached'
alias gdp='git diff --patience --ws-error-highlight=all'
alias gf='git fetch --prune'
alias gfp='git fetch --prune && git pull --rebase --autostash'
alias glg='git log --oneline --graph --all --decorate'
alias gp='git push --set-upstream origin HEAD'
alias grh='git reset --hard @{u}'
alias gs='git status'
# General aliasses
alias repos='cd ~/Documents/repos'
alias reload='source ~/.bash_profile && source ~/.bashrc'
function cdl () { cd "$@" && ls; }
function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
function rename () { for i in $1*; do mv "$i" "${i/$1/$2}"; done; }