This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/shell/aliases

155 lines
4.6 KiB
Text
Raw Normal View History

2017-02-07 16:16:45 -06:00
#!/usr/bin/env bash
# set our needed variables if we don't already have them
if [[ -z "$XDG_CONFIG_HOME" ]]; then
export XDG_CONFIG_HOME="$HOME/.config"
2017-02-07 16:16:45 -06:00
fi
if [[ -z "$DOTFILES_PATH" ]]; then
export DOTFILES_PATH="$XDG_CONFIG_HOME/dotfiles"
2017-02-07 16:16:45 -06:00
fi
# filesystem aliases
alias lx='ls -lXB' # order by filetype
alias lk='ls -lSr' # order by filesize reversed
alias lt='ls -ltr' # order by file modified time
alias lc='ls -ltcr' # order by filectime
alias lu='ls -ltur' # order by file access time
alias ls='ls -h --color --group-directories-first' # flat view w/ directories first
alias l='ls -h --color --group-directories-first' # same as above
alias ll='ls -lv --group-directories-first' # non-flat view
alias lm='ll | more'
alias lr='ll -R' # please don't - why is this even here...?
alias la='ll -A' # show all
alias tree='tree -Csuh'
2018-08-31 09:27:45 -05:00
alias f='fzf'
2018-09-25 21:32:34 -05:00
alias cp="rsync -ah --progress"
2017-02-07 16:16:45 -06:00
# navigation aliases
2018-08-09 09:40:14 -05:00
function c() {
if [[ -n $1 ]]; then
cd "${NICE_HOME}" || exit 1
else
cd "${NICE_HOME}" && cd "${1}" || exit 1
2018-08-09 09:40:14 -05:00
fi
}
2017-02-07 16:16:45 -06:00
alias cd..="cd .."
alias cdd="cd \"\$DOTFILES_PATH\"" # go to dotfiles
alias cdc="cd \"\$XDG_CONFIG_HOME\"" # go to
2018-11-03 14:17:39 -05:00
alias cdn="cd \"\$NOTES_PATH\""
2018-11-05 15:55:52 -06:00
alias nsync="cd \"\$NOTES_PATH\"; git add -A; git commit -m Updates; git pull && git push; cd -"
2017-02-07 16:16:45 -06:00
2018-08-09 09:40:14 -05:00
function cdp() {
cd "$(dirname "$(fzf)")" || return
}
2017-02-07 16:16:45 -06:00
# quick parent-directory aliases
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias .......="cd ../../../../../.."
alias ........="cd ../../../../../../.."
alias .........="cd ../../../../../../../.."
# tmux aliases
# TODO: see if this can be worked around?
alias tmux='TERM=screen-256color-bce tmux' # syntax higlighting for vim in tmux
alias tmnew="tmux new -s"
alias tmls="tmux list-sessions"
alias tmatt="tmux attach -t"
alias tu="tmux attach -t utils || tmux new -s utils"
alias tdf="tmux attach -t dotfiles || tmux new -s dotfiles -c \"\$DOTFILES_PATH\""
alias tmon="tmux attach -t monitoring || tmux new -s monitoring"
alias tcom="tmux attach -t comms || tmux new -s comms"
2017-02-07 16:16:45 -06:00
# git aliases
# TODO: make these git aliases in the gitconfig?
alias g="git"
2017-02-07 16:16:45 -06:00
alias gs="git status"
alias gpl="git pull"
2018-10-31 14:40:57 -05:00
alias gp="git push"
alias gpa="git push --all && git push --tags"
2017-07-31 13:47:23 -05:00
alias grbpf="git push --force-with-lease"
alias gac="git add -A && git commit"
alias gsur="git submodule update --remote"
2018-08-31 09:27:45 -05:00
alias glf="git ls-files"
2018-08-25 01:44:32 -05:00
alias gl="git log --graph --pretty=oneline --abbrev-commit --decorate"
2017-02-07 16:16:45 -06:00
2017-07-18 12:11:39 -05:00
grb() {
MAIN_BRANCH="master"
CUR_BRANCH="$(git branch | grep '\*' | cut -d ' ' -f2-)"
2017-07-18 12:11:39 -05:00
if [[ ! -z ${2+x} ]]; then
MAIN_BRANCH="$2"
CUR_BRANCH="$1"
elif [[ ! -z ${1+x} ]]; then
MAIN_BRANCH="$1"
fi
git rebase -i "$(git merge-base "$CUR_BRANCH" "$MAIN_BRANCH")"
2017-07-18 12:11:39 -05:00
}
# DEPRECATED: we use network manager (nmtui/nmcli) now
2017-02-07 16:16:45 -06:00
# start netctl using any available profile on the first wireless network
# interface
# TODO: flesh this out into a function that lets the user know what's going on.
#alias wifi="sudo systemctl start netctl-auto@$(for wli in /sys/class/net/wl*; do echo $(basename $wli); break; done)"
2017-02-07 16:16:45 -06:00
# misc aliases
2018-08-09 09:40:14 -05:00
alias qute="qutebrowser --backend webengine"
alias p="ping 8.8.8.8"
2017-02-07 16:16:45 -06:00
alias setbg="feh --bg-fill"
2017-04-25 07:59:41 -05:00
alias C="clear && clear"
2017-02-07 16:16:45 -06:00
alias keyrepeat="xset r rate 250 80"
alias r="ranger"
alias sctl="sudo systemctl"
alias btctl="sudo bluetoothctl"
alias pt="htop -t" # experimental htop tree-view-by-default
alias resrc="source \$HOME/.bashrc"
2018-11-03 14:05:58 -05:00
alias redshift="redshift -r -l 39.0997:-94.5786 -t 6500K:2500K"
alias gpmdpe="electron --app=/usr/share/gpmdp/resources/app.asar"
alias t="task"
export NOTES_DIR="$NICE_HOME"
2017-02-07 16:16:45 -06:00
# games aliases
# this sometimes fixes steam dynamic library issues?
# alias steam="LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1 /usr/$LIB/libxcb.so.1 /usr/$LIB/libgpg-error.so' steam"
# text editor aliases
# man pages with vim
vman() {
# our vim config is setup to not auto-load sessions if we set the
# `asmanviewer` variable, so launch vim that way when using vim as our man
# page viewer
2017-02-07 16:16:45 -06:00
if command -v nvim >/dev/null 2>&1; then
nvim --cmd "let asmanviewer=1" -c "SuperMan $*"
else
vim --cmd "let asmanviewer=1" -c "SuperMan $*"
fi
# proper error handling
2017-02-07 16:16:45 -06:00
if [ "$?" != "0" ]; then
echo "No manual entry for $*"
fi
}
# override the man commands
alias _man="\\man"
alias man="vman"
# set our EDITOR to neovim if we've got it
export EDITOR="vim"
if command -v nvim >/dev/null 2>&1; then
alias vim="nvim"
alias ovim="\\vim"
export EDITOR="nvim"
fi
2018-10-31 14:40:57 -05:00
export BROWSER="firefox"
2017-03-13 08:58:30 -05:00
2017-02-07 16:16:45 -06:00
# arch aliases
# TODO: load os-specific aliases based on running OS
alias archupdate="pacaur -Syyu --noconfirm --noedit"