Commands tagged bashrc (15)

  • You need to have fortune and cowsay installed. It uses a subshell to list cow files in you cow directory (this folder is default for debian based systems, others might use another folder). you can add it to your .bashrc file to have it great you with something interesting every time you start a new session. Show Sample Output


    10
    fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
    zed · 2010-07-08 02:57:52 8
  • * Add comment with # in your command * Later you can search that command on that comment with CTRL+R In the title command, you could search it later by invoking the command search tool by first typing CTRL+R and then typing "revert" Show Sample Output


    1
    svn up -r PREV # revert
    unixmonkey10719 · 2010-07-07 23:09:00 16
  • Makes bash-4.x like zsh. Automatic cd into a directory if a command with that name doesnt exists. Ready for your ~/.bashrc file Show Sample Output


    1
    shopt -s autocd
    xeor · 2010-12-12 20:53:33 3
  • This is useful if you use a shell with a lot of other users. You will be able to run "topu" to see your running processes instead of the complete 'top -u username'. Read more on alias: http://man.cx/alias


    1
    echo "alias topu='top -u USERNAME'" >> ~/.bash_aliases && source .bashrc
    TheLugal · 2011-07-07 08:24:06 3

  • 1
    echo 'export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"' >> .bashrc
    qdrizh · 2015-03-09 19:57:56 8
  • If you have a lot of hosts in /etc/hosts this would be very useful. Anyone have any more concise examples?


    0
    complete -W "$(sed 's/;.*//;' /etc/hosts | awk ' /^[[:digit:]]/ {$1 = "";print tolower($0)}')" ssh
    daodennis · 2011-06-20 03:54:45 3
  • Typographically speaking, it's generally the [accepted wisdom][1] that about 60 characters per line makes for optimal reading (would that more Web pages followed this convention!). I know I got tired of reading manpages with text as wide as my screen! However, the command above sets manwidth to 70 rather than 60 because paragraphs in manpages are generally indented. I recommend the following snippet for your .${SHELL}rc, which sets manwidth to 70 unless your terminal is smaller than 70 characters: function man () { if [[ $COLUMNS -gt 70 ]]; then MANWIDTH=70 command man $* else command man $* fi } [1]: https://en.wikipedia.org/wiki/Column_(typography)


    0
    MANWIDTH=70 man 7 man
    escondida · 2012-01-13 19:42:30 4
  • # AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages # (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies # and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]). # aliases (copy into ~/.bashrc file): alias a='alias' a ap='apt-get' a r='ap autoremove -y' a up='ap update' a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean' # && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed". I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names. # To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs # For more useful aliases go to ow.ly/zBMOx


    0
    apt-get update && apt-get dist-upgrade -y --show-progress && apt-get autoremove -y && apt-get check && apt-get autoclean -y
    unixmonkey78577 · 2014-07-26 12:18:57 6
  • extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; *.tar.gz) tar xvzf $1 ;; *.tar.xz) tar Jxvf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xvf $1 ;; *.tbz2) tar xvjf $1 ;; *.tgz) tar xvzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) echo "don't know how to extract '$1'..." ;; esac read -r -p "Delete the compressed file? [Y/N] " response response=${response,,} # tolower if [[ $response =~ ^([Yy]es|YES|[Yy])$ ]]; then echo "rm '$1'" rm $1 fi else echo "'$1' is not a valid file!" fi }


    0
    extract file.tar.gz
    asdzxc · 2015-02-08 11:17:12 9
  • compress(){ # compress [FIle/Folder] [NewFileName].[Suffix] # compress image.jpg pictures.tar.bz2 # compress Document/ folder.rar if [ -f $1 ] || [ -d $1 ]; then case $2 in *.tar.bz2) tar -jcvf $2 $1 ;; *.tar.gz) tar -zcvpf $2 $1 ;; *.tar) tar -cvpf $2 $1 ;; *.zip) zip -r $2 $1 ;; *.rar) rar a -r -rr10 $2 $1 ;; *) echo "don't know how to compres '$1'..." ;; esac else echo "'$1' is not a valid file or folder2" fi }


    0
    compress pictures/ pictures.tar.gz
    asdzxc · 2015-02-08 11:28:30 13
  • to run write: Sound-volume 30% or Sound-volume 1% Sound-volume 100% Show Sample Output


    0
    alias Sound-volume='amixer -D pulse sset Master '
    asdzxc · 2015-02-08 11:36:44 8
  • alias screen-brightness='xbacklight -set' alias screen-off='xset dpms force standby' alias screen-min='xbacklight -set 1' alias screen-max='xbacklight -set 100' alias screen-inc='xbacklight -inc 10' alias screen-dec='xbacklight -dec 10'


    0
    xbacklight -set 100
    asdzxc · 2015-02-08 12:12:16 8
  • Adds a shortcut (bash alias) for a lightweight detachable 'multi-windowed' cli terminal session to bashrc. Uses 'abduco' (supersedes 'dtach') to implement a personal default detachable terminal session with a 'windowed' terminal UI provided by 'dvtm'. "-A" option allows the shortcut "wm" to be used to both instigate and re-attach to session "your_title_here". "-M" options stops 'dvtm' from changing your default mouse behavior.


    0
    echo 'alias wm="abduco -A your_title_here dvtm -M"' >> ~/.bashrc
    kevjonesin · 2016-03-06 07:42:38 13

  • -2
    complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
    sammcj · 2011-06-01 23:21:06 5
  • To install on centos 6.2 for Centos auto accept: yum install fortune* -y yum install cowsay* -y Removed the -f command as I dont know how, but it works without it. Almost the same but one folder higher =).


    -2
    fortune | cowsay $(ls/usr/share/cowsay | shuf -n1)
    cablegunmaster · 2014-10-23 10:09:44 9

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

force unsupported i386 commands to work on amd64
The above was done using the i386 flashplayer plugin, and was installed on a AMD64 machine running an AMD64 kernel and AMD64 programs. the resulting plugin install ultimately didn't work for swiftfox (but worked for iceweasel) without also covering it with a nspluginwrapper which took a bit of fenangaling to get to work (lots of apt-getting) but it is a nice feature to be able to trick installers that think you need i386 into running on a amd64, or at least attempting to run on amd64. Enjoy

Gets the english pronunciation of a phrase
Usage examples: say hello say "hello world" say hello+world

Generat a Random MAC address
Generate a random MAC address with capital letters

Extract tarball from internet without local saving

Check whether laptop is running on battery or cable
The original proc file doesn't exist on my system.

Install pip with Proxy
Installs pip packages defining a proxy

Track X Window events in chosen window
After executing this, click on a window you want to track X Window events in. Explaination: "xev will track events in the window with the following -id, which we get by greping window information obtained by xwininfo"

dont execute command just add it to history as a comment, handy if your command is not "complete" yet

list files recursively by size

Get the IP address
gives u each configured IP in a seperate line.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: