User avatar
craigevil
Posts: 210
Joined: Wed Jan 27, 2021 5:22 am
Location: OZ

Share Your BASH Aliases

Mon May 03, 2021 10:08 am

Here is what my bash_aliases file looks like:

Code: Select all

# Start gomuks Matrix Client
alias gomuks=/home/pi/Downloads/gomuks-linux-arm64

# Show open ports
alias ports='netstat -tulanp'

# Refresh .bashrc
alias bashrc="nano ~/.bashrc && source ~/.bashrc"

# become root #
alias root='sudo -i'
alias su='sudo -i'

# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
    alias update='sudo apt update'
    alias ainstall='sudo apt install'
    alias apurge='sudo apt purge'
    alias upgrade='sudo apt upgrade'
    alias aremove='sudo apt autoremove -y'
    alias reboot='sudo reboot'
    alias shutdown="sudo shutdown -P now"
fi

# APT User Commands
alias asearch='apt search'
alias afile='apt-file search'
alias apolicy='apt policy'

# Create Python virtual environment
alias ve='python3 -m venv ./venv'
alias va='source ./venv/bin/activate'

# Ping Commands
# Stop after sending count ECHO_REQUEST packets #
alias ping='ping -c 5'
alias pg="ping google.com -c 5"

## set some other defaults ##
alias df='df -H'
alias du='du -ch'

# ls Commands
## Colorize the ls output and human readable sizes ##
alias ls='ls --color=auto --human-readable -al' 
 
## Use a long listing format ##
alias ll='ls -la'
 
## Show hidden files ##
alias l.='ls -d .* --color=auto'

# Clipboard
alias cpy="xclip -selection clipboard"

# Calculator
alias bc="bc -l"

# Resume wget by default
alias wget="wget -c"

# ps Commands
alias ps="ps auxf"
# Get top process eating cpu
alias pscpu="ps auxf | sort -nr -k 3"
alias pscpu10="ps auxf | sort -nr -k 3 | head -10"

# Get top process eating memory
alias psmem="ps auxf | sort -nr -k 4"
alias psmem10="ps auxf | sort -nr -k 4 | head -10"

# Free and Used Ram
alias meminfo="free -m -l -t"
alias free="free -mt"
Raspberry PI 400 Raspberry Pi OS (Unstable) Kernel: 5.10.17-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"

User avatar
kerry_s
Posts: 2113
Joined: Thu Jan 30, 2020 7:14 pm

Re: Share Your BASH Aliases

Mon May 03, 2021 10:45 am

Code: Select all

# alias shotrcuts
alias raspi="sudo raspi-config"
alias clr="clear"
alias clrh="history -c -w ~/.bash_history"
alias hg="history | grep"
alias rpi4="ssh pi@192.168.0.9"
alias ll="ls -l"
alias x="exit"

# apt aliases
alias upd="sudo apt update && sudo apt -y full-upgrade && sudo apt -y autoremove && sudo apt clean"
alias ins="sudo apt install"
alias del="sudo apt purge -y --autoremove"
alias srch="apt search"
alias lst="apt list | grep"
alias show="apt show"


User avatar
RaspbianUser1
Posts: 841
Joined: Thu Mar 05, 2020 6:34 pm
Location: ~/

Re: Share Your BASH Aliases

Sat May 08, 2021 1:20 pm

kerry_s wrote:
Mon May 03, 2021 10:45 am

Code: Select all

# alias shotrcuts
alias raspi="sudo raspi-config"
alias clr="clear"
alias clrh="history -c -w ~/.bash_history"
alias hg="history | grep"
alias rpi4="ssh pi@192.168.0.9"
alias ll="ls -l"
alias x="exit"

# apt aliases
alias upd="sudo apt update && sudo apt -y full-upgrade && sudo apt -y autoremove && sudo apt clean"
alias ins="sudo apt install"
alias del="sudo apt purge -y --autoremove"
alias srch="apt search"
alias lst="apt list | grep"
alias show="apt show"

a clr user rather than cls, also you can save a few bytes, single worded commands don't need to be in " "

see
alias cls=clear
Running with a Raspberry Pi 4B 4GB with Raspberry Pi OS with MATE Desktop
Why not overclock, push some more performance out of your computer!
Think before you delete something a stranger on the internet told you to.

User avatar
RaspbianUser1
Posts: 841
Joined: Thu Mar 05, 2020 6:34 pm
Location: ~/

Re: Share Your BASH Aliases

Sat May 08, 2021 1:22 pm

craigevil wrote:
Mon May 03, 2021 10:08 am
Here is what my bash_aliases file looks like:

Code: Select all

# Start gomuks Matrix Client
alias gomuks=/home/pi/Downloads/gomuks-linux-arm64
[/quote]
why don't you move the binary to /usr/bin?
Running with a Raspberry Pi 4B 4GB with Raspberry Pi OS with MATE Desktop
Why not overclock, push some more performance out of your computer!
Think before you delete something a stranger on the internet told you to.

User avatar
kerry_s
Posts: 2113
Joined: Thu Jan 30, 2020 7:14 pm

Re: Share Your BASH Aliases

Sat May 08, 2021 1:30 pm

RaspbianUser1 wrote:
Sat May 08, 2021 1:20 pm
kerry_s wrote:
Mon May 03, 2021 10:45 am

Code: Select all

# alias shotrcuts
alias raspi="sudo raspi-config"
alias clr="clear"
alias clrh="history -c -w ~/.bash_history"
alias hg="history | grep"
alias rpi4="ssh pi@192.168.0.9"
alias ll="ls -l"
alias x="exit"

# apt aliases
alias upd="sudo apt update && sudo apt -y full-upgrade && sudo apt -y autoremove && sudo apt clean"
alias ins="sudo apt install"
alias del="sudo apt purge -y --autoremove"
alias srch="apt search"
alias lst="apt list | grep"
alias show="apt show"

a clr user rather than cls, also you can save a few bytes, single worded commands don't need to be in " "

see
alias cls=clear
you can do that.
mines setup so i can remember. then i just change parts for the os i'm on, for example manjaro(arch).

Code: Select all

PATH="$HOME/bin:$PATH"

# alias shortcuts
alias clr="clear"
alias clrh="history -c -w ~/.bash_history"
alias hg="history | grep"
alias rpi4="ssh pi@192.168.0.9"
alias ll="ls -l"
alias x="exit"

# pacman
alias upd="sudo pacman -Syu"
alias ins="sudo pacman -S"
alias srch="pacman -Ss"
alias show="pacman -Si"
alias del="sudo pacman -R"


User avatar
RaspbianUser1
Posts: 841
Joined: Thu Mar 05, 2020 6:34 pm
Location: ~/

Re: Share Your BASH Aliases

Sat May 08, 2021 1:38 pm

How do you get aliases to work on arch, I have tried but the .bash_aliases file didn't seem to work. I think I remember them working in bashrc however.

If the answer is easy, my reasoning is I didn't care to look
Running with a Raspberry Pi 4B 4GB with Raspberry Pi OS with MATE Desktop
Why not overclock, push some more performance out of your computer!
Think before you delete something a stranger on the internet told you to.

User avatar
kerry_s
Posts: 2113
Joined: Thu Jan 30, 2020 7:14 pm

Re: Share Your BASH Aliases

Sat May 08, 2021 1:43 pm

RaspbianUser1 wrote:
Sat May 08, 2021 1:38 pm
How do you get aliases to work on arch, I have tried but the .bash_aliases file didn't seem to work. I think I remember them working in bashrc however.

If the answer is easy, my reasoning is I didn't care to look
Attachments
Screenshot_2021-05-08_03-42-35.png
Screenshot_2021-05-08_03-42-35.png (55.91 KiB) Viewed 1077 times

User avatar
scruss
Posts: 4109
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Share Your BASH Aliases

Sat May 08, 2021 2:22 pm

RaspbianUser1 wrote:
Sat May 08, 2021 1:22 pm
why don't you move the binary to /usr/bin?
Or create the folder ~/bin and move it there. $HOME/bin is added to your PATH if it exists after the next login/reboot.

The only two that I have that I haven't seen replicated here:

Code: Select all

alias ruler='echo -e "00000000011111111112222222222333333333344444444445555555555666666666677777777778\n12345678901234567890123456789012345678901234567890123456789012345678901234567890"'
so I can find the column argument for cut, etc (contrived example follows)

Code: Select all

ruler ; md5sum random1e6-0.txt
00000000011111111112222222222333333333344444444445555555555666666666677777777778
12345678901234567890123456789012345678901234567890123456789012345678901234567890
eb49f2c3ff91a9effa0febdd803f2522  random1e6-0.txt

md5sum random1e6-0.txt | cut --characters=35-
random1e6-0.txt
Some folks might use terminals wider than 80 characters. I think there's a way to query that with escape codes and craft a ruler of the right length, but that would need a bash function. (And yes, I know about cutting columns with awk, before anyone gets all butbutbut)

Code: Select all

alias pbpaste='xclip -o -selection clipboard -t UTF8_STRING'
As close as I could get to the Mac OS command pbpaste: pastes the clipboard into the terminal, for transforming short runs of text, such as pbpaste | sed 's/^/ /' for turning text into Markdown preformatted text. You'll need to install xclip (sudo apt install xclip).
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
jahboater
Posts: 7080
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Share Your BASH Aliases

Sat May 08, 2021 3:59 pm

Note that the "ls" ones are already in ~/.bashrc, you just have to uncomment them.

alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

User avatar
kerry_s
Posts: 2113
Joined: Thu Jan 30, 2020 7:14 pm

Re: Share Your BASH Aliases

Sat May 08, 2021 4:05 pm

jahboater wrote:
Sat May 08, 2021 3:59 pm
Note that the "ls" ones are already in ~/.bashrc, you just have to uncomment them.

alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
i know, but i keep .bash_aliases so i can just copy it over & go.
also not all distros have a complete .bashrc, look at my pic, that is all arch has in the bashrc, minus my little source entry.

User avatar
jahboater
Posts: 7080
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Share Your BASH Aliases

Sun May 09, 2021 12:00 am

Here are a few:

Code: Select all

alias p=python3
alias nmap='sudo nmap -sn 192.168.0.0/24'
alias m=make
alias v=valgrind 
alias free='free -h' 
alias d='diff -spd'
alias pi='ssh pi@pi' 
alias pi32='ssh pi@pi32' 
alias lz='lzip -k -m272 -s256MiB'
alias td=timedatectl
alias t=touch                                
alias getlite='wget --trust-server-names https://downloads.raspberrypi.org/raspbian_lite_latest'
alias def=e4defrag 
alias cc=gcc
alias cp='cp -iv'
alias du='du -sh'

MiscBits
Posts: 249
Joined: Wed Jan 27, 2021 12:48 pm

Re: Share Your BASH Aliases

Sun May 09, 2021 1:46 am

Very old habits die hard:

Code: Select all

alias 90=logout
Anyone else recognise the alias?
Is a computer language with goto's totally Wirth-less?

User avatar
rpdom
Posts: 18742
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Share Your BASH Aliases

Sun May 09, 2021 6:32 am

MiscBits wrote:
Sun May 09, 2021 1:46 am
Very old habits die hard:

Code: Select all

alias 90=logout
Anyone else recognise the alias?
Shouldn't that be *90# ?
Unreadable squiggle

swampdog
Posts: 698
Joined: Fri Dec 04, 2015 11:22 am

Re: Share Your BASH Aliases

Sun May 09, 2021 3:45 pm

There's a pair I use a lot..

Code: Select all

alias po='popd 1>/dev/null'
alias pu='pushd 1>/dev/null'
I don't have so many these days. They tend to get migrated into scripts. One which I accidentally type a lot on forums here (and forget to explain) is 'dfh'..

Code: Select all

foo@pi18:~ $ cat /usr/local/sd/bin/dfh
#!/bin/bash

df -hP | \
 egrep "(^/dev/|:/)" | \
 sed -e 's,^/dev/mapper/,,' | \
 sed -e 's,^/dev/,,' | \
 column -t | \
 sort
[code]

MiscBits
Posts: 249
Joined: Wed Jan 27, 2021 12:48 pm

Re: Share Your BASH Aliases

Sun May 09, 2021 4:12 pm

rpdom wrote:
Sun May 09, 2021 6:32 am
MiscBits wrote:
Sun May 09, 2021 1:46 am
Very old habits die hard:

Code: Select all

alias 90=logout
Anyone else recognise the alias?
Shouldn't that be *90# ?
That looks like a phone command - the 'standard' for AS/400 menus was to have option 90 as the log off option. Stuck with me despite not using one for many many many years.
Is a computer language with goto's totally Wirth-less?

bls
Posts: 1486
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Share Your BASH Aliases

Sun May 09, 2021 6:55 pm

Here's a few handy ones from my .bashrc

Code: Select all

#
# Do a continuous ping and preface each line with the date/time
#
alias pong='pong_() { ping -c ${2:-4096} $1 | while read pong; do echo "$(date +%Y-%m-%d:%H:%M:%S)  $pong"; done ;} ; pong_ $*'
#
# similar to pong, but prefaces each line of output from a command with the date/time
# A full date/time is printed before and after the command is run
#
alias pdate='echo $(date +"%Y-%m-%d %H:%M:%S.%N")'
alias tstamp='tstamp_() { pdate ; $* 2>&1 | while read ts; do echo "$(date +"%Y-%m-%d %H:%M:%S")  $ts"; done ; pdate ;} ; tstamp_ $*'
#
# Get weather on your terminal. Change 'seattle' to your location!
#
alias whelp="\"\$(curl -s https://wttr.in/:help)\""
alias weather='wt_() { local s=${1:-seattle} ; curl -s wttr.in/$s?T ; } ; wt_ $*'
alias wtemp='wtmp_() { local s=${1:-seattle} ; echo $(curl -s wttr.in/$s?format=%t) ; } ; wtmp_ $*'
#
# Handy-dandy aliases for journalctl and systemctl
#
alias jc='sudo journalctl -b'
alias jca='sudo journalctl'
alias jcf='sudo journalctl -f'
alias jcr='sudo journalctl --list-boots'
alias sc='sudo systemctl'
# 
# Set terminal colors. Works with xterm and some other terminal apps. Have not tested lxterminal
# example: xtset fg yellow bg black cursor green
#
function xtset() {
    #
    # set xterm color. can specify 3 sets of pairs (e.g., fg yellow bg black cursor red)
    # $1=fg|bg|cursor
    # $2=color to set
    # Colors are listed in /etc/X11/rgb.txt (or /usr/share/X11/rgb.txt)
    #
    function xtsetx() {
        case "$1" in
            fg) printf "\e]10;${2}\a"
                ;;
            bg) printf "\e]11;${2}\a"
                ;;
            cur*) printf "\e]12;${2}\a"
                  ;;
            *) echo "Usage: xtset fg|bg|cur*sor color..."
               ;;
        esac
    }
    [ "$1" == "reset" ] && xtsetx fg black && xtsetx bg white && return
    [ "$1" != "" ] && xtsetx "$1" "$2"
    [ "$3" != "" ] && xtsetx "$3" "$4"
    [ "$5" != "" ] && xtsetx "$5" "$6"
} ; declare -fx xtset
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

User avatar
rpdom
Posts: 18742
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Share Your BASH Aliases

Sun May 09, 2021 7:11 pm

MiscBits wrote:
Sun May 09, 2021 4:12 pm
rpdom wrote:
Sun May 09, 2021 6:32 am
MiscBits wrote:
Sun May 09, 2021 1:46 am
Very old habits die hard:

Code: Select all

alias 90=logout
Anyone else recognise the alias?
Shouldn't that be *90# ?
That looks like a phone command - the 'standard' for AS/400 menus was to have option 90 as the log off option. Stuck with me despite not using one for many many many years.
I was thinking Prestel/viewdata systems. SOmething I worked on for quite a few years. Some of it using Richard Russell;s BBC Basic or early PC and the RM Nimbus version.
Unreadable squiggle

MiscBits
Posts: 249
Joined: Wed Jan 27, 2021 12:48 pm

Re: Share Your BASH Aliases

Mon May 10, 2021 1:44 pm

rpdom wrote:
Sun May 09, 2021 7:11 pm
...
I was thinking Prestel/viewdata systems. SOmething I worked on for quite a few years. Some of it using Richard Russell;s BBC Basic or early PC and the RM Nimbus version.
That's two names I have not heard in a few years - I spent a fair bit of time with the BBC wedges and set up a 'notice board' system using those nice block graphics (not)! Wonder how many folk know the BBC 'red button' system currently in use dates from those times...

I thought pages started at 100 and above - but that could have been CEEFAX.

For the younger folk going - what / who ??? - please visit the museum here :D

Thanks for the memory :-)
Is a computer language with goto's totally Wirth-less?

User avatar
rpdom
Posts: 18742
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Share Your BASH Aliases

Mon May 10, 2021 2:16 pm

MiscBits wrote:
Mon May 10, 2021 1:44 pm
That's two names I have not heard in a few years - I spent a fair bit of time with the BBC wedges and set up a 'notice board' system using those nice block graphics (not)! Wonder how many folk know the BBC 'red button' system currently in use dates from those times...

I thought pages started at 100 and above - but that could have been CEEFAX.
Yep, that was Ceefax/Oracle. Viewdata and Prestel pages started with page 0 (actually 0a) which was the default "front" page. I've still got a snapshot of the system I used to run on a BBC Micro at home, along with some of the source code for the system I used.
Unreadable squiggle

Return to “Off topic discussion”