Your top 10 commands - Desktop Customization & Workflow

Users browsing this thread: 1 Guest(s)
seninha
Long time nixers
After reading this post on z3bra's phlog, I got curious to see what are my top 10 commands.

Quote:Now what are YOUR top 10 commands ?
-- z3bra

On OpenBSD ksh, the history builtin only lists the last 10 commands on history, to list all commands, you need to run this:
Code:
history 1
(history arguments are [first [last]]).

So, this is the command I needed to run:
Code:
history 1 | awk '{print $2}' | sort | uniq -c | sort -rn | head -n 10

My $HISTSIZE is 1000, so my sample is not that big as z3bra's (whose $HISTORY is ten times bigger).

Here's my top 10:
  • 1. vim: I expected that.
  • 2. make: I use makefiles to build programs and documents, move my dotfiles to their proper places, etc.
  • 3. cd
  • 4. d: This is a shell function wrapper around tree(1) (actually colortree(1), a colored version of tree). Yes, I use tree(1), and not ls(1), to list the contents of a directory...
  • 5. agenda: That's a shell script that shows a calendar for the current month, the events for the week and the tasks I need to do. Very handy. For events it calls calendar(1), for the tasks it calls todo(1). Both programs are part of my orgutils. This script reads the agenda and todo files in all directories of '~/proj/' (that is, in every project of mine), adds a prefix to each event and task corresponding to the project name, and pipes them to agenda(1) and todo(1).
  • 6. git.
  • 7. man.
  • 8. xopen: That's my opener script. If I want to open a image with sxiv or a document with zathura, I just call xopen on them.
  • 9. ssh.
  • 10. fm: That's actually an alias for lf, the file manager, with some options.
z3bra
Grey Hair Nixers
Holy cow that post was 1 year ago already ! Good retrospective, given that your top command is vim, I'd suggest aliasing it 😉
That's funny to see you use tree rather than ls. isn't it too verbose when you got a lot of subdirectories ? do you pipe it to less then ?
tuxifreund
Members
I’ve read z3bra’s phlog post a couple of weeks ago but thanks for opening this thread!

So, here’s my top 10:
  • 1. git - I didn’t expected to see git before vim, but I really use git often and as my vim is opened longer and I just open a new buffer there.
  • 2. vim - Place 2 is well, too.
  • 3. sudo - mostly used to run pacman as root to install packages
  • 4. l - alias of
    Code:
    ls
    , which itself is an alias of
    Code:
    ls --color=auto
  • 5. mutt - Do I really use mutt that much?
  • 6. tmux - Didn’t thaught seeing this on place 6.
  • 7. python − Most of my programs are written in python, so this is the command I start them.
  • 8. toot - my Mastodon client
  • 9. ssh - I use this to administrate my server and to ssh to it as there is running my WeeChat instance
  • 10. rm - Nothing to say here.
ols
Members
I wrote a follow up log to z3bra, my top ten are:

Code:
$ history | awk '{print $4}' | sort | uniq -c | sort -rn | head -n 10
   10442 vim
   8521 k
   5755 git
   5644 cd
   5091 ls
   4155 ssh
   3560 cat
   2251 curl
   1406 make
   1385 pscli
dionys
Nixers
Top Ten:
  1. sudo - nearly a third of the history
  2. vim - main editor, also used to view files when I want highlighting or folding
  3. apt-cache - searches for packages, or checking dependencies
  4. ls - alias that adds '--color=auto'
  5. lp - lots of print jobs with custom parameters
  6. cd - lots of these from going up or down one level
  7. git - breakdown: log, status, pull, clone, config, remote, init, describe
  8. echo - testing regex makes this pretty high
  9. cat - viewing file contents
  10. mv - wrangling third-party code in /opt/ that I rebuild when there's an update

sudo breakdown:
* apt-get - installing/updating/cleaning up packages
* vim - editing system files
* mount - mucking around with university cifs shares
* systemctl - stuck with systemd for now, for fear I'd break commercial software
* mkdir - reorganizing installed scripts / libs
* chown - cleaning up permissions
* mv - reorganizing
* chmod - cleaning up permissions
* ufw - opening ports
* virsh - starting/configuring vm's

Here's a hack for the last bit:
Code:
history|grep "^[^ ]*[ ]\bsudo\b"|awk '{print $3}'|sort|uniq -c|sort -rn|head -n 10
seninha
Long time nixers
(15-10-2021, 02:26 AM)z3bra Wrote: That's funny to see you use tree rather than ls. isn't it too verbose when you got a lot of subdirectories ? do you pipe it to less then ?

The function I wrote defaults to depth 1 (no subdirectories), but I can call it with the option -2 to list contents of subdirectories, -3 to list content of subdirectories up to depth 3, etc. Or -0 to recursively list at infinite depth. So there's no need to pipe to less, since the default output is not recursive.

The function also has find(1) functionalities. If I give it an argument, it looks for a file named as the argument in the filesystem up to the depth I specify.

The function also lists in the long format, so I get the size of the files and their permissions.

ls -Rl and find -iname in a single command!
freem
Nixers
Code:
% history 1 | awk '{print $2}' | sort | uniq -c | sort -rn | head -n 10
   1407 git
    662 ls
    530 cd
    340 vim
    279 make
    144 rm
    131 grep
    107 find
     82 man
     72 ps

But that's very likely wrong, because I use lot of terminals, and histories does not merge well. I'm not surprised with the high top though, git being such a pain in the ass to use, you have to use it a lot before commiting something. ls and cd... well, I should alias them to something which does both, or even better, stop using shell directly, because shells are so not convenient to use interactively... that's still the kind of stuff I summon a lot, though. Then goes vim and make, not surprising as coding is one of my major occupations.

I'm surprised to see rm that high, before grep and find, I would have thought I use those more often... and then yes, I read lot of man pages, which includes almost each time I need a `test` or a decent `find`. As for ps, yeah, I'm constantly hunting stuff which wastes my computer's resources. I'm a bit surprised to not see pstree or pree in there, though.
humky
Members
Code:
16223 cd
10417 vim
6059 cat
4991 ls
3866 mix
3631 touch
2712 rm
2135 sudo
1782 mv
1650 loc

Sample size is 88k, mix - alsamixer, loc - online+vpn checker
cd is killing me, I need to install zsh and do a/b/c and adopt jump program.
venam
Administrators
My $HISTSIZE is 100k so the sample is quite big.
Here's the unsurprising result I get:

Code:
4685 vim
   3931 cd
   2969 mv
   2868 rm
   2342 sudo
   1948 mplayer
   1651 git
   1332 man
   1036 cp
   1003 cat
z3bra
Grey Hair Nixers
Why the hell do you guys use rm(1) so much ?
freem
Nixers
For me, the 2 main reasons I can see are:

1) removal of screenshots, that I should likely just put in /tmp instead (yeah, I *should* do that, and other adjustments, too)
2) removal of garbage programs leave behind, even in /tmp (yeah, I *should* find a way to remove /tmp stuff after some some duration...)
3) removal of cmake's or other toolis like this artifacts when stuff break
4) removal of temp files I write, often in my $HOME

Other than that... I don't know, it surprises me too.
Globally, I think my workflow is pretty inefficient, tbh.
humky
Members
I rm: directories, temp files, scripts, configs, movies I just watched, archives after extraction etc.
Mostly just files, all sorts of files. It's probably depends on workflow, if it's git-centric or not.
z3bra
Grey Hair Nixers
You guys should mount your download directory as TMPFS 😉
This way everything I download goes to ~/tmp and is wiped as I reboot. So when I download archives, I extract them right in ~/tmp, and only move files I need in there, leaving the archive in ~/tmp knowing it'll disappear on next reboot.
humky
Members
My downloads folder is more of a 'to sort' folder, I know most of things just decaying in there, but I will get to it one day.
VMS
Members
I prefer not to keep a static history file, as I may type sensitive information on the terminal; instead, I like to have per-session history:
Code:
    if [ -d ~/.history ]; then
      HISTFILE=~/.history/hist.$(tty | sed 's;.*/;;')
          trap 'rm -f $HISTFILE' EXIT
    else
      HISTFILE=~/.history
    fi
venam
Administrators
(28-02-2022, 11:48 AM)DECnet Wrote: I like to have per-session history
What's your process to search in the history file? Do you purge old files also?

For many the histfile is a huge source of knowledge, so they increase it's size as much as possible (including me).
VMS
Members
(01-03-2022, 06:04 AM)venam Wrote: What's your process to search in the history file?


I use a function like:

Code:
# show history
        h() {
                fc -l 1 | sort | uniq;
        }

Quote:Do you purge old files also?

Well, if you look at the HISTFILE settings I posted above, each login shell has its temporary history, which is purged upon exiting. As I have rxvt set to spawn a login shell by default, each terminal emulator under X has its own temporary history.

Quote:For many the histfile is a huge source of knowledge, so they increase it's size as much as possible (including me).

I won't deny understanding this perfectly ;). Personally however, I've become accustomed to save useful commands in functions, aliases or ~/.bin scripts. Not having a history to rely on forces me to actually look carefully at the commands I find online (e.g., the typical 'awk' magic one may find it hard to figure themselves), so as to remember them the next time.
jkl
Long time nixers
Just in case anyone wonders, this command works on macOS (with the tcsh):

Code:
% history | awk '{print substr($0,index($0,$3))}' | sort | uniq -c | sort -rn | head -n 10

(I won't post my results here - there are personal data in them.)

--
<mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen
Hatbox
Registered
I use a lot of programs from Plan9port, including rc as my shell. rc has no history file support.

Instead of relying on my shell to create my history, I use my text editor, acme. Acme has this neat feature where you can spawn a shell within an acme window, which means that it's essentially a terminal inside of a plaintext file. At any point it can be edited or saved. So that instead of having a history file, I have a history directory.

Whenever I do something somewhat complex or I figure out the perfect awk script to preform some function, I save all the relevant commands with their output to a file in my history directory. For example, I have a file for generating new git repos for stagit on my server. I find it a much better reference than a simple history file, because not only do I get the command(s) that worked, I also get why they worked, and why another command didn't. I can even add notes while I'm executing the commands, or after I save the file. It gives me a better understanding of my command history. I also don't have to sift through a million 'cd' or 'ls' commands.

If I had a proper history file, my top ten would probably be some combination of p (alias for plumb), ls, cd, git, man, rm, B, mv, Sel (used for looking through my music library in acme), and ssh.
yuno
Registered
1. vim
2. cd
3 ls (cd and ls being high up makes sense, I don't use a file manager)
4 sudo (presumably from using pacman)
5 make
6 neocities (for pushing to my blog, surprised it's this high up)
7 rm (guess i make a lot of mistakes lol)
8 n (alias for newsboat)
9 iamb (matrix client)
10 ssh (hanging out on pubnixes)
josuah
Long time nixers
I think I got polluted by my own ecosystem and do not have a sane workflow like Yuno but....

I rarely do "ls": I use tab to show the list of files, and disable bash specific completion (so that it shows the files even when it expects only directories).

I rarely do "cd": I run most things from some project directory, and I have "cd ~/zephyrproject/zephyr" in ~/.bashrc for whichever project I work on.

1. "xrun" - (which I bound to a keybinding: a script to open a new https://tools.suckless.org/tabbed/ terminal, with an initial command that spawn at every new tab, or if a tabbed window is focused, spawn the command as a tab *inside* the focused window)

2. "$clientname" - (which is an alias to something like "xrun sudo -s -u $clientname" to run a new session in /home/$clientname where every time I spawn a new tab, it's under that user.

3. "root" - alias to "xrun sudo -s" which I call from dmenu to run a temporary terminal tab as root within some other "tabbed" session (i.e. modify /etc/profile where all these aliases are)

4. "o" - open the file on a new local tab, even if it is over SSH: alias to xopen (my xdg-open script with a giant "case $1 in (https://...) ... ;; esac"... or if running from ssh, send "ssh://$HOST/$filename" to "/tmp/$user@host.sock" which is telling my local host to call xdg-open on that, which recognizes "ssh://" and spawns "xrun ssh $HOST $EDITOR $filename"

5. "xssh" - same as ssh, but setups the socket forwarding like used above. Some ad-hoc unixargs.c combines unix socket and xargs, to spawn the xdg-open on every `\n` lines received from the "o" alias (source below)

6. "west" - the command to compile and run unit tests on Zephyr

7. "make" - various projects which uses it

8. "www" - at least once per day to start the big bad browser

9. "irc" - ssh to $HOST and calls "abduco -a irssi" to check out messages

10. "rm -rf" - muahahahahahahaha (delete ./out-twister/ directory or ./build/ that keep spawning on builds)

Code:
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include <sys/socket.h>
#include <sys/un.h>

#define LINE_SIZE 1024

int recv_first_line(int fd, char *line_buf, size_t line_sz)
{
    char *buf = line_buf;
    size_t sz = line_sz;

    for (ssize_t n; sz > 0 && (n = recv(fd, buf, sz, MSG_WAITALL)) != 0; sz -= n, buf += n) {
        if (n < 0) {
            return -errno;
        }
    }
    line_buf[line_sz - 1] = '\0';
    line_buf[strcspn(line_buf, "\r\n")] = '\0';
    return 0;
}

int handle_connection(int fd, char **argv, char **placeholder)
{
    char line[LINE_SIZE] = {0};
    int err;

    err = shutdown(fd, SHUT_WR);
    if (err) {
        perror("shutdown");
        return -errno;
    }

    err = recv_first_line(fd, line, sizeof(line));
    if (err) {
        perror("recv_first_line");
        return err;
    }

    *placeholder = line;

    printf("unixargs:");
    for (size_t i = 0; argv[i] != NULL; i++) {
        printf(" %s", argv[i]);
    }
    printf("\n");

    switch (fork()) {
    case -1:
        perror("fork");
        return -errno;
    case 0:
        execvp(argv[0], argv);
        perror(argv[0]);
        return -errno;
    }

    return 0;
}

int xserver(char *path, char **argv, char **placeholder)
{
    struct sockaddr_un sun = { .sun_family = AF_UNIX };
    int sockfd, netfd, err;

    sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
    if (sockfd < 0) {
        perror("socket(AF_UNIX)");
        return -errno;
    }

    strncpy(sun.sun_path, path, sizeof(sun.sun_path) - 1);
    err = bind(sockfd, (struct sockaddr *)&sun, sizeof(sun));
    if (err) {
        perror(path);
        return -errno;
    }

    err = listen(sockfd, 10);
    if (err) {
        perror(path);
        return -errno;
    }

    while (true) {
        netfd = accept(sockfd, NULL, NULL);
        if (netfd < 0) {
            perror(path);
            continue;
        }

        handle_connection(netfd, argv, placeholder);
    }

    return 0;
}

void usage(char *argv0)
{
    fprintf(stderr, "Usage: %s ./path.sock cmd [args...] {} [args...]\n", argv0);
    exit(1);
}

int main(int argc, char **argv)
{
    char **placeholder = NULL;
    int err;

    if (argc < 4) {
        usage(argv[0]);
    }

    for (int i = 3; i < argc; i++) {
        if (strcmp(argv[i], "{}") == 0) {
            placeholder = &argv[i];
            break;
        }
    }
    if (placeholder == NULL) {
        usage(argv[0]);
    }

    err = xserver(argv[1], argv + 2, placeholder);
    if (err) {
        fprintf(stderr, "failed to run xserver, exiting\n");
        return -err;
    }

    return 0;
}

P.S.: I know I can use tmux to skip all of that messy business, but I'm trapped in my own habits, please come save me! (;_;) :P
josuah
Long time nixers
I think I under-estimated the git commands in that. Glad to be reminded to actually check the data:

Code:
git --all --decorate --oneline --graph # aliased to git dog

Very glad to learn about https://github.com/ulyssa/iamb !