AstonJ

AstonJ

Inspired by @JoeZMar’s post, what shortcuts or other goodies do you have in your .bash_profile?

Showing Posts 1 to 10

AstonJ

AstonJ OP

I am a sucker for shortcuts, so have just added these:

alias mixec="mix ecto.create"
alias mixem="mix ecto.migrate"
alias mixps="mix phx.server"
alias iexmixps="iex -S mix phx.server"
alias iexsmix="iex -S mix"
alias iexs="iex -S mix"
alias mixpr="mix phx.routes"

I also have various others, such as:

PS1="[\W]\$ "
alias ll="ls -lahG"

alias code="cd /Users/Aston/projects/code"
alias home="cd /Users/Aston"
alias oss="cd /Users/Aston/projects/oss"
alias desktop="cd /Users/Aston/desktop"
alias some_project_name="cd /Users/Aston/projects/code/some_project_name"

alias showhidden="defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder"
alias hidehidden="defaults write com.apple.finder AppleShowAllFiles -boolean false ; killall Finder"

vscode () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

Plus various others to shh to a server, upload/download files to/from a server, push certain scripts or rsync sites etc

connorlay

connorlay

Here is one I recently stumbled upon in the documentation for IEx:

export ERL_AFLAGS='-kernel shell_history enabled'

This enables IEx shell history between sessions.

11
Post #2
NobbZ

NobbZ

Well, the most basic improvement is to get rid of bash and use zsh instead :wink:

My alias list is pretty much the default, only replacing ls by k.

Also I do have emacs, emats and emax as aliases to emacsclient to choose graphical/terminal mode automatically in the first or manually with the latter two. I wrote once about my emacs deamon setup in a blog post of mine and made my emacs config public.

I can’t publish the remainder of my dotfiles though, as the repository contains some secrets, I need to distribute in another way before publishing it again.

Qqwy

Qqwy

TypeCheck Core Team

This is amazing! I’ve taken two minutes to perform the steps from your blog post, and already made up for them now, because of the near-instant loading of (Spac)emacs now. :smile:

NobbZ

NobbZ

Be aware though, that it now does only check for updates on reboot, manual restart using systemctl or when using M-x whatever-spacemacs-invokes-to-check-for-update. I’m not even sure if you can interact with spacemacs in the way necessary to confirm or deny an update.

Please take care of this in your surrounding configuration.

axelclark

axelclark

Here’s some of what I have:

#Elixir Phoenix
alias mps="mix phx.server"
alias ism="iex -S mix"
alias mt="mix test"
alias mts="mix test --stale"
alias mec="mix ecto.create"
alias mem="mix ecto.migrate"

#Git
alias gri="git rebase -i origin/master"
alias grif="git commit -am 'f' && git rebase -i origin/master"
alias gpf="git push origin $(git branch) --force-with-lease"
alias gs="git status"

#Vim
alias rmntl="find . -name '*Netrw*' -exec rm -f {} \;"

# display current git branch
parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

# Customize prompt to show only working directory and git branch.
export PS1="[\W]\[\033[34m\]\$(parse_git_branch)\[\033[00m\] $ "
adrianrl

adrianrl

Most of the time I use plugins from Sublime Text or Neovim to interact with Git, but here are a few aliases and functions. :sweat_smile:

# Aliases
alias nv="nvim"

alias g="git"
alias ga="git add"
alias gaa="git add --all"
alias gb="git branch"
alias gc="git commit -m"
alias gca="git commit -a -m"
alias gcl="git clean -fd"
alias gcm="git checkout master"
alias gco="git checkout"
alias gcp="git cherry-pick"
alias gd="git diff"
alias gfo="git fetch origin"
alias ggpull="git pull origin $(git_current_branch)"
alias ggpush="git push origin $(git_current_branch)"
alias ghh="git help"
alias gl="git log"
alias gm="git merge"
alias gmom="git merge origin/master"
alias gp="git push"
alias gr="git reset"
alias grb="git rebase"
alias grh="git reset --hard"
alias gst="git status"
alias nah="git reset --hard && git clean -df"

alias mr="mix run"
alias mt="mix test"
alias ism="iex -S mix"
alias mdc="mix deps.clean"
alias mdg="mix deps.get"
alias mec="mix ecto.create"
alias mer="mix ecto.reset"
alias mes="mix ecto.setup"
alias mpr="mix phx.routes"
alias mps="mix phx.server"

# Functions
function zshconfig {
    nvim ~/.zshrc
    source ~/.zshrc
    echo "ZSH config was reloaded."
}

function gclone {
    git clone "https://github.com/${2:-$(whoami)}/$1.git"
}

function ginit {
    git init
    git add --all
    git commit -m ${1:-"Init repo"}
}
jchrist

jchrist

Oh lord, this one is a mess. I’ve went and added a bunch of comments so it’s not entirely horrible to read through.

#
# ~/.bash_profile
#

# Save working directory after cd-ing so I can hop back into
# the same working directory on login (see `~/.bash_login` in a bit).
function cd {
    builtin cd "$@"
    pwd > ~/.bash_lastcwd
}

__prompt_command() {
    if [[ $? -eq 0 ]]; then
        # On success of the last command, paint the `$` green.
        local colour="32"
    else
        # On error, paint it red.
        local colour="31"
    fi

    # If `.python-version` exists in the current working directory, show the Python version in the
    # prompt. This uses pyenv: https://github.com/pyenv/pyenv
    if [[ -e .python-version ]]; then
        local additional=' via \[\e[33m\]'"$(<.python-version)"' \[\e[0m\]'
    fi
    PS1='\n\w'"$additional"'\n\[\e['"$colour"'m\]$ \[\e[0m\]'
}


export PROMPT_COMMAND=__prompt_command

# Rust tools
export PATH="$HOME/.cargo/bin:$PATH"
# Custom binaries
export PATH="$PATH:~/.bin"
# Up-to-date coreutils to override Mac's builtin coreutils
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
# Up-to-date manpages for coreutils from above
export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
# Probably some dumb experiments
export SSH_ASKPASS="/usr/local/bin/ssh-askpass"
# load z: https://github.com/rupa/z
source /usr/local/etc/profile.d/z.sh
# load hub: https://github.com/github/hub
source ~/.bash_complete/hub.sh
# setup my borg repository for backups
export BORG_REPO='borgbackup@192.168.0.241:/media/borgbackup/mac/main'
# along with non-interactive passphrase retrieval
export BORG_PASSCOMMAND='pass rpi_borg'
# no idea what these two do again
export HISTSIZE=
export HISTFILESIZE=1000000

# I am one lazy guy
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# I think this fixed some `gpg` issues at some point
export GPG_TTY=$(tty)
# Database URL for a command-line collaborative issue tracker I'm building
export TM_DATABASE_URL=postgres://Johannes:@localhost/tm

# Setup hub
eval "$(hub alias -s)"

# ??
. ~/.bash_completion

# load the login prompt (see below)
source ~/.bash_login
# custom `vi` and `vim` with no config for quick editing in `git` an others
source ~/.bash_aliases
# pyenv setup (copied from the repo I believe)
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

export LANG=en_US.UTF-8
# load z again (???)
. /usr/local/etc/profile.d/z.sh

I feel like you can learn some software development lessons from this one :smile:
Here’s my accompanying ~/.bash_login, basically just checks some birthday tracker thing I wrote (to learn Rust) for whose birthday it is and displays a random quote from fortune.

rusday dashboard
fortune | cowsay

Hey, this one’s clean at least.

Also @AstonJ, seeing your aliases for moving around, you might want to take a look at z - it’s a huge timesaver for me for this common cd-ing around :smile:

AstonJ

AstonJ OP

I’m glad I started this thread now - definitely pinching stuff from it :lol:

:003:

Thanks, I will check it out :023: Usually tho, I use those at a start of a session and tend to keep windows per project with multiple tabs (so one main one in the project directory, another for iex and another for phx.server of that project, etc)

mkunikow

mkunikow

Nothing better than good mechanical keyboard and and shell :smiley:
This is why I :heart: Linux
My shell

My nice commands replacement
https://github.com/sharkdp/bat
https://github.com/Peltoche/lsd

https://github.com/junegunn/fzf
https://github.com/sharkdp/fd

Something to inspire
https://github.com/alebcay/awesome-shell
https://github.com/jorgebucaran/awesome-fish

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
maennchen
:warning: Security advisory: Decimal DoS vulnerability A vulnerability has been published for decimal where very large exponents can cau...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews